babylon.module.d.ts 4.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077
  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. MAX_SHADER_COMPILER_THREADS_KHR: number;
  27289. maxShaderCompilerThreadsKHR: (thread: number) => void;
  27290. COMPLETION_STATUS_KHR: number;
  27291. };
  27292. }
  27293. /** Interface defining initialization parameters for Engine class */
  27294. export interface EngineOptions extends WebGLContextAttributes {
  27295. /**
  27296. * Defines if the engine should no exceed a specified device ratio
  27297. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27298. */
  27299. limitDeviceRatio?: number;
  27300. /**
  27301. * Defines if webvr should be enabled automatically
  27302. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27303. */
  27304. autoEnableWebVR?: boolean;
  27305. /**
  27306. * Defines if webgl2 should be turned off even if supported
  27307. * @see http://doc.babylonjs.com/features/webgl2
  27308. */
  27309. disableWebGL2Support?: boolean;
  27310. /**
  27311. * Defines if webaudio should be initialized as well
  27312. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27313. */
  27314. audioEngine?: boolean;
  27315. /**
  27316. * Defines if animations should run using a deterministic lock step
  27317. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27318. */
  27319. deterministicLockstep?: boolean;
  27320. /** Defines the maximum steps to use with deterministic lock step mode */
  27321. lockstepMaxSteps?: number;
  27322. /**
  27323. * Defines that engine should ignore context lost events
  27324. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27325. */
  27326. doNotHandleContextLost?: boolean;
  27327. /**
  27328. * Defines that engine should ignore modifying touch action attribute and style
  27329. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27330. */
  27331. doNotHandleTouchAction?: boolean;
  27332. /**
  27333. * Defines that engine should compile shaders with high precision floats (if supported). False by default
  27334. */
  27335. useHighPrecisionFloats?: boolean;
  27336. }
  27337. /**
  27338. * Defines the interface used by display changed events
  27339. */
  27340. export interface IDisplayChangedEventArgs {
  27341. /** Gets the vrDisplay object (if any) */
  27342. vrDisplay: Nullable<any>;
  27343. /** Gets a boolean indicating if webVR is supported */
  27344. vrSupported: boolean;
  27345. }
  27346. /**
  27347. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27348. */
  27349. export class Engine {
  27350. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27351. static ExceptionList: ({
  27352. key: string;
  27353. capture: string;
  27354. captureConstraint: number;
  27355. targets: string[];
  27356. } | {
  27357. key: string;
  27358. capture: null;
  27359. captureConstraint: null;
  27360. targets: string[];
  27361. })[];
  27362. /** Gets the list of created engines */
  27363. static readonly Instances: Engine[];
  27364. /**
  27365. * Gets the latest created engine
  27366. */
  27367. static readonly LastCreatedEngine: Nullable<Engine>;
  27368. /**
  27369. * Gets the latest created scene
  27370. */
  27371. static readonly LastCreatedScene: Nullable<Scene>;
  27372. /**
  27373. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27374. * @param flag defines which part of the materials must be marked as dirty
  27375. * @param predicate defines a predicate used to filter which materials should be affected
  27376. */
  27377. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27378. /**
  27379. * Hidden
  27380. */
  27381. static _TextureLoaders: IInternalTextureLoader[];
  27382. /** Defines that alpha blending is disabled */
  27383. static readonly ALPHA_DISABLE: number;
  27384. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27385. static readonly ALPHA_ADD: number;
  27386. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27387. static readonly ALPHA_COMBINE: number;
  27388. /** Defines that alpha blending to DEST - SRC * DEST */
  27389. static readonly ALPHA_SUBTRACT: number;
  27390. /** Defines that alpha blending to SRC * DEST */
  27391. static readonly ALPHA_MULTIPLY: number;
  27392. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27393. static readonly ALPHA_MAXIMIZED: number;
  27394. /** Defines that alpha blending to SRC + DEST */
  27395. static readonly ALPHA_ONEONE: number;
  27396. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27397. static readonly ALPHA_PREMULTIPLIED: number;
  27398. /**
  27399. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27400. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27401. */
  27402. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27403. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27404. static readonly ALPHA_INTERPOLATE: number;
  27405. /**
  27406. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27407. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27408. */
  27409. static readonly ALPHA_SCREENMODE: number;
  27410. /** Defines that the ressource is not delayed*/
  27411. static readonly DELAYLOADSTATE_NONE: number;
  27412. /** Defines that the ressource was successfully delay loaded */
  27413. static readonly DELAYLOADSTATE_LOADED: number;
  27414. /** Defines that the ressource is currently delay loading */
  27415. static readonly DELAYLOADSTATE_LOADING: number;
  27416. /** Defines that the ressource is delayed and has not started loading */
  27417. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27418. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27419. static readonly NEVER: number;
  27420. /** 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 */
  27421. static readonly ALWAYS: number;
  27422. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27423. static readonly LESS: number;
  27424. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27425. static readonly EQUAL: number;
  27426. /** 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 */
  27427. static readonly LEQUAL: number;
  27428. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27429. static readonly GREATER: number;
  27430. /** 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 */
  27431. static readonly GEQUAL: number;
  27432. /** 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 */
  27433. static readonly NOTEQUAL: number;
  27434. /** Passed to stencilOperation to specify that stencil value must be kept */
  27435. static readonly KEEP: number;
  27436. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27437. static readonly REPLACE: number;
  27438. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27439. static readonly INCR: number;
  27440. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27441. static readonly DECR: number;
  27442. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27443. static readonly INVERT: number;
  27444. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27445. static readonly INCR_WRAP: number;
  27446. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27447. static readonly DECR_WRAP: number;
  27448. /** Texture is not repeating outside of 0..1 UVs */
  27449. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27450. /** Texture is repeating outside of 0..1 UVs */
  27451. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27452. /** Texture is repeating and mirrored */
  27453. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27454. /** ALPHA */
  27455. static readonly TEXTUREFORMAT_ALPHA: number;
  27456. /** LUMINANCE */
  27457. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27458. /** LUMINANCE_ALPHA */
  27459. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27460. /** RGB */
  27461. static readonly TEXTUREFORMAT_RGB: number;
  27462. /** RGBA */
  27463. static readonly TEXTUREFORMAT_RGBA: number;
  27464. /** RED */
  27465. static readonly TEXTUREFORMAT_RED: number;
  27466. /** RED (2nd reference) */
  27467. static readonly TEXTUREFORMAT_R: number;
  27468. /** RG */
  27469. static readonly TEXTUREFORMAT_RG: number;
  27470. /** RED_INTEGER */
  27471. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27472. /** RED_INTEGER (2nd reference) */
  27473. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27474. /** RG_INTEGER */
  27475. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27476. /** RGB_INTEGER */
  27477. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27478. /** RGBA_INTEGER */
  27479. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27480. /** UNSIGNED_BYTE */
  27481. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27482. /** UNSIGNED_BYTE (2nd reference) */
  27483. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27484. /** FLOAT */
  27485. static readonly TEXTURETYPE_FLOAT: number;
  27486. /** HALF_FLOAT */
  27487. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27488. /** BYTE */
  27489. static readonly TEXTURETYPE_BYTE: number;
  27490. /** SHORT */
  27491. static readonly TEXTURETYPE_SHORT: number;
  27492. /** UNSIGNED_SHORT */
  27493. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27494. /** INT */
  27495. static readonly TEXTURETYPE_INT: number;
  27496. /** UNSIGNED_INT */
  27497. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27498. /** UNSIGNED_SHORT_4_4_4_4 */
  27499. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27500. /** UNSIGNED_SHORT_5_5_5_1 */
  27501. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27502. /** UNSIGNED_SHORT_5_6_5 */
  27503. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27504. /** UNSIGNED_INT_2_10_10_10_REV */
  27505. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27506. /** UNSIGNED_INT_24_8 */
  27507. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27508. /** UNSIGNED_INT_10F_11F_11F_REV */
  27509. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27510. /** UNSIGNED_INT_5_9_9_9_REV */
  27511. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27512. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27513. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27514. /** nearest is mag = nearest and min = nearest and mip = linear */
  27515. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27516. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27517. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27518. /** Trilinear is mag = linear and min = linear and mip = linear */
  27519. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27520. /** nearest is mag = nearest and min = nearest and mip = linear */
  27521. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27522. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27523. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27524. /** Trilinear is mag = linear and min = linear and mip = linear */
  27525. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27526. /** mag = nearest and min = nearest and mip = nearest */
  27527. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27528. /** mag = nearest and min = linear and mip = nearest */
  27529. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27530. /** mag = nearest and min = linear and mip = linear */
  27531. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27532. /** mag = nearest and min = linear and mip = none */
  27533. static readonly TEXTURE_NEAREST_LINEAR: number;
  27534. /** mag = nearest and min = nearest and mip = none */
  27535. static readonly TEXTURE_NEAREST_NEAREST: number;
  27536. /** mag = linear and min = nearest and mip = nearest */
  27537. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27538. /** mag = linear and min = nearest and mip = linear */
  27539. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27540. /** mag = linear and min = linear and mip = none */
  27541. static readonly TEXTURE_LINEAR_LINEAR: number;
  27542. /** mag = linear and min = nearest and mip = none */
  27543. static readonly TEXTURE_LINEAR_NEAREST: number;
  27544. /** Explicit coordinates mode */
  27545. static readonly TEXTURE_EXPLICIT_MODE: number;
  27546. /** Spherical coordinates mode */
  27547. static readonly TEXTURE_SPHERICAL_MODE: number;
  27548. /** Planar coordinates mode */
  27549. static readonly TEXTURE_PLANAR_MODE: number;
  27550. /** Cubic coordinates mode */
  27551. static readonly TEXTURE_CUBIC_MODE: number;
  27552. /** Projection coordinates mode */
  27553. static readonly TEXTURE_PROJECTION_MODE: number;
  27554. /** Skybox coordinates mode */
  27555. static readonly TEXTURE_SKYBOX_MODE: number;
  27556. /** Inverse Cubic coordinates mode */
  27557. static readonly TEXTURE_INVCUBIC_MODE: number;
  27558. /** Equirectangular coordinates mode */
  27559. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27560. /** Equirectangular Fixed coordinates mode */
  27561. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27562. /** Equirectangular Fixed Mirrored coordinates mode */
  27563. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27564. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27565. static readonly SCALEMODE_FLOOR: number;
  27566. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27567. static readonly SCALEMODE_NEAREST: number;
  27568. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27569. static readonly SCALEMODE_CEILING: number;
  27570. /**
  27571. * Returns the current version of the framework
  27572. */
  27573. static readonly Version: string;
  27574. /**
  27575. * Returns a string describing the current engine
  27576. */
  27577. readonly description: string;
  27578. /**
  27579. * Gets or sets the epsilon value used by collision engine
  27580. */
  27581. static CollisionsEpsilon: number;
  27582. /**
  27583. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27584. */
  27585. static ShadersRepository: string;
  27586. /**
  27587. * Method called to create the default loading screen.
  27588. * This can be overriden in your own app.
  27589. * @param canvas The rendering canvas element
  27590. * @returns The loading screen
  27591. */
  27592. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27593. /**
  27594. * Method called to create the default rescale post process on each engine.
  27595. */
  27596. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27597. /**
  27598. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27599. */
  27600. forcePOTTextures: boolean;
  27601. /**
  27602. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27603. */
  27604. isFullscreen: boolean;
  27605. /**
  27606. * Gets a boolean indicating if the pointer is currently locked
  27607. */
  27608. isPointerLock: boolean;
  27609. /**
  27610. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27611. */
  27612. cullBackFaces: boolean;
  27613. /**
  27614. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27615. */
  27616. renderEvenInBackground: boolean;
  27617. /**
  27618. * Gets or sets a boolean indicating that cache can be kept between frames
  27619. */
  27620. preventCacheWipeBetweenFrames: boolean;
  27621. /**
  27622. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27623. **/
  27624. enableOfflineSupport: boolean;
  27625. /**
  27626. * 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)
  27627. **/
  27628. disableManifestCheck: boolean;
  27629. /**
  27630. * Gets the list of created scenes
  27631. */
  27632. scenes: Scene[];
  27633. /**
  27634. * Event raised when a new scene is created
  27635. */
  27636. onNewSceneAddedObservable: Observable<Scene>;
  27637. /**
  27638. * Gets the list of created postprocesses
  27639. */
  27640. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27641. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27642. validateShaderPrograms: boolean;
  27643. /**
  27644. * Observable event triggered each time the rendering canvas is resized
  27645. */
  27646. onResizeObservable: Observable<Engine>;
  27647. /**
  27648. * Observable event triggered each time the canvas loses focus
  27649. */
  27650. onCanvasBlurObservable: Observable<Engine>;
  27651. /**
  27652. * Observable event triggered each time the canvas gains focus
  27653. */
  27654. onCanvasFocusObservable: Observable<Engine>;
  27655. /**
  27656. * Observable event triggered each time the canvas receives pointerout event
  27657. */
  27658. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27659. /**
  27660. * Observable event triggered before each texture is initialized
  27661. */
  27662. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27663. private _vrDisplay;
  27664. private _vrSupported;
  27665. private _oldSize;
  27666. private _oldHardwareScaleFactor;
  27667. private _vrExclusivePointerMode;
  27668. private _webVRInitPromise;
  27669. /**
  27670. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27671. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27672. */
  27673. readonly isInVRExclusivePointerMode: boolean;
  27674. /**
  27675. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27676. */
  27677. disableUniformBuffers: boolean;
  27678. /** @hidden */
  27679. _uniformBuffers: UniformBuffer[];
  27680. /**
  27681. * Gets a boolean indicating that the engine supports uniform buffers
  27682. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27683. */
  27684. readonly supportsUniformBuffers: boolean;
  27685. /**
  27686. * Observable raised when the engine begins a new frame
  27687. */
  27688. onBeginFrameObservable: Observable<Engine>;
  27689. /**
  27690. * If set, will be used to request the next animation frame for the render loop
  27691. */
  27692. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27693. /**
  27694. * Observable raised when the engine ends the current frame
  27695. */
  27696. onEndFrameObservable: Observable<Engine>;
  27697. /**
  27698. * Observable raised when the engine is about to compile a shader
  27699. */
  27700. onBeforeShaderCompilationObservable: Observable<Engine>;
  27701. /**
  27702. * Observable raised when the engine has jsut compiled a shader
  27703. */
  27704. onAfterShaderCompilationObservable: Observable<Engine>;
  27705. /** @hidden */
  27706. _gl: WebGLRenderingContext;
  27707. private _renderingCanvas;
  27708. private _windowIsBackground;
  27709. private _webGLVersion;
  27710. protected _highPrecisionShadersAllowed: boolean;
  27711. /** @hidden */
  27712. readonly _shouldUseHighPrecisionShader: boolean;
  27713. /**
  27714. * Gets a boolean indicating that only power of 2 textures are supported
  27715. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27716. */
  27717. readonly needPOTTextures: boolean;
  27718. /** @hidden */
  27719. _badOS: boolean;
  27720. /** @hidden */
  27721. _badDesktopOS: boolean;
  27722. /**
  27723. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27724. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27725. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27726. */
  27727. disableTextureBindingOptimization: boolean;
  27728. /**
  27729. * Gets the audio engine
  27730. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27731. * @ignorenaming
  27732. */
  27733. static audioEngine: IAudioEngine;
  27734. /**
  27735. * Default AudioEngine factory responsible of creating the Audio Engine.
  27736. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27737. */
  27738. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27739. /**
  27740. * Default offline support factory responsible of creating a tool used to store data locally.
  27741. * By default, this will create a Database object if the workload has been embedded.
  27742. */
  27743. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27744. private _onFocus;
  27745. private _onBlur;
  27746. private _onCanvasPointerOut;
  27747. private _onCanvasBlur;
  27748. private _onCanvasFocus;
  27749. private _onFullscreenChange;
  27750. private _onPointerLockChange;
  27751. private _onVRDisplayPointerRestricted;
  27752. private _onVRDisplayPointerUnrestricted;
  27753. private _onVrDisplayConnect;
  27754. private _onVrDisplayDisconnect;
  27755. private _onVrDisplayPresentChange;
  27756. /**
  27757. * Observable signaled when VR display mode changes
  27758. */
  27759. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27760. /**
  27761. * Observable signaled when VR request present is complete
  27762. */
  27763. onVRRequestPresentComplete: Observable<boolean>;
  27764. /**
  27765. * Observable signaled when VR request present starts
  27766. */
  27767. onVRRequestPresentStart: Observable<Engine>;
  27768. private _hardwareScalingLevel;
  27769. /** @hidden */
  27770. protected _caps: EngineCapabilities;
  27771. private _pointerLockRequested;
  27772. private _isStencilEnable;
  27773. private _colorWrite;
  27774. private _loadingScreen;
  27775. /** @hidden */
  27776. _drawCalls: PerfCounter;
  27777. /** @hidden */
  27778. _textureCollisions: PerfCounter;
  27779. private _glVersion;
  27780. private _glRenderer;
  27781. private _glVendor;
  27782. private _videoTextureSupported;
  27783. private _renderingQueueLaunched;
  27784. private _activeRenderLoops;
  27785. private _deterministicLockstep;
  27786. private _lockstepMaxSteps;
  27787. /**
  27788. * Observable signaled when a context lost event is raised
  27789. */
  27790. onContextLostObservable: Observable<Engine>;
  27791. /**
  27792. * Observable signaled when a context restored event is raised
  27793. */
  27794. onContextRestoredObservable: Observable<Engine>;
  27795. private _onContextLost;
  27796. private _onContextRestored;
  27797. private _contextWasLost;
  27798. private _doNotHandleContextLost;
  27799. /**
  27800. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27801. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27802. */
  27803. doNotHandleContextLost: boolean;
  27804. private _performanceMonitor;
  27805. private _fps;
  27806. private _deltaTime;
  27807. /**
  27808. * Turn this value on if you want to pause FPS computation when in background
  27809. */
  27810. disablePerformanceMonitorInBackground: boolean;
  27811. /**
  27812. * Gets the performance monitor attached to this engine
  27813. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27814. */
  27815. readonly performanceMonitor: PerformanceMonitor;
  27816. /** @hidden */
  27817. protected _depthCullingState: _DepthCullingState;
  27818. /** @hidden */
  27819. protected _stencilState: _StencilState;
  27820. /** @hidden */
  27821. protected _alphaState: _AlphaState;
  27822. /** @hidden */
  27823. protected _alphaMode: number;
  27824. protected _internalTexturesCache: InternalTexture[];
  27825. /** @hidden */
  27826. protected _activeChannel: number;
  27827. private _currentTextureChannel;
  27828. /** @hidden */
  27829. protected _boundTexturesCache: {
  27830. [key: string]: Nullable<InternalTexture>;
  27831. };
  27832. /** @hidden */
  27833. protected _currentEffect: Nullable<Effect>;
  27834. /** @hidden */
  27835. protected _currentProgram: Nullable<WebGLProgram>;
  27836. private _compiledEffects;
  27837. private _vertexAttribArraysEnabled;
  27838. /** @hidden */
  27839. protected _cachedViewport: Nullable<Viewport>;
  27840. private _cachedVertexArrayObject;
  27841. /** @hidden */
  27842. protected _cachedVertexBuffers: any;
  27843. /** @hidden */
  27844. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27845. /** @hidden */
  27846. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27847. /** @hidden */
  27848. protected _currentRenderTarget: Nullable<InternalTexture>;
  27849. private _uintIndicesCurrentlySet;
  27850. private _currentBoundBuffer;
  27851. /** @hidden */
  27852. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27853. private _currentBufferPointers;
  27854. private _currentInstanceLocations;
  27855. private _currentInstanceBuffers;
  27856. private _textureUnits;
  27857. private _firstBoundInternalTextureTracker;
  27858. private _lastBoundInternalTextureTracker;
  27859. private _workingCanvas;
  27860. private _workingContext;
  27861. private _rescalePostProcess;
  27862. private _dummyFramebuffer;
  27863. private _externalData;
  27864. private _bindedRenderFunction;
  27865. private _vaoRecordInProgress;
  27866. private _mustWipeVertexAttributes;
  27867. private _emptyTexture;
  27868. private _emptyCubeTexture;
  27869. private _emptyTexture3D;
  27870. /** @hidden */
  27871. _frameHandler: number;
  27872. private _nextFreeTextureSlots;
  27873. private _maxSimultaneousTextures;
  27874. private _activeRequests;
  27875. private _texturesSupported;
  27876. private _textureFormatInUse;
  27877. /**
  27878. * Gets the list of texture formats supported
  27879. */
  27880. readonly texturesSupported: Array<string>;
  27881. /**
  27882. * Gets the list of texture formats in use
  27883. */
  27884. readonly textureFormatInUse: Nullable<string>;
  27885. /**
  27886. * Gets the current viewport
  27887. */
  27888. readonly currentViewport: Nullable<Viewport>;
  27889. /**
  27890. * Gets the default empty texture
  27891. */
  27892. readonly emptyTexture: InternalTexture;
  27893. /**
  27894. * Gets the default empty 3D texture
  27895. */
  27896. readonly emptyTexture3D: InternalTexture;
  27897. /**
  27898. * Gets the default empty cube texture
  27899. */
  27900. readonly emptyCubeTexture: InternalTexture;
  27901. /**
  27902. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27903. */
  27904. readonly premultipliedAlpha: boolean;
  27905. /**
  27906. * Creates a new engine
  27907. * @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
  27908. * @param antialias defines enable antialiasing (default: false)
  27909. * @param options defines further options to be sent to the getContext() function
  27910. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27911. */
  27912. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27913. private _disableTouchAction;
  27914. private _rebuildInternalTextures;
  27915. private _rebuildEffects;
  27916. /**
  27917. * Gets a boolean indicating if all created effects are ready
  27918. * @returns true if all effects are ready
  27919. */
  27920. areAllEffectsReady(): boolean;
  27921. private _rebuildBuffers;
  27922. private _initGLContext;
  27923. /**
  27924. * Gets version of the current webGL context
  27925. */
  27926. readonly webGLVersion: number;
  27927. /**
  27928. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27929. */
  27930. readonly isStencilEnable: boolean;
  27931. private _prepareWorkingCanvas;
  27932. /**
  27933. * Reset the texture cache to empty state
  27934. */
  27935. resetTextureCache(): void;
  27936. /**
  27937. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27938. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27939. * @returns true if engine is in deterministic lock step mode
  27940. */
  27941. isDeterministicLockStep(): boolean;
  27942. /**
  27943. * Gets the max steps when engine is running in deterministic lock step
  27944. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27945. * @returns the max steps
  27946. */
  27947. getLockstepMaxSteps(): number;
  27948. /**
  27949. * Gets an object containing information about the current webGL context
  27950. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27951. */
  27952. getGlInfo(): {
  27953. vendor: string;
  27954. renderer: string;
  27955. version: string;
  27956. };
  27957. /**
  27958. * Gets current aspect ratio
  27959. * @param camera defines the camera to use to get the aspect ratio
  27960. * @param useScreen defines if screen size must be used (or the current render target if any)
  27961. * @returns a number defining the aspect ratio
  27962. */
  27963. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27964. /**
  27965. * Gets current screen aspect ratio
  27966. * @returns a number defining the aspect ratio
  27967. */
  27968. getScreenAspectRatio(): number;
  27969. /**
  27970. * Gets the current render width
  27971. * @param useScreen defines if screen size must be used (or the current render target if any)
  27972. * @returns a number defining the current render width
  27973. */
  27974. getRenderWidth(useScreen?: boolean): number;
  27975. /**
  27976. * Gets the current render height
  27977. * @param useScreen defines if screen size must be used (or the current render target if any)
  27978. * @returns a number defining the current render height
  27979. */
  27980. getRenderHeight(useScreen?: boolean): number;
  27981. /**
  27982. * Gets the HTML canvas attached with the current webGL context
  27983. * @returns a HTML canvas
  27984. */
  27985. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27986. /**
  27987. * Gets the client rect of the HTML canvas attached with the current webGL context
  27988. * @returns a client rectanglee
  27989. */
  27990. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27991. /**
  27992. * Defines the hardware scaling level.
  27993. * By default the hardware scaling level is computed from the window device ratio.
  27994. * 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.
  27995. * @param level defines the level to use
  27996. */
  27997. setHardwareScalingLevel(level: number): void;
  27998. /**
  27999. * Gets the current hardware scaling level.
  28000. * By default the hardware scaling level is computed from the window device ratio.
  28001. * 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.
  28002. * @returns a number indicating the current hardware scaling level
  28003. */
  28004. getHardwareScalingLevel(): number;
  28005. /**
  28006. * Gets the list of loaded textures
  28007. * @returns an array containing all loaded textures
  28008. */
  28009. getLoadedTexturesCache(): InternalTexture[];
  28010. /**
  28011. * Gets the object containing all engine capabilities
  28012. * @returns the EngineCapabilities object
  28013. */
  28014. getCaps(): EngineCapabilities;
  28015. /**
  28016. * Gets the current depth function
  28017. * @returns a number defining the depth function
  28018. */
  28019. getDepthFunction(): Nullable<number>;
  28020. /**
  28021. * Sets the current depth function
  28022. * @param depthFunc defines the function to use
  28023. */
  28024. setDepthFunction(depthFunc: number): void;
  28025. /**
  28026. * Sets the current depth function to GREATER
  28027. */
  28028. setDepthFunctionToGreater(): void;
  28029. /**
  28030. * Sets the current depth function to GEQUAL
  28031. */
  28032. setDepthFunctionToGreaterOrEqual(): void;
  28033. /**
  28034. * Sets the current depth function to LESS
  28035. */
  28036. setDepthFunctionToLess(): void;
  28037. /**
  28038. * Sets the current depth function to LEQUAL
  28039. */
  28040. setDepthFunctionToLessOrEqual(): void;
  28041. /**
  28042. * Gets a boolean indicating if stencil buffer is enabled
  28043. * @returns the current stencil buffer state
  28044. */
  28045. getStencilBuffer(): boolean;
  28046. /**
  28047. * Enable or disable the stencil buffer
  28048. * @param enable defines if the stencil buffer must be enabled or disabled
  28049. */
  28050. setStencilBuffer(enable: boolean): void;
  28051. /**
  28052. * Gets the current stencil mask
  28053. * @returns a number defining the new stencil mask to use
  28054. */
  28055. getStencilMask(): number;
  28056. /**
  28057. * Sets the current stencil mask
  28058. * @param mask defines the new stencil mask to use
  28059. */
  28060. setStencilMask(mask: number): void;
  28061. /**
  28062. * Gets the current stencil function
  28063. * @returns a number defining the stencil function to use
  28064. */
  28065. getStencilFunction(): number;
  28066. /**
  28067. * Gets the current stencil reference value
  28068. * @returns a number defining the stencil reference value to use
  28069. */
  28070. getStencilFunctionReference(): number;
  28071. /**
  28072. * Gets the current stencil mask
  28073. * @returns a number defining the stencil mask to use
  28074. */
  28075. getStencilFunctionMask(): number;
  28076. /**
  28077. * Sets the current stencil function
  28078. * @param stencilFunc defines the new stencil function to use
  28079. */
  28080. setStencilFunction(stencilFunc: number): void;
  28081. /**
  28082. * Sets the current stencil reference
  28083. * @param reference defines the new stencil reference to use
  28084. */
  28085. setStencilFunctionReference(reference: number): void;
  28086. /**
  28087. * Sets the current stencil mask
  28088. * @param mask defines the new stencil mask to use
  28089. */
  28090. setStencilFunctionMask(mask: number): void;
  28091. /**
  28092. * Gets the current stencil operation when stencil fails
  28093. * @returns a number defining stencil operation to use when stencil fails
  28094. */
  28095. getStencilOperationFail(): number;
  28096. /**
  28097. * Gets the current stencil operation when depth fails
  28098. * @returns a number defining stencil operation to use when depth fails
  28099. */
  28100. getStencilOperationDepthFail(): number;
  28101. /**
  28102. * Gets the current stencil operation when stencil passes
  28103. * @returns a number defining stencil operation to use when stencil passes
  28104. */
  28105. getStencilOperationPass(): number;
  28106. /**
  28107. * Sets the stencil operation to use when stencil fails
  28108. * @param operation defines the stencil operation to use when stencil fails
  28109. */
  28110. setStencilOperationFail(operation: number): void;
  28111. /**
  28112. * Sets the stencil operation to use when depth fails
  28113. * @param operation defines the stencil operation to use when depth fails
  28114. */
  28115. setStencilOperationDepthFail(operation: number): void;
  28116. /**
  28117. * Sets the stencil operation to use when stencil passes
  28118. * @param operation defines the stencil operation to use when stencil passes
  28119. */
  28120. setStencilOperationPass(operation: number): void;
  28121. /**
  28122. * Sets a boolean indicating if the dithering state is enabled or disabled
  28123. * @param value defines the dithering state
  28124. */
  28125. setDitheringState(value: boolean): void;
  28126. /**
  28127. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28128. * @param value defines the rasterizer state
  28129. */
  28130. setRasterizerState(value: boolean): void;
  28131. /**
  28132. * stop executing a render loop function and remove it from the execution array
  28133. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28134. */
  28135. stopRenderLoop(renderFunction?: () => void): void;
  28136. /** @hidden */
  28137. _renderLoop(): void;
  28138. /**
  28139. * Register and execute a render loop. The engine can have more than one render function
  28140. * @param renderFunction defines the function to continuously execute
  28141. */
  28142. runRenderLoop(renderFunction: () => void): void;
  28143. /**
  28144. * Toggle full screen mode
  28145. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28146. */
  28147. switchFullscreen(requestPointerLock: boolean): void;
  28148. /**
  28149. * Enters full screen mode
  28150. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28151. */
  28152. enterFullscreen(requestPointerLock: boolean): void;
  28153. /**
  28154. * Exits full screen mode
  28155. */
  28156. exitFullscreen(): void;
  28157. /**
  28158. * Clear the current render buffer or the current render target (if any is set up)
  28159. * @param color defines the color to use
  28160. * @param backBuffer defines if the back buffer must be cleared
  28161. * @param depth defines if the depth buffer must be cleared
  28162. * @param stencil defines if the stencil buffer must be cleared
  28163. */
  28164. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28165. /**
  28166. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28167. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28168. * @param y defines the y-coordinate of the corner of the clear rectangle
  28169. * @param width defines the width of the clear rectangle
  28170. * @param height defines the height of the clear rectangle
  28171. * @param clearColor defines the clear color
  28172. */
  28173. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28174. /**
  28175. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28176. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28177. * @param y defines the y-coordinate of the corner of the clear rectangle
  28178. * @param width defines the width of the clear rectangle
  28179. * @param height defines the height of the clear rectangle
  28180. */
  28181. enableScissor(x: number, y: number, width: number, height: number): void;
  28182. /**
  28183. * Disable previously set scissor test rectangle
  28184. */
  28185. disableScissor(): void;
  28186. private _viewportCached;
  28187. /** @hidden */
  28188. _viewport(x: number, y: number, width: number, height: number): void;
  28189. /**
  28190. * Set the WebGL's viewport
  28191. * @param viewport defines the viewport element to be used
  28192. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28193. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28194. */
  28195. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28196. /**
  28197. * Directly set the WebGL Viewport
  28198. * @param x defines the x coordinate of the viewport (in screen space)
  28199. * @param y defines the y coordinate of the viewport (in screen space)
  28200. * @param width defines the width of the viewport (in screen space)
  28201. * @param height defines the height of the viewport (in screen space)
  28202. * @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
  28203. */
  28204. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28205. /**
  28206. * Begin a new frame
  28207. */
  28208. beginFrame(): void;
  28209. /**
  28210. * Enf the current frame
  28211. */
  28212. endFrame(): void;
  28213. /**
  28214. * Resize the view according to the canvas' size
  28215. */
  28216. resize(): void;
  28217. /**
  28218. * Force a specific size of the canvas
  28219. * @param width defines the new canvas' width
  28220. * @param height defines the new canvas' height
  28221. */
  28222. setSize(width: number, height: number): void;
  28223. /**
  28224. * Gets a boolean indicating if a webVR device was detected
  28225. * @returns true if a webVR device was detected
  28226. */
  28227. isVRDevicePresent(): boolean;
  28228. /**
  28229. * Gets the current webVR device
  28230. * @returns the current webVR device (or null)
  28231. */
  28232. getVRDevice(): any;
  28233. /**
  28234. * Initializes a webVR display and starts listening to display change events
  28235. * The onVRDisplayChangedObservable will be notified upon these changes
  28236. * @returns The onVRDisplayChangedObservable
  28237. */
  28238. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28239. /**
  28240. * Initializes a webVR display and starts listening to display change events
  28241. * The onVRDisplayChangedObservable will be notified upon these changes
  28242. * @returns A promise containing a VRDisplay and if vr is supported
  28243. */
  28244. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28245. /**
  28246. * Call this function to switch to webVR mode
  28247. * Will do nothing if webVR is not supported or if there is no webVR device
  28248. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28249. */
  28250. enableVR(): void;
  28251. /**
  28252. * Call this function to leave webVR mode
  28253. * Will do nothing if webVR is not supported or if there is no webVR device
  28254. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28255. */
  28256. disableVR(): void;
  28257. private _onVRFullScreenTriggered;
  28258. private _getVRDisplaysAsync;
  28259. /**
  28260. * Binds the frame buffer to the specified texture.
  28261. * @param texture The texture to render to or null for the default canvas
  28262. * @param faceIndex The face of the texture to render to in case of cube texture
  28263. * @param requiredWidth The width of the target to render to
  28264. * @param requiredHeight The height of the target to render to
  28265. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28266. * @param depthStencilTexture The depth stencil texture to use to render
  28267. * @param lodLevel defines le lod level to bind to the frame buffer
  28268. */
  28269. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28270. private bindUnboundFramebuffer;
  28271. /**
  28272. * Unbind the current render target texture from the webGL context
  28273. * @param texture defines the render target texture to unbind
  28274. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28275. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28276. */
  28277. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28278. /**
  28279. * Unbind a list of render target textures from the webGL context
  28280. * This is used only when drawBuffer extension or webGL2 are active
  28281. * @param textures defines the render target textures to unbind
  28282. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28283. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28284. */
  28285. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28286. /**
  28287. * Force the mipmap generation for the given render target texture
  28288. * @param texture defines the render target texture to use
  28289. */
  28290. generateMipMapsForCubemap(texture: InternalTexture): void;
  28291. /**
  28292. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28293. */
  28294. flushFramebuffer(): void;
  28295. /**
  28296. * Unbind the current render target and bind the default framebuffer
  28297. */
  28298. restoreDefaultFramebuffer(): void;
  28299. /**
  28300. * Create an uniform buffer
  28301. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28302. * @param elements defines the content of the uniform buffer
  28303. * @returns the webGL uniform buffer
  28304. */
  28305. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  28306. /**
  28307. * Create a dynamic uniform buffer
  28308. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28309. * @param elements defines the content of the uniform buffer
  28310. * @returns the webGL uniform buffer
  28311. */
  28312. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  28313. /**
  28314. * Update an existing uniform buffer
  28315. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28316. * @param uniformBuffer defines the target uniform buffer
  28317. * @param elements defines the content to update
  28318. * @param offset defines the offset in the uniform buffer where update should start
  28319. * @param count defines the size of the data to update
  28320. */
  28321. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28322. private _resetVertexBufferBinding;
  28323. /**
  28324. * Creates a vertex buffer
  28325. * @param data the data for the vertex buffer
  28326. * @returns the new WebGL static buffer
  28327. */
  28328. createVertexBuffer(data: DataArray): WebGLBuffer;
  28329. /**
  28330. * Creates a dynamic vertex buffer
  28331. * @param data the data for the dynamic vertex buffer
  28332. * @returns the new WebGL dynamic buffer
  28333. */
  28334. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  28335. /**
  28336. * Update a dynamic index buffer
  28337. * @param indexBuffer defines the target index buffer
  28338. * @param indices defines the data to update
  28339. * @param offset defines the offset in the target index buffer where update should start
  28340. */
  28341. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  28342. /**
  28343. * Updates a dynamic vertex buffer.
  28344. * @param vertexBuffer the vertex buffer to update
  28345. * @param data the data used to update the vertex buffer
  28346. * @param byteOffset the byte offset of the data
  28347. * @param byteLength the byte length of the data
  28348. */
  28349. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28350. private _resetIndexBufferBinding;
  28351. /**
  28352. * Creates a new index buffer
  28353. * @param indices defines the content of the index buffer
  28354. * @param updatable defines if the index buffer must be updatable
  28355. * @returns a new webGL buffer
  28356. */
  28357. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  28358. /**
  28359. * Bind a webGL buffer to the webGL context
  28360. * @param buffer defines the buffer to bind
  28361. */
  28362. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  28363. /**
  28364. * Bind an uniform buffer to the current webGL context
  28365. * @param buffer defines the buffer to bind
  28366. */
  28367. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28368. /**
  28369. * Bind a buffer to the current webGL context at a given location
  28370. * @param buffer defines the buffer to bind
  28371. * @param location defines the index where to bind the buffer
  28372. */
  28373. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28374. /**
  28375. * Bind a specific block at a given index in a specific shader program
  28376. * @param shaderProgram defines the shader program
  28377. * @param blockName defines the block name
  28378. * @param index defines the index where to bind the block
  28379. */
  28380. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28381. private bindIndexBuffer;
  28382. private bindBuffer;
  28383. /**
  28384. * update the bound buffer with the given data
  28385. * @param data defines the data to update
  28386. */
  28387. updateArrayBuffer(data: Float32Array): void;
  28388. private _vertexAttribPointer;
  28389. private _bindIndexBufferWithCache;
  28390. private _bindVertexBuffersAttributes;
  28391. /**
  28392. * Records a vertex array object
  28393. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28394. * @param vertexBuffers defines the list of vertex buffers to store
  28395. * @param indexBuffer defines the index buffer to store
  28396. * @param effect defines the effect to store
  28397. * @returns the new vertex array object
  28398. */
  28399. recordVertexArrayObject(vertexBuffers: {
  28400. [key: string]: VertexBuffer;
  28401. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28402. /**
  28403. * Bind a specific vertex array object
  28404. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28405. * @param vertexArrayObject defines the vertex array object to bind
  28406. * @param indexBuffer defines the index buffer to bind
  28407. */
  28408. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28409. /**
  28410. * Bind webGl buffers directly to the webGL context
  28411. * @param vertexBuffer defines the vertex buffer to bind
  28412. * @param indexBuffer defines the index buffer to bind
  28413. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28414. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28415. * @param effect defines the effect associated with the vertex buffer
  28416. */
  28417. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28418. private _unbindVertexArrayObject;
  28419. /**
  28420. * Bind a list of vertex buffers to the webGL context
  28421. * @param vertexBuffers defines the list of vertex buffers to bind
  28422. * @param indexBuffer defines the index buffer to bind
  28423. * @param effect defines the effect associated with the vertex buffers
  28424. */
  28425. bindBuffers(vertexBuffers: {
  28426. [key: string]: Nullable<VertexBuffer>;
  28427. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28428. /**
  28429. * Unbind all instance attributes
  28430. */
  28431. unbindInstanceAttributes(): void;
  28432. /**
  28433. * Release and free the memory of a vertex array object
  28434. * @param vao defines the vertex array object to delete
  28435. */
  28436. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28437. /** @hidden */
  28438. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28439. /**
  28440. * Creates a webGL buffer to use with instanciation
  28441. * @param capacity defines the size of the buffer
  28442. * @returns the webGL buffer
  28443. */
  28444. createInstancesBuffer(capacity: number): WebGLBuffer;
  28445. /**
  28446. * Delete a webGL buffer used with instanciation
  28447. * @param buffer defines the webGL buffer to delete
  28448. */
  28449. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28450. /**
  28451. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28452. * @param instancesBuffer defines the webGL buffer to update and bind
  28453. * @param data defines the data to store in the buffer
  28454. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28455. */
  28456. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28457. /**
  28458. * Apply all cached states (depth, culling, stencil and alpha)
  28459. */
  28460. applyStates(): void;
  28461. /**
  28462. * Send a draw order
  28463. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28464. * @param indexStart defines the starting index
  28465. * @param indexCount defines the number of index to draw
  28466. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28467. */
  28468. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28469. /**
  28470. * Draw a list of points
  28471. * @param verticesStart defines the index of first vertex to draw
  28472. * @param verticesCount defines the count of vertices to draw
  28473. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28474. */
  28475. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28476. /**
  28477. * Draw a list of unindexed primitives
  28478. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28479. * @param verticesStart defines the index of first vertex to draw
  28480. * @param verticesCount defines the count of vertices to draw
  28481. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28482. */
  28483. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28484. /**
  28485. * Draw a list of indexed primitives
  28486. * @param fillMode defines the primitive to use
  28487. * @param indexStart defines the starting index
  28488. * @param indexCount defines the number of index to draw
  28489. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28490. */
  28491. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28492. /**
  28493. * Draw a list of unindexed primitives
  28494. * @param fillMode defines the primitive to use
  28495. * @param verticesStart defines the index of first vertex to draw
  28496. * @param verticesCount defines the count of vertices to draw
  28497. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28498. */
  28499. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28500. private _drawMode;
  28501. /** @hidden */
  28502. _releaseEffect(effect: Effect): void;
  28503. /** @hidden */
  28504. _deleteProgram(program: WebGLProgram): void;
  28505. /**
  28506. * Create a new effect (used to store vertex/fragment shaders)
  28507. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28508. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28509. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28510. * @param samplers defines an array of string used to represent textures
  28511. * @param defines defines the string containing the defines to use to compile the shaders
  28512. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28513. * @param onCompiled defines a function to call when the effect creation is successful
  28514. * @param onError defines a function to call when the effect creation has failed
  28515. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28516. * @returns the new Effect
  28517. */
  28518. 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;
  28519. private _compileShader;
  28520. private _compileRawShader;
  28521. /**
  28522. * Directly creates a webGL program
  28523. * @param vertexCode defines the vertex shader code to use
  28524. * @param fragmentCode defines the fragment shader code to use
  28525. * @param context defines the webGL context to use (if not set, the current one will be used)
  28526. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28527. * @returns the new webGL program
  28528. */
  28529. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28530. /**
  28531. * Creates a webGL program
  28532. * @param vertexCode defines the vertex shader code to use
  28533. * @param fragmentCode defines the fragment shader code to use
  28534. * @param defines defines the string containing the defines to use to compile the shaders
  28535. * @param context defines the webGL context to use (if not set, the current one will be used)
  28536. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28537. * @returns the new webGL program
  28538. */
  28539. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28540. private _createShaderProgram;
  28541. private _finalizeProgram;
  28542. /** @hidden */
  28543. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28544. /** @hidden */
  28545. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28546. /**
  28547. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28548. * @param shaderProgram defines the webGL program to use
  28549. * @param uniformsNames defines the list of uniform names
  28550. * @returns an array of webGL uniform locations
  28551. */
  28552. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28553. /**
  28554. * Gets the lsit of active attributes for a given webGL program
  28555. * @param shaderProgram defines the webGL program to use
  28556. * @param attributesNames defines the list of attribute names to get
  28557. * @returns an array of indices indicating the offset of each attribute
  28558. */
  28559. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28560. /**
  28561. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28562. * @param effect defines the effect to activate
  28563. */
  28564. enableEffect(effect: Nullable<Effect>): void;
  28565. /**
  28566. * Set the value of an uniform to an array of int32
  28567. * @param uniform defines the webGL uniform location where to store the value
  28568. * @param array defines the array of int32 to store
  28569. */
  28570. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28571. /**
  28572. * Set the value of an uniform to an array of int32 (stored as vec2)
  28573. * @param uniform defines the webGL uniform location where to store the value
  28574. * @param array defines the array of int32 to store
  28575. */
  28576. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28577. /**
  28578. * Set the value of an uniform to an array of int32 (stored as vec3)
  28579. * @param uniform defines the webGL uniform location where to store the value
  28580. * @param array defines the array of int32 to store
  28581. */
  28582. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28583. /**
  28584. * Set the value of an uniform to an array of int32 (stored as vec4)
  28585. * @param uniform defines the webGL uniform location where to store the value
  28586. * @param array defines the array of int32 to store
  28587. */
  28588. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28589. /**
  28590. * Set the value of an uniform to an array of float32
  28591. * @param uniform defines the webGL uniform location where to store the value
  28592. * @param array defines the array of float32 to store
  28593. */
  28594. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28595. /**
  28596. * Set the value of an uniform to an array of float32 (stored as vec2)
  28597. * @param uniform defines the webGL uniform location where to store the value
  28598. * @param array defines the array of float32 to store
  28599. */
  28600. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28601. /**
  28602. * Set the value of an uniform to an array of float32 (stored as vec3)
  28603. * @param uniform defines the webGL uniform location where to store the value
  28604. * @param array defines the array of float32 to store
  28605. */
  28606. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28607. /**
  28608. * Set the value of an uniform to an array of float32 (stored as vec4)
  28609. * @param uniform defines the webGL uniform location where to store the value
  28610. * @param array defines the array of float32 to store
  28611. */
  28612. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28613. /**
  28614. * Set the value of an uniform to an array of number
  28615. * @param uniform defines the webGL uniform location where to store the value
  28616. * @param array defines the array of number to store
  28617. */
  28618. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28619. /**
  28620. * Set the value of an uniform to an array of number (stored as vec2)
  28621. * @param uniform defines the webGL uniform location where to store the value
  28622. * @param array defines the array of number to store
  28623. */
  28624. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28625. /**
  28626. * Set the value of an uniform to an array of number (stored as vec3)
  28627. * @param uniform defines the webGL uniform location where to store the value
  28628. * @param array defines the array of number to store
  28629. */
  28630. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28631. /**
  28632. * Set the value of an uniform to an array of number (stored as vec4)
  28633. * @param uniform defines the webGL uniform location where to store the value
  28634. * @param array defines the array of number to store
  28635. */
  28636. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28637. /**
  28638. * Set the value of an uniform to an array of float32 (stored as matrices)
  28639. * @param uniform defines the webGL uniform location where to store the value
  28640. * @param matrices defines the array of float32 to store
  28641. */
  28642. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28643. /**
  28644. * Set the value of an uniform to a matrix
  28645. * @param uniform defines the webGL uniform location where to store the value
  28646. * @param matrix defines the matrix to store
  28647. */
  28648. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28649. /**
  28650. * Set the value of an uniform to a matrix (3x3)
  28651. * @param uniform defines the webGL uniform location where to store the value
  28652. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28653. */
  28654. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28655. /**
  28656. * Set the value of an uniform to a matrix (2x2)
  28657. * @param uniform defines the webGL uniform location where to store the value
  28658. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28659. */
  28660. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28661. /**
  28662. * Set the value of an uniform to a number (int)
  28663. * @param uniform defines the webGL uniform location where to store the value
  28664. * @param value defines the int number to store
  28665. */
  28666. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28667. /**
  28668. * Set the value of an uniform to a number (float)
  28669. * @param uniform defines the webGL uniform location where to store the value
  28670. * @param value defines the float number to store
  28671. */
  28672. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28673. /**
  28674. * Set the value of an uniform to a vec2
  28675. * @param uniform defines the webGL uniform location where to store the value
  28676. * @param x defines the 1st component of the value
  28677. * @param y defines the 2nd component of the value
  28678. */
  28679. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28680. /**
  28681. * Set the value of an uniform to a vec3
  28682. * @param uniform defines the webGL uniform location where to store the value
  28683. * @param x defines the 1st component of the value
  28684. * @param y defines the 2nd component of the value
  28685. * @param z defines the 3rd component of the value
  28686. */
  28687. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28688. /**
  28689. * Set the value of an uniform to a boolean
  28690. * @param uniform defines the webGL uniform location where to store the value
  28691. * @param bool defines the boolean to store
  28692. */
  28693. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28694. /**
  28695. * Set the value of an uniform to a vec4
  28696. * @param uniform defines the webGL uniform location where to store the value
  28697. * @param x defines the 1st component of the value
  28698. * @param y defines the 2nd component of the value
  28699. * @param z defines the 3rd component of the value
  28700. * @param w defines the 4th component of the value
  28701. */
  28702. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28703. /**
  28704. * Set the value of an uniform to a Color3
  28705. * @param uniform defines the webGL uniform location where to store the value
  28706. * @param color3 defines the color to store
  28707. */
  28708. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28709. /**
  28710. * Set the value of an uniform to a Color3 and an alpha value
  28711. * @param uniform defines the webGL uniform location where to store the value
  28712. * @param color3 defines the color to store
  28713. * @param alpha defines the alpha component to store
  28714. */
  28715. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28716. /**
  28717. * Sets a Color4 on a uniform variable
  28718. * @param uniform defines the uniform location
  28719. * @param color4 defines the value to be set
  28720. */
  28721. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28722. /**
  28723. * Set various states to the webGL context
  28724. * @param culling defines backface culling state
  28725. * @param zOffset defines the value to apply to zOffset (0 by default)
  28726. * @param force defines if states must be applied even if cache is up to date
  28727. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28728. */
  28729. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28730. /**
  28731. * Set the z offset to apply to current rendering
  28732. * @param value defines the offset to apply
  28733. */
  28734. setZOffset(value: number): void;
  28735. /**
  28736. * Gets the current value of the zOffset
  28737. * @returns the current zOffset state
  28738. */
  28739. getZOffset(): number;
  28740. /**
  28741. * Enable or disable depth buffering
  28742. * @param enable defines the state to set
  28743. */
  28744. setDepthBuffer(enable: boolean): void;
  28745. /**
  28746. * Gets a boolean indicating if depth writing is enabled
  28747. * @returns the current depth writing state
  28748. */
  28749. getDepthWrite(): boolean;
  28750. /**
  28751. * Enable or disable depth writing
  28752. * @param enable defines the state to set
  28753. */
  28754. setDepthWrite(enable: boolean): void;
  28755. /**
  28756. * Enable or disable color writing
  28757. * @param enable defines the state to set
  28758. */
  28759. setColorWrite(enable: boolean): void;
  28760. /**
  28761. * Gets a boolean indicating if color writing is enabled
  28762. * @returns the current color writing state
  28763. */
  28764. getColorWrite(): boolean;
  28765. /**
  28766. * Sets alpha constants used by some alpha blending modes
  28767. * @param r defines the red component
  28768. * @param g defines the green component
  28769. * @param b defines the blue component
  28770. * @param a defines the alpha component
  28771. */
  28772. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28773. /**
  28774. * Sets the current alpha mode
  28775. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28776. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28777. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28778. */
  28779. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28780. /**
  28781. * Gets the current alpha mode
  28782. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28783. * @returns the current alpha mode
  28784. */
  28785. getAlphaMode(): number;
  28786. /**
  28787. * Clears the list of texture accessible through engine.
  28788. * This can help preventing texture load conflict due to name collision.
  28789. */
  28790. clearInternalTexturesCache(): void;
  28791. /**
  28792. * Force the entire cache to be cleared
  28793. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28794. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28795. */
  28796. wipeCaches(bruteForce?: boolean): void;
  28797. /**
  28798. * Set the compressed texture format to use, based on the formats you have, and the formats
  28799. * supported by the hardware / browser.
  28800. *
  28801. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28802. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28803. * to API arguments needed to compressed textures. This puts the burden on the container
  28804. * generator to house the arcane code for determining these for current & future formats.
  28805. *
  28806. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28807. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28808. *
  28809. * Note: The result of this call is not taken into account when a texture is base64.
  28810. *
  28811. * @param formatsAvailable defines the list of those format families you have created
  28812. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28813. *
  28814. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28815. * @returns The extension selected.
  28816. */
  28817. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28818. private _getSamplingParameters;
  28819. private _partialLoadImg;
  28820. private _cascadeLoadImgs;
  28821. /** @hidden */
  28822. _createTexture(): WebGLTexture;
  28823. /**
  28824. * Usually called from Texture.ts.
  28825. * Passed information to create a WebGLTexture
  28826. * @param urlArg defines a value which contains one of the following:
  28827. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28828. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28829. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28830. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28831. * @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)
  28832. * @param scene needed for loading to the correct scene
  28833. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28834. * @param onLoad optional callback to be called upon successful completion
  28835. * @param onError optional callback to be called upon failure
  28836. * @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
  28837. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28838. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28839. * @param forcedExtension defines the extension to use to pick the right loader
  28840. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28841. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28842. */
  28843. 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;
  28844. private _rescaleTexture;
  28845. /**
  28846. * Update a raw texture
  28847. * @param texture defines the texture to update
  28848. * @param data defines the data to store in the texture
  28849. * @param format defines the format of the data
  28850. * @param invertY defines if data must be stored with Y axis inverted
  28851. * @param compression defines the compression used (null by default)
  28852. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28853. */
  28854. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28855. /**
  28856. * Creates a raw texture
  28857. * @param data defines the data to store in the texture
  28858. * @param width defines the width of the texture
  28859. * @param height defines the height of the texture
  28860. * @param format defines the format of the data
  28861. * @param generateMipMaps defines if the engine should generate the mip levels
  28862. * @param invertY defines if data must be stored with Y axis inverted
  28863. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28864. * @param compression defines the compression used (null by default)
  28865. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28866. * @returns the raw texture inside an InternalTexture
  28867. */
  28868. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28869. private _unpackFlipYCached;
  28870. /**
  28871. * In case you are sharing the context with other applications, it might
  28872. * be interested to not cache the unpack flip y state to ensure a consistent
  28873. * value would be set.
  28874. */
  28875. enableUnpackFlipYCached: boolean;
  28876. /** @hidden */
  28877. _unpackFlipY(value: boolean): void;
  28878. /** @hidden */
  28879. _getUnpackAlignement(): number;
  28880. /**
  28881. * Creates a dynamic texture
  28882. * @param width defines the width of the texture
  28883. * @param height defines the height of the texture
  28884. * @param generateMipMaps defines if the engine should generate the mip levels
  28885. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28886. * @returns the dynamic texture inside an InternalTexture
  28887. */
  28888. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28889. /**
  28890. * Update the sampling mode of a given texture
  28891. * @param samplingMode defines the required sampling mode
  28892. * @param texture defines the texture to update
  28893. */
  28894. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28895. /**
  28896. * Update the content of a dynamic texture
  28897. * @param texture defines the texture to update
  28898. * @param canvas defines the canvas containing the source
  28899. * @param invertY defines if data must be stored with Y axis inverted
  28900. * @param premulAlpha defines if alpha is stored as premultiplied
  28901. * @param format defines the format of the data
  28902. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28903. */
  28904. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28905. /**
  28906. * Update a video texture
  28907. * @param texture defines the texture to update
  28908. * @param video defines the video element to use
  28909. * @param invertY defines if data must be stored with Y axis inverted
  28910. */
  28911. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28912. /**
  28913. * Updates a depth texture Comparison Mode and Function.
  28914. * If the comparison Function is equal to 0, the mode will be set to none.
  28915. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28916. * @param texture The texture to set the comparison function for
  28917. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28918. */
  28919. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28920. private _setupDepthStencilTexture;
  28921. /**
  28922. * Creates a depth stencil texture.
  28923. * This is only available in WebGL 2 or with the depth texture extension available.
  28924. * @param size The size of face edge in the texture.
  28925. * @param options The options defining the texture.
  28926. * @returns The texture
  28927. */
  28928. createDepthStencilTexture(size: number | {
  28929. width: number;
  28930. height: number;
  28931. }, options: DepthTextureCreationOptions): InternalTexture;
  28932. /**
  28933. * Creates a depth stencil texture.
  28934. * This is only available in WebGL 2 or with the depth texture extension available.
  28935. * @param size The size of face edge in the texture.
  28936. * @param options The options defining the texture.
  28937. * @returns The texture
  28938. */
  28939. private _createDepthStencilTexture;
  28940. /**
  28941. * Creates a depth stencil cube texture.
  28942. * This is only available in WebGL 2.
  28943. * @param size The size of face edge in the cube texture.
  28944. * @param options The options defining the cube texture.
  28945. * @returns The cube texture
  28946. */
  28947. private _createDepthStencilCubeTexture;
  28948. /**
  28949. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28950. * @param renderTarget The render target to set the frame buffer for
  28951. */
  28952. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28953. /**
  28954. * Creates a new render target texture
  28955. * @param size defines the size of the texture
  28956. * @param options defines the options used to create the texture
  28957. * @returns a new render target texture stored in an InternalTexture
  28958. */
  28959. createRenderTargetTexture(size: number | {
  28960. width: number;
  28961. height: number;
  28962. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28963. /**
  28964. * Create a multi render target texture
  28965. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28966. * @param size defines the size of the texture
  28967. * @param options defines the creation options
  28968. * @returns the cube texture as an InternalTexture
  28969. */
  28970. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28971. private _setupFramebufferDepthAttachments;
  28972. /**
  28973. * Updates the sample count of a render target texture
  28974. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28975. * @param texture defines the texture to update
  28976. * @param samples defines the sample count to set
  28977. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28978. */
  28979. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28980. /**
  28981. * Update the sample count for a given multiple render target texture
  28982. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28983. * @param textures defines the textures to update
  28984. * @param samples defines the sample count to set
  28985. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28986. */
  28987. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28988. /** @hidden */
  28989. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28990. /** @hidden */
  28991. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28992. /** @hidden */
  28993. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28994. /** @hidden */
  28995. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28996. /**
  28997. * Creates a new render target cube texture
  28998. * @param size defines the size of the texture
  28999. * @param options defines the options used to create the texture
  29000. * @returns a new render target cube texture stored in an InternalTexture
  29001. */
  29002. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  29003. /**
  29004. * Creates a cube texture
  29005. * @param rootUrl defines the url where the files to load is located
  29006. * @param scene defines the current scene
  29007. * @param files defines the list of files to load (1 per face)
  29008. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  29009. * @param onLoad defines an optional callback raised when the texture is loaded
  29010. * @param onError defines an optional callback raised if there is an issue to load the texture
  29011. * @param format defines the format of the data
  29012. * @param forcedExtension defines the extension to use to pick the right loader
  29013. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  29014. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  29015. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  29016. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  29017. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  29018. * @returns the cube texture as an InternalTexture
  29019. */
  29020. 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;
  29021. /**
  29022. * @hidden
  29023. */
  29024. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29025. /**
  29026. * Update a raw cube texture
  29027. * @param texture defines the texture to udpdate
  29028. * @param data defines the data to store
  29029. * @param format defines the data format
  29030. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29031. * @param invertY defines if data must be stored with Y axis inverted
  29032. * @param compression defines the compression used (null by default)
  29033. * @param level defines which level of the texture to update
  29034. */
  29035. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  29036. /**
  29037. * Creates a new raw cube texture
  29038. * @param data defines the array of data to use to create each face
  29039. * @param size defines the size of the textures
  29040. * @param format defines the format of the data
  29041. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29042. * @param generateMipMaps defines if the engine should generate the mip levels
  29043. * @param invertY defines if data must be stored with Y axis inverted
  29044. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29045. * @param compression defines the compression used (null by default)
  29046. * @returns the cube texture as an InternalTexture
  29047. */
  29048. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29049. /**
  29050. * Creates a new raw cube texture from a specified url
  29051. * @param url defines the url where the data is located
  29052. * @param scene defines the current scene
  29053. * @param size defines the size of the textures
  29054. * @param format defines the format of the data
  29055. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29056. * @param noMipmap defines if the engine should avoid generating the mip levels
  29057. * @param callback defines a callback used to extract texture data from loaded data
  29058. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  29059. * @param onLoad defines a callback called when texture is loaded
  29060. * @param onError defines a callback called if there is an error
  29061. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29062. * @param invertY defines if data must be stored with Y axis inverted
  29063. * @returns the cube texture as an InternalTexture
  29064. */
  29065. 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;
  29066. /**
  29067. * Update a raw 3D texture
  29068. * @param texture defines the texture to update
  29069. * @param data defines the data to store
  29070. * @param format defines the data format
  29071. * @param invertY defines if data must be stored with Y axis inverted
  29072. * @param compression defines the used compression (can be null)
  29073. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  29074. */
  29075. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  29076. /**
  29077. * Creates a new raw 3D texture
  29078. * @param data defines the data used to create the texture
  29079. * @param width defines the width of the texture
  29080. * @param height defines the height of the texture
  29081. * @param depth defines the depth of the texture
  29082. * @param format defines the format of the texture
  29083. * @param generateMipMaps defines if the engine must generate mip levels
  29084. * @param invertY defines if data must be stored with Y axis inverted
  29085. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29086. * @param compression defines the compressed used (can be null)
  29087. * @param textureType defines the compressed used (can be null)
  29088. * @returns a new raw 3D texture (stored in an InternalTexture)
  29089. */
  29090. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29091. private _prepareWebGLTextureContinuation;
  29092. private _prepareWebGLTexture;
  29093. private _convertRGBtoRGBATextureData;
  29094. /** @hidden */
  29095. _releaseFramebufferObjects(texture: InternalTexture): void;
  29096. /** @hidden */
  29097. _releaseTexture(texture: InternalTexture): void;
  29098. private setProgram;
  29099. private _boundUniforms;
  29100. /**
  29101. * Binds an effect to the webGL context
  29102. * @param effect defines the effect to bind
  29103. */
  29104. bindSamplers(effect: Effect): void;
  29105. private _moveBoundTextureOnTop;
  29106. private _getCorrectTextureChannel;
  29107. private _linkTrackers;
  29108. private _removeDesignatedSlot;
  29109. private _activateCurrentTexture;
  29110. /** @hidden */
  29111. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29112. /** @hidden */
  29113. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29114. /**
  29115. * Sets a texture to the webGL context from a postprocess
  29116. * @param channel defines the channel to use
  29117. * @param postProcess defines the source postprocess
  29118. */
  29119. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29120. /**
  29121. * Binds the output of the passed in post process to the texture channel specified
  29122. * @param channel The channel the texture should be bound to
  29123. * @param postProcess The post process which's output should be bound
  29124. */
  29125. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29126. /**
  29127. * Unbind all textures from the webGL context
  29128. */
  29129. unbindAllTextures(): void;
  29130. /**
  29131. * Sets a texture to the according uniform.
  29132. * @param channel The texture channel
  29133. * @param uniform The uniform to set
  29134. * @param texture The texture to apply
  29135. */
  29136. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29137. /**
  29138. * Sets a depth stencil texture from a render target to the according uniform.
  29139. * @param channel The texture channel
  29140. * @param uniform The uniform to set
  29141. * @param texture The render target texture containing the depth stencil texture to apply
  29142. */
  29143. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29144. private _bindSamplerUniformToChannel;
  29145. private _getTextureWrapMode;
  29146. private _setTexture;
  29147. /**
  29148. * Sets an array of texture to the webGL context
  29149. * @param channel defines the channel where the texture array must be set
  29150. * @param uniform defines the associated uniform location
  29151. * @param textures defines the array of textures to bind
  29152. */
  29153. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29154. /** @hidden */
  29155. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29156. private _setTextureParameterFloat;
  29157. private _setTextureParameterInteger;
  29158. /**
  29159. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29160. * @param x defines the x coordinate of the rectangle where pixels must be read
  29161. * @param y defines the y coordinate of the rectangle where pixels must be read
  29162. * @param width defines the width of the rectangle where pixels must be read
  29163. * @param height defines the height of the rectangle where pixels must be read
  29164. * @returns a Uint8Array containing RGBA colors
  29165. */
  29166. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29167. /**
  29168. * Add an externaly attached data from its key.
  29169. * This method call will fail and return false, if such key already exists.
  29170. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29171. * @param key the unique key that identifies the data
  29172. * @param data the data object to associate to the key for this Engine instance
  29173. * @return true if no such key were already present and the data was added successfully, false otherwise
  29174. */
  29175. addExternalData<T>(key: string, data: T): boolean;
  29176. /**
  29177. * Get an externaly attached data from its key
  29178. * @param key the unique key that identifies the data
  29179. * @return the associated data, if present (can be null), or undefined if not present
  29180. */
  29181. getExternalData<T>(key: string): T;
  29182. /**
  29183. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29184. * @param key the unique key that identifies the data
  29185. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29186. * @return the associated data, can be null if the factory returned null.
  29187. */
  29188. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29189. /**
  29190. * Remove an externaly attached data from the Engine instance
  29191. * @param key the unique key that identifies the data
  29192. * @return true if the data was successfully removed, false if it doesn't exist
  29193. */
  29194. removeExternalData(key: string): boolean;
  29195. /**
  29196. * Unbind all vertex attributes from the webGL context
  29197. */
  29198. unbindAllAttributes(): void;
  29199. /**
  29200. * 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
  29201. */
  29202. releaseEffects(): void;
  29203. /**
  29204. * Dispose and release all associated resources
  29205. */
  29206. dispose(): void;
  29207. /**
  29208. * Display the loading screen
  29209. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29210. */
  29211. displayLoadingUI(): void;
  29212. /**
  29213. * Hide the loading screen
  29214. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29215. */
  29216. hideLoadingUI(): void;
  29217. /**
  29218. * Gets the current loading screen object
  29219. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29220. */
  29221. /**
  29222. * Sets the current loading screen object
  29223. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29224. */
  29225. loadingScreen: ILoadingScreen;
  29226. /**
  29227. * Sets the current loading screen text
  29228. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29229. */
  29230. loadingUIText: string;
  29231. /**
  29232. * Sets the current loading screen background color
  29233. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29234. */
  29235. loadingUIBackgroundColor: string;
  29236. /**
  29237. * Attach a new callback raised when context lost event is fired
  29238. * @param callback defines the callback to call
  29239. */
  29240. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29241. /**
  29242. * Attach a new callback raised when context restored event is fired
  29243. * @param callback defines the callback to call
  29244. */
  29245. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29246. /**
  29247. * Gets the source code of the vertex shader associated with a specific webGL program
  29248. * @param program defines the program to use
  29249. * @returns a string containing the source code of the vertex shader associated with the program
  29250. */
  29251. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29252. /**
  29253. * Gets the source code of the fragment shader associated with a specific webGL program
  29254. * @param program defines the program to use
  29255. * @returns a string containing the source code of the fragment shader associated with the program
  29256. */
  29257. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29258. /**
  29259. * Get the current error code of the webGL context
  29260. * @returns the error code
  29261. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29262. */
  29263. getError(): number;
  29264. /**
  29265. * Gets the current framerate
  29266. * @returns a number representing the framerate
  29267. */
  29268. getFps(): number;
  29269. /**
  29270. * Gets the time spent between current and previous frame
  29271. * @returns a number representing the delta time in ms
  29272. */
  29273. getDeltaTime(): number;
  29274. private _measureFps;
  29275. /** @hidden */
  29276. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29277. private _canRenderToFloatFramebuffer;
  29278. private _canRenderToHalfFloatFramebuffer;
  29279. private _canRenderToFramebuffer;
  29280. /** @hidden */
  29281. _getWebGLTextureType(type: number): number;
  29282. private _getInternalFormat;
  29283. /** @hidden */
  29284. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29285. /** @hidden */
  29286. _getRGBAMultiSampleBufferFormat(type: number): number;
  29287. /** @hidden */
  29288. _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;
  29289. /** @hidden */
  29290. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29291. private _partialLoadFile;
  29292. private _cascadeLoadFiles;
  29293. /**
  29294. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29295. * @returns true if the engine can be created
  29296. * @ignorenaming
  29297. */
  29298. static isSupported(): boolean;
  29299. }
  29300. }
  29301. declare module "babylonjs/Materials/effect" {
  29302. import { Observable } from "babylonjs/Misc/observable";
  29303. import { Nullable } from "babylonjs/types";
  29304. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29305. import { Engine } from "babylonjs/Engines/engine";
  29306. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29307. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29308. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29309. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29310. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29311. /**
  29312. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29313. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29314. */
  29315. export class EffectFallbacks {
  29316. private _defines;
  29317. private _currentRank;
  29318. private _maxRank;
  29319. private _mesh;
  29320. /**
  29321. * Removes the fallback from the bound mesh.
  29322. */
  29323. unBindMesh(): void;
  29324. /**
  29325. * Adds a fallback on the specified property.
  29326. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29327. * @param define The name of the define in the shader
  29328. */
  29329. addFallback(rank: number, define: string): void;
  29330. /**
  29331. * Sets the mesh to use CPU skinning when needing to fallback.
  29332. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29333. * @param mesh The mesh to use the fallbacks.
  29334. */
  29335. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29336. /**
  29337. * Checks to see if more fallbacks are still availible.
  29338. */
  29339. readonly isMoreFallbacks: boolean;
  29340. /**
  29341. * Removes the defines that shoould be removed when falling back.
  29342. * @param currentDefines defines the current define statements for the shader.
  29343. * @param effect defines the current effect we try to compile
  29344. * @returns The resulting defines with defines of the current rank removed.
  29345. */
  29346. reduce(currentDefines: string, effect: Effect): string;
  29347. }
  29348. /**
  29349. * Options to be used when creating an effect.
  29350. */
  29351. export class EffectCreationOptions {
  29352. /**
  29353. * Atrributes that will be used in the shader.
  29354. */
  29355. attributes: string[];
  29356. /**
  29357. * Uniform varible names that will be set in the shader.
  29358. */
  29359. uniformsNames: string[];
  29360. /**
  29361. * Uniform buffer varible names that will be set in the shader.
  29362. */
  29363. uniformBuffersNames: string[];
  29364. /**
  29365. * Sampler texture variable names that will be set in the shader.
  29366. */
  29367. samplers: string[];
  29368. /**
  29369. * Define statements that will be set in the shader.
  29370. */
  29371. defines: any;
  29372. /**
  29373. * Possible fallbacks for this effect to improve performance when needed.
  29374. */
  29375. fallbacks: Nullable<EffectFallbacks>;
  29376. /**
  29377. * Callback that will be called when the shader is compiled.
  29378. */
  29379. onCompiled: Nullable<(effect: Effect) => void>;
  29380. /**
  29381. * Callback that will be called if an error occurs during shader compilation.
  29382. */
  29383. onError: Nullable<(effect: Effect, errors: string) => void>;
  29384. /**
  29385. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29386. */
  29387. indexParameters: any;
  29388. /**
  29389. * Max number of lights that can be used in the shader.
  29390. */
  29391. maxSimultaneousLights: number;
  29392. /**
  29393. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29394. */
  29395. transformFeedbackVaryings: Nullable<string[]>;
  29396. }
  29397. /**
  29398. * Effect containing vertex and fragment shader that can be executed on an object.
  29399. */
  29400. export class Effect {
  29401. /**
  29402. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29403. */
  29404. static ShadersRepository: string;
  29405. /**
  29406. * Name of the effect.
  29407. */
  29408. name: any;
  29409. /**
  29410. * String container all the define statements that should be set on the shader.
  29411. */
  29412. defines: string;
  29413. /**
  29414. * Callback that will be called when the shader is compiled.
  29415. */
  29416. onCompiled: Nullable<(effect: Effect) => void>;
  29417. /**
  29418. * Callback that will be called if an error occurs during shader compilation.
  29419. */
  29420. onError: Nullable<(effect: Effect, errors: string) => void>;
  29421. /**
  29422. * Callback that will be called when effect is bound.
  29423. */
  29424. onBind: Nullable<(effect: Effect) => void>;
  29425. /**
  29426. * Unique ID of the effect.
  29427. */
  29428. uniqueId: number;
  29429. /**
  29430. * Observable that will be called when the shader is compiled.
  29431. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29432. */
  29433. onCompileObservable: Observable<Effect>;
  29434. /**
  29435. * Observable that will be called if an error occurs during shader compilation.
  29436. */
  29437. onErrorObservable: Observable<Effect>;
  29438. /** @hidden */
  29439. _onBindObservable: Nullable<Observable<Effect>>;
  29440. /**
  29441. * Observable that will be called when effect is bound.
  29442. */
  29443. readonly onBindObservable: Observable<Effect>;
  29444. /** @hidden */
  29445. _bonesComputationForcedToCPU: boolean;
  29446. private static _uniqueIdSeed;
  29447. private _engine;
  29448. private _uniformBuffersNames;
  29449. private _uniformsNames;
  29450. private _samplers;
  29451. private _isReady;
  29452. private _compilationError;
  29453. private _attributesNames;
  29454. private _attributes;
  29455. private _uniforms;
  29456. /**
  29457. * Key for the effect.
  29458. * @hidden
  29459. */
  29460. _key: string;
  29461. private _indexParameters;
  29462. private _fallbacks;
  29463. private _vertexSourceCode;
  29464. private _fragmentSourceCode;
  29465. private _vertexSourceCodeOverride;
  29466. private _fragmentSourceCodeOverride;
  29467. private _transformFeedbackVaryings;
  29468. /**
  29469. * Compiled shader to webGL program.
  29470. * @hidden
  29471. */
  29472. _program: WebGLProgram;
  29473. private _valueCache;
  29474. private static _baseCache;
  29475. /**
  29476. * Instantiates an effect.
  29477. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29478. * @param baseName Name of the effect.
  29479. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29480. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29481. * @param samplers List of sampler variables that will be passed to the shader.
  29482. * @param engine Engine to be used to render the effect
  29483. * @param defines Define statements to be added to the shader.
  29484. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29485. * @param onCompiled Callback that will be called when the shader is compiled.
  29486. * @param onError Callback that will be called if an error occurs during shader compilation.
  29487. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29488. */
  29489. 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);
  29490. /**
  29491. * Unique key for this effect
  29492. */
  29493. readonly key: string;
  29494. /**
  29495. * If the effect has been compiled and prepared.
  29496. * @returns if the effect is compiled and prepared.
  29497. */
  29498. isReady(): boolean;
  29499. /**
  29500. * The engine the effect was initialized with.
  29501. * @returns the engine.
  29502. */
  29503. getEngine(): Engine;
  29504. /**
  29505. * The compiled webGL program for the effect
  29506. * @returns the webGL program.
  29507. */
  29508. getProgram(): WebGLProgram;
  29509. /**
  29510. * The set of names of attribute variables for the shader.
  29511. * @returns An array of attribute names.
  29512. */
  29513. getAttributesNames(): string[];
  29514. /**
  29515. * Returns the attribute at the given index.
  29516. * @param index The index of the attribute.
  29517. * @returns The location of the attribute.
  29518. */
  29519. getAttributeLocation(index: number): number;
  29520. /**
  29521. * Returns the attribute based on the name of the variable.
  29522. * @param name of the attribute to look up.
  29523. * @returns the attribute location.
  29524. */
  29525. getAttributeLocationByName(name: string): number;
  29526. /**
  29527. * The number of attributes.
  29528. * @returns the numnber of attributes.
  29529. */
  29530. getAttributesCount(): number;
  29531. /**
  29532. * Gets the index of a uniform variable.
  29533. * @param uniformName of the uniform to look up.
  29534. * @returns the index.
  29535. */
  29536. getUniformIndex(uniformName: string): number;
  29537. /**
  29538. * Returns the attribute based on the name of the variable.
  29539. * @param uniformName of the uniform to look up.
  29540. * @returns the location of the uniform.
  29541. */
  29542. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29543. /**
  29544. * Returns an array of sampler variable names
  29545. * @returns The array of sampler variable neames.
  29546. */
  29547. getSamplers(): string[];
  29548. /**
  29549. * The error from the last compilation.
  29550. * @returns the error string.
  29551. */
  29552. getCompilationError(): string;
  29553. /**
  29554. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29555. * @param func The callback to be used.
  29556. */
  29557. executeWhenCompiled(func: (effect: Effect) => void): void;
  29558. private _checkIsReady;
  29559. /** @hidden */
  29560. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29561. /** @hidden */
  29562. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29563. /** @hidden */
  29564. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29565. private _processShaderConversion;
  29566. private _processIncludes;
  29567. private _processPrecision;
  29568. /**
  29569. * Recompiles the webGL program
  29570. * @param vertexSourceCode The source code for the vertex shader.
  29571. * @param fragmentSourceCode The source code for the fragment shader.
  29572. * @param onCompiled Callback called when completed.
  29573. * @param onError Callback called on error.
  29574. * @hidden
  29575. */
  29576. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29577. /**
  29578. * Gets the uniform locations of the the specified variable names
  29579. * @param names THe names of the variables to lookup.
  29580. * @returns Array of locations in the same order as variable names.
  29581. */
  29582. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29583. /**
  29584. * Prepares the effect
  29585. * @hidden
  29586. */
  29587. _prepareEffect(): void;
  29588. /**
  29589. * Checks if the effect is supported. (Must be called after compilation)
  29590. */
  29591. readonly isSupported: boolean;
  29592. /**
  29593. * Binds a texture to the engine to be used as output of the shader.
  29594. * @param channel Name of the output variable.
  29595. * @param texture Texture to bind.
  29596. * @hidden
  29597. */
  29598. _bindTexture(channel: string, texture: InternalTexture): void;
  29599. /**
  29600. * Sets a texture on the engine to be used in the shader.
  29601. * @param channel Name of the sampler variable.
  29602. * @param texture Texture to set.
  29603. */
  29604. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29605. /**
  29606. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29607. * @param channel Name of the sampler variable.
  29608. * @param texture Texture to set.
  29609. */
  29610. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29611. /**
  29612. * Sets an array of textures on the engine to be used in the shader.
  29613. * @param channel Name of the variable.
  29614. * @param textures Textures to set.
  29615. */
  29616. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29617. /**
  29618. * 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)
  29619. * @param channel Name of the sampler variable.
  29620. * @param postProcess Post process to get the input texture from.
  29621. */
  29622. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29623. /**
  29624. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29625. * 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)
  29626. * @param channel Name of the sampler variable.
  29627. * @param postProcess Post process to get the output texture from.
  29628. */
  29629. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29630. /** @hidden */
  29631. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29632. /** @hidden */
  29633. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29634. /** @hidden */
  29635. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29636. /** @hidden */
  29637. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29638. /**
  29639. * Binds a buffer to a uniform.
  29640. * @param buffer Buffer to bind.
  29641. * @param name Name of the uniform variable to bind to.
  29642. */
  29643. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29644. /**
  29645. * Binds block to a uniform.
  29646. * @param blockName Name of the block to bind.
  29647. * @param index Index to bind.
  29648. */
  29649. bindUniformBlock(blockName: string, index: number): void;
  29650. /**
  29651. * Sets an interger value on a uniform variable.
  29652. * @param uniformName Name of the variable.
  29653. * @param value Value to be set.
  29654. * @returns this effect.
  29655. */
  29656. setInt(uniformName: string, value: number): Effect;
  29657. /**
  29658. * Sets an int array on a uniform variable.
  29659. * @param uniformName Name of the variable.
  29660. * @param array array to be set.
  29661. * @returns this effect.
  29662. */
  29663. setIntArray(uniformName: string, array: Int32Array): Effect;
  29664. /**
  29665. * 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)
  29666. * @param uniformName Name of the variable.
  29667. * @param array array to be set.
  29668. * @returns this effect.
  29669. */
  29670. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29671. /**
  29672. * 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)
  29673. * @param uniformName Name of the variable.
  29674. * @param array array to be set.
  29675. * @returns this effect.
  29676. */
  29677. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29678. /**
  29679. * 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)
  29680. * @param uniformName Name of the variable.
  29681. * @param array array to be set.
  29682. * @returns this effect.
  29683. */
  29684. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29685. /**
  29686. * Sets an float array on a uniform variable.
  29687. * @param uniformName Name of the variable.
  29688. * @param array array to be set.
  29689. * @returns this effect.
  29690. */
  29691. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29692. /**
  29693. * 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)
  29694. * @param uniformName Name of the variable.
  29695. * @param array array to be set.
  29696. * @returns this effect.
  29697. */
  29698. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29699. /**
  29700. * 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)
  29701. * @param uniformName Name of the variable.
  29702. * @param array array to be set.
  29703. * @returns this effect.
  29704. */
  29705. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29706. /**
  29707. * 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)
  29708. * @param uniformName Name of the variable.
  29709. * @param array array to be set.
  29710. * @returns this effect.
  29711. */
  29712. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29713. /**
  29714. * Sets an array on a uniform variable.
  29715. * @param uniformName Name of the variable.
  29716. * @param array array to be set.
  29717. * @returns this effect.
  29718. */
  29719. setArray(uniformName: string, array: number[]): Effect;
  29720. /**
  29721. * 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)
  29722. * @param uniformName Name of the variable.
  29723. * @param array array to be set.
  29724. * @returns this effect.
  29725. */
  29726. setArray2(uniformName: string, array: number[]): Effect;
  29727. /**
  29728. * 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)
  29729. * @param uniformName Name of the variable.
  29730. * @param array array to be set.
  29731. * @returns this effect.
  29732. */
  29733. setArray3(uniformName: string, array: number[]): Effect;
  29734. /**
  29735. * 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)
  29736. * @param uniformName Name of the variable.
  29737. * @param array array to be set.
  29738. * @returns this effect.
  29739. */
  29740. setArray4(uniformName: string, array: number[]): Effect;
  29741. /**
  29742. * Sets matrices on a uniform variable.
  29743. * @param uniformName Name of the variable.
  29744. * @param matrices matrices to be set.
  29745. * @returns this effect.
  29746. */
  29747. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29748. /**
  29749. * Sets matrix on a uniform variable.
  29750. * @param uniformName Name of the variable.
  29751. * @param matrix matrix to be set.
  29752. * @returns this effect.
  29753. */
  29754. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29755. /**
  29756. * 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)
  29757. * @param uniformName Name of the variable.
  29758. * @param matrix matrix to be set.
  29759. * @returns this effect.
  29760. */
  29761. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29762. /**
  29763. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29764. * @param uniformName Name of the variable.
  29765. * @param matrix matrix to be set.
  29766. * @returns this effect.
  29767. */
  29768. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29769. /**
  29770. * Sets a float on a uniform variable.
  29771. * @param uniformName Name of the variable.
  29772. * @param value value to be set.
  29773. * @returns this effect.
  29774. */
  29775. setFloat(uniformName: string, value: number): Effect;
  29776. /**
  29777. * Sets a boolean on a uniform variable.
  29778. * @param uniformName Name of the variable.
  29779. * @param bool value to be set.
  29780. * @returns this effect.
  29781. */
  29782. setBool(uniformName: string, bool: boolean): Effect;
  29783. /**
  29784. * Sets a Vector2 on a uniform variable.
  29785. * @param uniformName Name of the variable.
  29786. * @param vector2 vector2 to be set.
  29787. * @returns this effect.
  29788. */
  29789. setVector2(uniformName: string, vector2: Vector2): Effect;
  29790. /**
  29791. * Sets a float2 on a uniform variable.
  29792. * @param uniformName Name of the variable.
  29793. * @param x First float in float2.
  29794. * @param y Second float in float2.
  29795. * @returns this effect.
  29796. */
  29797. setFloat2(uniformName: string, x: number, y: number): Effect;
  29798. /**
  29799. * Sets a Vector3 on a uniform variable.
  29800. * @param uniformName Name of the variable.
  29801. * @param vector3 Value to be set.
  29802. * @returns this effect.
  29803. */
  29804. setVector3(uniformName: string, vector3: Vector3): Effect;
  29805. /**
  29806. * Sets a float3 on a uniform variable.
  29807. * @param uniformName Name of the variable.
  29808. * @param x First float in float3.
  29809. * @param y Second float in float3.
  29810. * @param z Third float in float3.
  29811. * @returns this effect.
  29812. */
  29813. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29814. /**
  29815. * Sets a Vector4 on a uniform variable.
  29816. * @param uniformName Name of the variable.
  29817. * @param vector4 Value to be set.
  29818. * @returns this effect.
  29819. */
  29820. setVector4(uniformName: string, vector4: Vector4): Effect;
  29821. /**
  29822. * Sets a float4 on a uniform variable.
  29823. * @param uniformName Name of the variable.
  29824. * @param x First float in float4.
  29825. * @param y Second float in float4.
  29826. * @param z Third float in float4.
  29827. * @param w Fourth float in float4.
  29828. * @returns this effect.
  29829. */
  29830. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29831. /**
  29832. * Sets a Color3 on a uniform variable.
  29833. * @param uniformName Name of the variable.
  29834. * @param color3 Value to be set.
  29835. * @returns this effect.
  29836. */
  29837. setColor3(uniformName: string, color3: Color3): Effect;
  29838. /**
  29839. * Sets a Color4 on a uniform variable.
  29840. * @param uniformName Name of the variable.
  29841. * @param color3 Value to be set.
  29842. * @param alpha Alpha value to be set.
  29843. * @returns this effect.
  29844. */
  29845. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29846. /**
  29847. * Sets a Color4 on a uniform variable
  29848. * @param uniformName defines the name of the variable
  29849. * @param color4 defines the value to be set
  29850. * @returns this effect.
  29851. */
  29852. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29853. /**
  29854. * This function will add a new shader to the shader store
  29855. * @param name the name of the shader
  29856. * @param pixelShader optional pixel shader content
  29857. * @param vertexShader optional vertex shader content
  29858. */
  29859. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29860. /**
  29861. * Store of each shader (The can be looked up using effect.key)
  29862. */
  29863. static ShadersStore: {
  29864. [key: string]: string;
  29865. };
  29866. /**
  29867. * Store of each included file for a shader (The can be looked up using effect.key)
  29868. */
  29869. static IncludesShadersStore: {
  29870. [key: string]: string;
  29871. };
  29872. /**
  29873. * Resets the cache of effects.
  29874. */
  29875. static ResetCache(): void;
  29876. }
  29877. }
  29878. declare module "babylonjs/Materials/colorCurves" {
  29879. import { Effect } from "babylonjs/Materials/effect";
  29880. /**
  29881. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29882. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29883. * 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;
  29884. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29885. */
  29886. export class ColorCurves {
  29887. private _dirty;
  29888. private _tempColor;
  29889. private _globalCurve;
  29890. private _highlightsCurve;
  29891. private _midtonesCurve;
  29892. private _shadowsCurve;
  29893. private _positiveCurve;
  29894. private _negativeCurve;
  29895. private _globalHue;
  29896. private _globalDensity;
  29897. private _globalSaturation;
  29898. private _globalExposure;
  29899. /**
  29900. * Gets the global Hue value.
  29901. * 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).
  29902. */
  29903. /**
  29904. * Sets the global Hue value.
  29905. * 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).
  29906. */
  29907. globalHue: number;
  29908. /**
  29909. * Gets the global Density value.
  29910. * 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.
  29911. * Values less than zero provide a filter of opposite hue.
  29912. */
  29913. /**
  29914. * Sets the global Density value.
  29915. * 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.
  29916. * Values less than zero provide a filter of opposite hue.
  29917. */
  29918. globalDensity: number;
  29919. /**
  29920. * Gets the global Saturation value.
  29921. * 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.
  29922. */
  29923. /**
  29924. * Sets the global Saturation value.
  29925. * 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.
  29926. */
  29927. globalSaturation: number;
  29928. /**
  29929. * Gets the global Exposure value.
  29930. * 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.
  29931. */
  29932. /**
  29933. * Sets the global Exposure value.
  29934. * 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.
  29935. */
  29936. globalExposure: number;
  29937. private _highlightsHue;
  29938. private _highlightsDensity;
  29939. private _highlightsSaturation;
  29940. private _highlightsExposure;
  29941. /**
  29942. * Gets the highlights Hue value.
  29943. * 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).
  29944. */
  29945. /**
  29946. * Sets the highlights Hue value.
  29947. * 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).
  29948. */
  29949. highlightsHue: number;
  29950. /**
  29951. * Gets the highlights Density value.
  29952. * 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.
  29953. * Values less than zero provide a filter of opposite hue.
  29954. */
  29955. /**
  29956. * Sets the highlights Density value.
  29957. * 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.
  29958. * Values less than zero provide a filter of opposite hue.
  29959. */
  29960. highlightsDensity: number;
  29961. /**
  29962. * Gets the highlights Saturation value.
  29963. * 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.
  29964. */
  29965. /**
  29966. * Sets the highlights Saturation value.
  29967. * 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.
  29968. */
  29969. highlightsSaturation: number;
  29970. /**
  29971. * Gets the highlights Exposure value.
  29972. * 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.
  29973. */
  29974. /**
  29975. * Sets the highlights Exposure value.
  29976. * 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.
  29977. */
  29978. highlightsExposure: number;
  29979. private _midtonesHue;
  29980. private _midtonesDensity;
  29981. private _midtonesSaturation;
  29982. private _midtonesExposure;
  29983. /**
  29984. * Gets the midtones Hue value.
  29985. * 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).
  29986. */
  29987. /**
  29988. * Sets the midtones Hue value.
  29989. * 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).
  29990. */
  29991. midtonesHue: number;
  29992. /**
  29993. * Gets the midtones Density value.
  29994. * 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.
  29995. * Values less than zero provide a filter of opposite hue.
  29996. */
  29997. /**
  29998. * Sets the midtones Density value.
  29999. * 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.
  30000. * Values less than zero provide a filter of opposite hue.
  30001. */
  30002. midtonesDensity: number;
  30003. /**
  30004. * Gets the midtones Saturation value.
  30005. * 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.
  30006. */
  30007. /**
  30008. * Sets the midtones Saturation value.
  30009. * 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.
  30010. */
  30011. midtonesSaturation: number;
  30012. /**
  30013. * Gets the midtones Exposure value.
  30014. * 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.
  30015. */
  30016. /**
  30017. * Sets the midtones Exposure value.
  30018. * 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.
  30019. */
  30020. midtonesExposure: number;
  30021. private _shadowsHue;
  30022. private _shadowsDensity;
  30023. private _shadowsSaturation;
  30024. private _shadowsExposure;
  30025. /**
  30026. * Gets the shadows Hue value.
  30027. * 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).
  30028. */
  30029. /**
  30030. * Sets the shadows Hue value.
  30031. * 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).
  30032. */
  30033. shadowsHue: number;
  30034. /**
  30035. * Gets the shadows Density value.
  30036. * 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.
  30037. * Values less than zero provide a filter of opposite hue.
  30038. */
  30039. /**
  30040. * Sets the shadows Density value.
  30041. * 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.
  30042. * Values less than zero provide a filter of opposite hue.
  30043. */
  30044. shadowsDensity: number;
  30045. /**
  30046. * Gets the shadows Saturation value.
  30047. * 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.
  30048. */
  30049. /**
  30050. * Sets the shadows Saturation value.
  30051. * 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.
  30052. */
  30053. shadowsSaturation: number;
  30054. /**
  30055. * Gets the shadows Exposure value.
  30056. * 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.
  30057. */
  30058. /**
  30059. * Sets the shadows Exposure value.
  30060. * 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.
  30061. */
  30062. shadowsExposure: number;
  30063. /**
  30064. * Returns the class name
  30065. * @returns The class name
  30066. */
  30067. getClassName(): string;
  30068. /**
  30069. * Binds the color curves to the shader.
  30070. * @param colorCurves The color curve to bind
  30071. * @param effect The effect to bind to
  30072. * @param positiveUniform The positive uniform shader parameter
  30073. * @param neutralUniform The neutral uniform shader parameter
  30074. * @param negativeUniform The negative uniform shader parameter
  30075. */
  30076. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30077. /**
  30078. * Prepare the list of uniforms associated with the ColorCurves effects.
  30079. * @param uniformsList The list of uniforms used in the effect
  30080. */
  30081. static PrepareUniforms(uniformsList: string[]): void;
  30082. /**
  30083. * Returns color grading data based on a hue, density, saturation and exposure value.
  30084. * @param filterHue The hue of the color filter.
  30085. * @param filterDensity The density of the color filter.
  30086. * @param saturation The saturation.
  30087. * @param exposure The exposure.
  30088. * @param result The result data container.
  30089. */
  30090. private getColorGradingDataToRef;
  30091. /**
  30092. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30093. * @param value The input slider value in range [-100,100].
  30094. * @returns Adjusted value.
  30095. */
  30096. private static applyColorGradingSliderNonlinear;
  30097. /**
  30098. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30099. * @param hue The hue (H) input.
  30100. * @param saturation The saturation (S) input.
  30101. * @param brightness The brightness (B) input.
  30102. * @result An RGBA color represented as Vector4.
  30103. */
  30104. private static fromHSBToRef;
  30105. /**
  30106. * Returns a value clamped between min and max
  30107. * @param value The value to clamp
  30108. * @param min The minimum of value
  30109. * @param max The maximum of value
  30110. * @returns The clamped value.
  30111. */
  30112. private static clamp;
  30113. /**
  30114. * Clones the current color curve instance.
  30115. * @return The cloned curves
  30116. */
  30117. clone(): ColorCurves;
  30118. /**
  30119. * Serializes the current color curve instance to a json representation.
  30120. * @return a JSON representation
  30121. */
  30122. serialize(): any;
  30123. /**
  30124. * Parses the color curve from a json representation.
  30125. * @param source the JSON source to parse
  30126. * @return The parsed curves
  30127. */
  30128. static Parse(source: any): ColorCurves;
  30129. }
  30130. }
  30131. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30132. import { Observable } from "babylonjs/Misc/observable";
  30133. import { Nullable } from "babylonjs/types";
  30134. import { Color4 } from "babylonjs/Maths/math";
  30135. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30136. import { Effect } from "babylonjs/Materials/effect";
  30137. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30138. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30139. /**
  30140. * Interface to follow in your material defines to integrate easily the
  30141. * Image proccessing functions.
  30142. * @hidden
  30143. */
  30144. export interface IImageProcessingConfigurationDefines {
  30145. IMAGEPROCESSING: boolean;
  30146. VIGNETTE: boolean;
  30147. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30148. VIGNETTEBLENDMODEOPAQUE: boolean;
  30149. TONEMAPPING: boolean;
  30150. TONEMAPPING_ACES: boolean;
  30151. CONTRAST: boolean;
  30152. EXPOSURE: boolean;
  30153. COLORCURVES: boolean;
  30154. COLORGRADING: boolean;
  30155. COLORGRADING3D: boolean;
  30156. SAMPLER3DGREENDEPTH: boolean;
  30157. SAMPLER3DBGRMAP: boolean;
  30158. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30159. }
  30160. /**
  30161. * @hidden
  30162. */
  30163. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30164. IMAGEPROCESSING: boolean;
  30165. VIGNETTE: boolean;
  30166. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30167. VIGNETTEBLENDMODEOPAQUE: boolean;
  30168. TONEMAPPING: boolean;
  30169. TONEMAPPING_ACES: boolean;
  30170. CONTRAST: boolean;
  30171. COLORCURVES: boolean;
  30172. COLORGRADING: boolean;
  30173. COLORGRADING3D: boolean;
  30174. SAMPLER3DGREENDEPTH: boolean;
  30175. SAMPLER3DBGRMAP: boolean;
  30176. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30177. EXPOSURE: boolean;
  30178. constructor();
  30179. }
  30180. /**
  30181. * This groups together the common properties used for image processing either in direct forward pass
  30182. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30183. * or not.
  30184. */
  30185. export class ImageProcessingConfiguration {
  30186. /**
  30187. * Default tone mapping applied in BabylonJS.
  30188. */
  30189. static readonly TONEMAPPING_STANDARD: number;
  30190. /**
  30191. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30192. * to other engines rendering to increase portability.
  30193. */
  30194. static readonly TONEMAPPING_ACES: number;
  30195. /**
  30196. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30197. */
  30198. colorCurves: Nullable<ColorCurves>;
  30199. private _colorCurvesEnabled;
  30200. /**
  30201. * Gets wether the color curves effect is enabled.
  30202. */
  30203. /**
  30204. * Sets wether the color curves effect is enabled.
  30205. */
  30206. colorCurvesEnabled: boolean;
  30207. private _colorGradingTexture;
  30208. /**
  30209. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30210. */
  30211. /**
  30212. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30213. */
  30214. colorGradingTexture: Nullable<BaseTexture>;
  30215. private _colorGradingEnabled;
  30216. /**
  30217. * Gets wether the color grading effect is enabled.
  30218. */
  30219. /**
  30220. * Sets wether the color grading effect is enabled.
  30221. */
  30222. colorGradingEnabled: boolean;
  30223. private _colorGradingWithGreenDepth;
  30224. /**
  30225. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30226. */
  30227. /**
  30228. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30229. */
  30230. colorGradingWithGreenDepth: boolean;
  30231. private _colorGradingBGR;
  30232. /**
  30233. * Gets wether the color grading texture contains BGR values.
  30234. */
  30235. /**
  30236. * Sets wether the color grading texture contains BGR values.
  30237. */
  30238. colorGradingBGR: boolean;
  30239. /** @hidden */
  30240. _exposure: number;
  30241. /**
  30242. * Gets the Exposure used in the effect.
  30243. */
  30244. /**
  30245. * Sets the Exposure used in the effect.
  30246. */
  30247. exposure: number;
  30248. private _toneMappingEnabled;
  30249. /**
  30250. * Gets wether the tone mapping effect is enabled.
  30251. */
  30252. /**
  30253. * Sets wether the tone mapping effect is enabled.
  30254. */
  30255. toneMappingEnabled: boolean;
  30256. private _toneMappingType;
  30257. /**
  30258. * Gets the type of tone mapping effect.
  30259. */
  30260. /**
  30261. * Sets the type of tone mapping effect used in BabylonJS.
  30262. */
  30263. toneMappingType: number;
  30264. protected _contrast: number;
  30265. /**
  30266. * Gets the contrast used in the effect.
  30267. */
  30268. /**
  30269. * Sets the contrast used in the effect.
  30270. */
  30271. contrast: number;
  30272. /**
  30273. * Vignette stretch size.
  30274. */
  30275. vignetteStretch: number;
  30276. /**
  30277. * Vignette centre X Offset.
  30278. */
  30279. vignetteCentreX: number;
  30280. /**
  30281. * Vignette centre Y Offset.
  30282. */
  30283. vignetteCentreY: number;
  30284. /**
  30285. * Vignette weight or intensity of the vignette effect.
  30286. */
  30287. vignetteWeight: number;
  30288. /**
  30289. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30290. * if vignetteEnabled is set to true.
  30291. */
  30292. vignetteColor: Color4;
  30293. /**
  30294. * Camera field of view used by the Vignette effect.
  30295. */
  30296. vignetteCameraFov: number;
  30297. private _vignetteBlendMode;
  30298. /**
  30299. * Gets the vignette blend mode allowing different kind of effect.
  30300. */
  30301. /**
  30302. * Sets the vignette blend mode allowing different kind of effect.
  30303. */
  30304. vignetteBlendMode: number;
  30305. private _vignetteEnabled;
  30306. /**
  30307. * Gets wether the vignette effect is enabled.
  30308. */
  30309. /**
  30310. * Sets wether the vignette effect is enabled.
  30311. */
  30312. vignetteEnabled: boolean;
  30313. private _applyByPostProcess;
  30314. /**
  30315. * Gets wether the image processing is applied through a post process or not.
  30316. */
  30317. /**
  30318. * Sets wether the image processing is applied through a post process or not.
  30319. */
  30320. applyByPostProcess: boolean;
  30321. private _isEnabled;
  30322. /**
  30323. * Gets wether the image processing is enabled or not.
  30324. */
  30325. /**
  30326. * Sets wether the image processing is enabled or not.
  30327. */
  30328. isEnabled: boolean;
  30329. /**
  30330. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30331. */
  30332. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30333. /**
  30334. * Method called each time the image processing information changes requires to recompile the effect.
  30335. */
  30336. protected _updateParameters(): void;
  30337. /**
  30338. * Gets the current class name.
  30339. * @return "ImageProcessingConfiguration"
  30340. */
  30341. getClassName(): string;
  30342. /**
  30343. * Prepare the list of uniforms associated with the Image Processing effects.
  30344. * @param uniforms The list of uniforms used in the effect
  30345. * @param defines the list of defines currently in use
  30346. */
  30347. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30348. /**
  30349. * Prepare the list of samplers associated with the Image Processing effects.
  30350. * @param samplersList The list of uniforms used in the effect
  30351. * @param defines the list of defines currently in use
  30352. */
  30353. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30354. /**
  30355. * Prepare the list of defines associated to the shader.
  30356. * @param defines the list of defines to complete
  30357. * @param forPostProcess Define if we are currently in post process mode or not
  30358. */
  30359. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30360. /**
  30361. * Returns true if all the image processing information are ready.
  30362. * @returns True if ready, otherwise, false
  30363. */
  30364. isReady(): boolean;
  30365. /**
  30366. * Binds the image processing to the shader.
  30367. * @param effect The effect to bind to
  30368. * @param aspectRatio Define the current aspect ratio of the effect
  30369. */
  30370. bind(effect: Effect, aspectRatio?: number): void;
  30371. /**
  30372. * Clones the current image processing instance.
  30373. * @return The cloned image processing
  30374. */
  30375. clone(): ImageProcessingConfiguration;
  30376. /**
  30377. * Serializes the current image processing instance to a json representation.
  30378. * @return a JSON representation
  30379. */
  30380. serialize(): any;
  30381. /**
  30382. * Parses the image processing from a json representation.
  30383. * @param source the JSON source to parse
  30384. * @return The parsed image processing
  30385. */
  30386. static Parse(source: any): ImageProcessingConfiguration;
  30387. private static _VIGNETTEMODE_MULTIPLY;
  30388. private static _VIGNETTEMODE_OPAQUE;
  30389. /**
  30390. * Used to apply the vignette as a mix with the pixel color.
  30391. */
  30392. static readonly VIGNETTEMODE_MULTIPLY: number;
  30393. /**
  30394. * Used to apply the vignette as a replacement of the pixel color.
  30395. */
  30396. static readonly VIGNETTEMODE_OPAQUE: number;
  30397. }
  30398. }
  30399. declare module "babylonjs/Materials/fresnelParameters" {
  30400. import { Color3 } from "babylonjs/Maths/math";
  30401. /**
  30402. * This represents all the required information to add a fresnel effect on a material:
  30403. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30404. */
  30405. export class FresnelParameters {
  30406. private _isEnabled;
  30407. /**
  30408. * Define if the fresnel effect is enable or not.
  30409. */
  30410. isEnabled: boolean;
  30411. /**
  30412. * Define the color used on edges (grazing angle)
  30413. */
  30414. leftColor: Color3;
  30415. /**
  30416. * Define the color used on center
  30417. */
  30418. rightColor: Color3;
  30419. /**
  30420. * Define bias applied to computed fresnel term
  30421. */
  30422. bias: number;
  30423. /**
  30424. * Defined the power exponent applied to fresnel term
  30425. */
  30426. power: number;
  30427. /**
  30428. * Clones the current fresnel and its valuues
  30429. * @returns a clone fresnel configuration
  30430. */
  30431. clone(): FresnelParameters;
  30432. /**
  30433. * Serializes the current fresnel parameters to a JSON representation.
  30434. * @return the JSON serialization
  30435. */
  30436. serialize(): any;
  30437. /**
  30438. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30439. * @param parsedFresnelParameters Define the JSON representation
  30440. * @returns the parsed parameters
  30441. */
  30442. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30443. }
  30444. }
  30445. declare module "babylonjs/Misc/decorators" {
  30446. import { Nullable } from "babylonjs/types";
  30447. import { Scene } from "babylonjs/scene";
  30448. import { IAnimatable } from "babylonjs/Misc/tools";
  30449. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30450. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30451. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30452. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30453. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30454. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30455. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30456. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30457. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30458. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30459. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30460. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30461. /**
  30462. * Decorator used to define property that can be serialized as reference to a camera
  30463. * @param sourceName defines the name of the property to decorate
  30464. */
  30465. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30466. /**
  30467. * Class used to help serialization objects
  30468. */
  30469. export class SerializationHelper {
  30470. /** hidden */
  30471. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30472. /** hidden */
  30473. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30474. /** hidden */
  30475. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30476. /** hidden */
  30477. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30478. /**
  30479. * Appends the serialized animations from the source animations
  30480. * @param source Source containing the animations
  30481. * @param destination Target to store the animations
  30482. */
  30483. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30484. /**
  30485. * Static function used to serialized a specific entity
  30486. * @param entity defines the entity to serialize
  30487. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30488. * @returns a JSON compatible object representing the serialization of the entity
  30489. */
  30490. static Serialize<T>(entity: T, serializationObject?: any): any;
  30491. /**
  30492. * Creates a new entity from a serialization data object
  30493. * @param creationFunction defines a function used to instanciated the new entity
  30494. * @param source defines the source serialization data
  30495. * @param scene defines the hosting scene
  30496. * @param rootUrl defines the root url for resources
  30497. * @returns a new entity
  30498. */
  30499. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30500. /**
  30501. * Clones an object
  30502. * @param creationFunction defines the function used to instanciate the new object
  30503. * @param source defines the source object
  30504. * @returns the cloned object
  30505. */
  30506. static Clone<T>(creationFunction: () => T, source: T): T;
  30507. /**
  30508. * Instanciates a new object based on a source one (some data will be shared between both object)
  30509. * @param creationFunction defines the function used to instanciate the new object
  30510. * @param source defines the source object
  30511. * @returns the new object
  30512. */
  30513. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30514. }
  30515. }
  30516. declare module "babylonjs/Cameras/camera" {
  30517. import { SmartArray } from "babylonjs/Misc/smartArray";
  30518. import { Observable } from "babylonjs/Misc/observable";
  30519. import { Nullable } from "babylonjs/types";
  30520. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30521. import { Scene } from "babylonjs/scene";
  30522. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30523. import { Node } from "babylonjs/node";
  30524. import { Mesh } from "babylonjs/Meshes/mesh";
  30525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30526. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30527. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30528. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30529. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30530. import { Ray } from "babylonjs/Culling/ray";
  30531. /**
  30532. * This is the base class of all the camera used in the application.
  30533. * @see http://doc.babylonjs.com/features/cameras
  30534. */
  30535. export class Camera extends Node {
  30536. /** @hidden */
  30537. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30538. /**
  30539. * This is the default projection mode used by the cameras.
  30540. * It helps recreating a feeling of perspective and better appreciate depth.
  30541. * This is the best way to simulate real life cameras.
  30542. */
  30543. static readonly PERSPECTIVE_CAMERA: number;
  30544. /**
  30545. * This helps creating camera with an orthographic mode.
  30546. * 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.
  30547. */
  30548. static readonly ORTHOGRAPHIC_CAMERA: number;
  30549. /**
  30550. * This is the default FOV mode for perspective cameras.
  30551. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30552. */
  30553. static readonly FOVMODE_VERTICAL_FIXED: number;
  30554. /**
  30555. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30556. */
  30557. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30558. /**
  30559. * This specifies ther is no need for a camera rig.
  30560. * Basically only one eye is rendered corresponding to the camera.
  30561. */
  30562. static readonly RIG_MODE_NONE: number;
  30563. /**
  30564. * Simulates a camera Rig with one blue eye and one red eye.
  30565. * This can be use with 3d blue and red glasses.
  30566. */
  30567. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30568. /**
  30569. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30570. */
  30571. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30572. /**
  30573. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30574. */
  30575. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30576. /**
  30577. * Defines that both eyes of the camera will be rendered over under each other.
  30578. */
  30579. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30580. /**
  30581. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30582. */
  30583. static readonly RIG_MODE_VR: number;
  30584. /**
  30585. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30586. */
  30587. static readonly RIG_MODE_WEBVR: number;
  30588. /**
  30589. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30590. */
  30591. static readonly RIG_MODE_CUSTOM: number;
  30592. /**
  30593. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30594. */
  30595. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30596. /**
  30597. * @hidden
  30598. * Might be removed once multiview will be a thing
  30599. */
  30600. static UseAlternateWebVRRendering: boolean;
  30601. /**
  30602. * Define the input manager associated with the camera.
  30603. */
  30604. inputs: CameraInputsManager<Camera>;
  30605. /** @hidden */
  30606. _position: Vector3;
  30607. /**
  30608. * Define the current local position of the camera in the scene
  30609. */
  30610. position: Vector3;
  30611. /**
  30612. * The vector the camera should consider as up.
  30613. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30614. */
  30615. upVector: Vector3;
  30616. /**
  30617. * Define the current limit on the left side for an orthographic camera
  30618. * In scene unit
  30619. */
  30620. orthoLeft: Nullable<number>;
  30621. /**
  30622. * Define the current limit on the right side for an orthographic camera
  30623. * In scene unit
  30624. */
  30625. orthoRight: Nullable<number>;
  30626. /**
  30627. * Define the current limit on the bottom side for an orthographic camera
  30628. * In scene unit
  30629. */
  30630. orthoBottom: Nullable<number>;
  30631. /**
  30632. * Define the current limit on the top side for an orthographic camera
  30633. * In scene unit
  30634. */
  30635. orthoTop: Nullable<number>;
  30636. /**
  30637. * Field Of View is set in Radians. (default is 0.8)
  30638. */
  30639. fov: number;
  30640. /**
  30641. * Define the minimum distance the camera can see from.
  30642. * This is important to note that the depth buffer are not infinite and the closer it starts
  30643. * the more your scene might encounter depth fighting issue.
  30644. */
  30645. minZ: number;
  30646. /**
  30647. * Define the maximum distance the camera can see to.
  30648. * This is important to note that the depth buffer are not infinite and the further it end
  30649. * the more your scene might encounter depth fighting issue.
  30650. */
  30651. maxZ: number;
  30652. /**
  30653. * Define the default inertia of the camera.
  30654. * This helps giving a smooth feeling to the camera movement.
  30655. */
  30656. inertia: number;
  30657. /**
  30658. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30659. */
  30660. mode: number;
  30661. /**
  30662. * Define wether the camera is intermediate.
  30663. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30664. */
  30665. isIntermediate: boolean;
  30666. /**
  30667. * Define the viewport of the camera.
  30668. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30669. */
  30670. viewport: Viewport;
  30671. /**
  30672. * Restricts the camera to viewing objects with the same layerMask.
  30673. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30674. */
  30675. layerMask: number;
  30676. /**
  30677. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30678. */
  30679. fovMode: number;
  30680. /**
  30681. * Rig mode of the camera.
  30682. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30683. * This is normally controlled byt the camera themselves as internal use.
  30684. */
  30685. cameraRigMode: number;
  30686. /**
  30687. * Defines the distance between both "eyes" in case of a RIG
  30688. */
  30689. interaxialDistance: number;
  30690. /**
  30691. * Defines if stereoscopic rendering is done side by side or over under.
  30692. */
  30693. isStereoscopicSideBySide: boolean;
  30694. /**
  30695. * 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
  30696. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30697. * else in the scene.
  30698. */
  30699. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30700. /**
  30701. * When set, the camera will render to this render target instead of the default canvas
  30702. */
  30703. outputRenderTarget: Nullable<RenderTargetTexture>;
  30704. /**
  30705. * Observable triggered when the camera view matrix has changed.
  30706. */
  30707. onViewMatrixChangedObservable: Observable<Camera>;
  30708. /**
  30709. * Observable triggered when the camera Projection matrix has changed.
  30710. */
  30711. onProjectionMatrixChangedObservable: Observable<Camera>;
  30712. /**
  30713. * Observable triggered when the inputs have been processed.
  30714. */
  30715. onAfterCheckInputsObservable: Observable<Camera>;
  30716. /**
  30717. * Observable triggered when reset has been called and applied to the camera.
  30718. */
  30719. onRestoreStateObservable: Observable<Camera>;
  30720. /** @hidden */
  30721. _cameraRigParams: any;
  30722. /** @hidden */
  30723. _rigCameras: Camera[];
  30724. /** @hidden */
  30725. _rigPostProcess: Nullable<PostProcess>;
  30726. protected _webvrViewMatrix: Matrix;
  30727. /** @hidden */
  30728. _skipRendering: boolean;
  30729. /** @hidden */
  30730. _alternateCamera: Camera;
  30731. /** @hidden */
  30732. _projectionMatrix: Matrix;
  30733. /** @hidden */
  30734. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30735. /** @hidden */
  30736. _activeMeshes: SmartArray<AbstractMesh>;
  30737. protected _globalPosition: Vector3;
  30738. /** hidden */
  30739. _computedViewMatrix: Matrix;
  30740. private _doNotComputeProjectionMatrix;
  30741. private _transformMatrix;
  30742. private _frustumPlanes;
  30743. private _refreshFrustumPlanes;
  30744. private _storedFov;
  30745. private _stateStored;
  30746. /**
  30747. * Instantiates a new camera object.
  30748. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30749. * @see http://doc.babylonjs.com/features/cameras
  30750. * @param name Defines the name of the camera in the scene
  30751. * @param position Defines the position of the camera
  30752. * @param scene Defines the scene the camera belongs too
  30753. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30754. */
  30755. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30756. /**
  30757. * Store current camera state (fov, position, etc..)
  30758. * @returns the camera
  30759. */
  30760. storeState(): Camera;
  30761. /**
  30762. * Restores the camera state values if it has been stored. You must call storeState() first
  30763. */
  30764. protected _restoreStateValues(): boolean;
  30765. /**
  30766. * Restored camera state. You must call storeState() first.
  30767. * @returns true if restored and false otherwise
  30768. */
  30769. restoreState(): boolean;
  30770. /**
  30771. * Gets the class name of the camera.
  30772. * @returns the class name
  30773. */
  30774. getClassName(): string;
  30775. /** @hidden */
  30776. readonly _isCamera: boolean;
  30777. /**
  30778. * Gets a string representation of the camera useful for debug purpose.
  30779. * @param fullDetails Defines that a more verboe level of logging is required
  30780. * @returns the string representation
  30781. */
  30782. toString(fullDetails?: boolean): string;
  30783. /**
  30784. * Gets the current world space position of the camera.
  30785. */
  30786. readonly globalPosition: Vector3;
  30787. /**
  30788. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30789. * @returns the active meshe list
  30790. */
  30791. getActiveMeshes(): SmartArray<AbstractMesh>;
  30792. /**
  30793. * Check wether a mesh is part of the current active mesh list of the camera
  30794. * @param mesh Defines the mesh to check
  30795. * @returns true if active, false otherwise
  30796. */
  30797. isActiveMesh(mesh: Mesh): boolean;
  30798. /**
  30799. * Is this camera ready to be used/rendered
  30800. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30801. * @return true if the camera is ready
  30802. */
  30803. isReady(completeCheck?: boolean): boolean;
  30804. /** @hidden */
  30805. _initCache(): void;
  30806. /** @hidden */
  30807. _updateCache(ignoreParentClass?: boolean): void;
  30808. /** @hidden */
  30809. _isSynchronized(): boolean;
  30810. /** @hidden */
  30811. _isSynchronizedViewMatrix(): boolean;
  30812. /** @hidden */
  30813. _isSynchronizedProjectionMatrix(): boolean;
  30814. /**
  30815. * Attach the input controls to a specific dom element to get the input from.
  30816. * @param element Defines the element the controls should be listened from
  30817. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30818. */
  30819. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30820. /**
  30821. * Detach the current controls from the specified dom element.
  30822. * @param element Defines the element to stop listening the inputs from
  30823. */
  30824. detachControl(element: HTMLElement): void;
  30825. /**
  30826. * Update the camera state according to the different inputs gathered during the frame.
  30827. */
  30828. update(): void;
  30829. /** @hidden */
  30830. _checkInputs(): void;
  30831. /** @hidden */
  30832. readonly rigCameras: Camera[];
  30833. /**
  30834. * Gets the post process used by the rig cameras
  30835. */
  30836. readonly rigPostProcess: Nullable<PostProcess>;
  30837. /**
  30838. * Internal, gets the first post proces.
  30839. * @returns the first post process to be run on this camera.
  30840. */
  30841. _getFirstPostProcess(): Nullable<PostProcess>;
  30842. private _cascadePostProcessesToRigCams;
  30843. /**
  30844. * Attach a post process to the camera.
  30845. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30846. * @param postProcess The post process to attach to the camera
  30847. * @param insertAt The position of the post process in case several of them are in use in the scene
  30848. * @returns the position the post process has been inserted at
  30849. */
  30850. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30851. /**
  30852. * Detach a post process to the camera.
  30853. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30854. * @param postProcess The post process to detach from the camera
  30855. */
  30856. detachPostProcess(postProcess: PostProcess): void;
  30857. /**
  30858. * Gets the current world matrix of the camera
  30859. */
  30860. getWorldMatrix(): Matrix;
  30861. /** @hidden */
  30862. _getViewMatrix(): Matrix;
  30863. /**
  30864. * Gets the current view matrix of the camera.
  30865. * @param force forces the camera to recompute the matrix without looking at the cached state
  30866. * @returns the view matrix
  30867. */
  30868. getViewMatrix(force?: boolean): Matrix;
  30869. /**
  30870. * Freeze the projection matrix.
  30871. * It will prevent the cache check of the camera projection compute and can speed up perf
  30872. * if no parameter of the camera are meant to change
  30873. * @param projection Defines manually a projection if necessary
  30874. */
  30875. freezeProjectionMatrix(projection?: Matrix): void;
  30876. /**
  30877. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30878. */
  30879. unfreezeProjectionMatrix(): void;
  30880. /**
  30881. * Gets the current projection matrix of the camera.
  30882. * @param force forces the camera to recompute the matrix without looking at the cached state
  30883. * @returns the projection matrix
  30884. */
  30885. getProjectionMatrix(force?: boolean): Matrix;
  30886. /**
  30887. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30888. * @returns a Matrix
  30889. */
  30890. getTransformationMatrix(): Matrix;
  30891. private _updateFrustumPlanes;
  30892. /**
  30893. * Checks if a cullable object (mesh...) is in the camera frustum
  30894. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30895. * @param target The object to check
  30896. * @returns true if the object is in frustum otherwise false
  30897. */
  30898. isInFrustum(target: ICullable): boolean;
  30899. /**
  30900. * Checks if a cullable object (mesh...) is in the camera frustum
  30901. * Unlike isInFrustum this cheks the full bounding box
  30902. * @param target The object to check
  30903. * @returns true if the object is in frustum otherwise false
  30904. */
  30905. isCompletelyInFrustum(target: ICullable): boolean;
  30906. /**
  30907. * Gets a ray in the forward direction from the camera.
  30908. * @param length Defines the length of the ray to create
  30909. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30910. * @param origin Defines the start point of the ray which defaults to the camera position
  30911. * @returns the forward ray
  30912. */
  30913. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30914. /**
  30915. * Releases resources associated with this node.
  30916. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30917. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30918. */
  30919. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30920. /** @hidden */
  30921. _isLeftCamera: boolean;
  30922. /**
  30923. * Gets the left camera of a rig setup in case of Rigged Camera
  30924. */
  30925. readonly isLeftCamera: boolean;
  30926. /** @hidden */
  30927. _isRightCamera: boolean;
  30928. /**
  30929. * Gets the right camera of a rig setup in case of Rigged Camera
  30930. */
  30931. readonly isRightCamera: boolean;
  30932. /**
  30933. * Gets the left camera of a rig setup in case of Rigged Camera
  30934. */
  30935. readonly leftCamera: Nullable<FreeCamera>;
  30936. /**
  30937. * Gets the right camera of a rig setup in case of Rigged Camera
  30938. */
  30939. readonly rightCamera: Nullable<FreeCamera>;
  30940. /**
  30941. * Gets the left camera target of a rig setup in case of Rigged Camera
  30942. * @returns the target position
  30943. */
  30944. getLeftTarget(): Nullable<Vector3>;
  30945. /**
  30946. * Gets the right camera target of a rig setup in case of Rigged Camera
  30947. * @returns the target position
  30948. */
  30949. getRightTarget(): Nullable<Vector3>;
  30950. /**
  30951. * @hidden
  30952. */
  30953. setCameraRigMode(mode: number, rigParams: any): void;
  30954. /** @hidden */
  30955. static _setStereoscopicRigMode(camera: Camera): void;
  30956. /** @hidden */
  30957. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30958. /** @hidden */
  30959. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30960. /** @hidden */
  30961. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30962. /** @hidden */
  30963. _getVRProjectionMatrix(): Matrix;
  30964. protected _updateCameraRotationMatrix(): void;
  30965. protected _updateWebVRCameraRotationMatrix(): void;
  30966. /**
  30967. * This function MUST be overwritten by the different WebVR cameras available.
  30968. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30969. * @hidden
  30970. */
  30971. _getWebVRProjectionMatrix(): Matrix;
  30972. /**
  30973. * This function MUST be overwritten by the different WebVR cameras available.
  30974. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30975. * @hidden
  30976. */
  30977. _getWebVRViewMatrix(): Matrix;
  30978. /** @hidden */
  30979. setCameraRigParameter(name: string, value: any): void;
  30980. /**
  30981. * needs to be overridden by children so sub has required properties to be copied
  30982. * @hidden
  30983. */
  30984. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30985. /**
  30986. * May need to be overridden by children
  30987. * @hidden
  30988. */
  30989. _updateRigCameras(): void;
  30990. /** @hidden */
  30991. _setupInputs(): void;
  30992. /**
  30993. * Serialiaze the camera setup to a json represention
  30994. * @returns the JSON representation
  30995. */
  30996. serialize(): any;
  30997. /**
  30998. * Clones the current camera.
  30999. * @param name The cloned camera name
  31000. * @returns the cloned camera
  31001. */
  31002. clone(name: string): Camera;
  31003. /**
  31004. * Gets the direction of the camera relative to a given local axis.
  31005. * @param localAxis Defines the reference axis to provide a relative direction.
  31006. * @return the direction
  31007. */
  31008. getDirection(localAxis: Vector3): Vector3;
  31009. /**
  31010. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31011. * @param localAxis Defines the reference axis to provide a relative direction.
  31012. * @param result Defines the vector to store the result in
  31013. */
  31014. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31015. /**
  31016. * Gets a camera constructor for a given camera type
  31017. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31018. * @param name The name of the camera the result will be able to instantiate
  31019. * @param scene The scene the result will construct the camera in
  31020. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31021. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31022. * @returns a factory method to construc the camera
  31023. */
  31024. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31025. /**
  31026. * Compute the world matrix of the camera.
  31027. * @returns the camera workd matrix
  31028. */
  31029. computeWorldMatrix(): Matrix;
  31030. /**
  31031. * Parse a JSON and creates the camera from the parsed information
  31032. * @param parsedCamera The JSON to parse
  31033. * @param scene The scene to instantiate the camera in
  31034. * @returns the newly constructed camera
  31035. */
  31036. static Parse(parsedCamera: any, scene: Scene): Camera;
  31037. }
  31038. }
  31039. declare module "babylonjs/Misc/tools" {
  31040. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31041. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31042. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31043. import { Observable } from "babylonjs/Misc/observable";
  31044. import { DomManagement } from "babylonjs/Misc/domManagement";
  31045. import { WebRequest } from "babylonjs/Misc/webRequest";
  31046. import { Camera } from "babylonjs/Cameras/camera";
  31047. import { Engine } from "babylonjs/Engines/engine";
  31048. import { Animation } from "babylonjs/Animations/animation";
  31049. /**
  31050. * Interface for any object that can request an animation frame
  31051. */
  31052. export interface ICustomAnimationFrameRequester {
  31053. /**
  31054. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31055. */
  31056. renderFunction?: Function;
  31057. /**
  31058. * Called to request the next frame to render to
  31059. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31060. */
  31061. requestAnimationFrame: Function;
  31062. /**
  31063. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31064. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31065. */
  31066. requestID?: number;
  31067. }
  31068. /**
  31069. * Interface containing an array of animations
  31070. */
  31071. export interface IAnimatable {
  31072. /**
  31073. * Array of animations
  31074. */
  31075. animations: Array<Animation>;
  31076. }
  31077. /** Interface used by value gradients (color, factor, ...) */
  31078. export interface IValueGradient {
  31079. /**
  31080. * Gets or sets the gradient value (between 0 and 1)
  31081. */
  31082. gradient: number;
  31083. }
  31084. /** Class used to store color4 gradient */
  31085. export class ColorGradient implements IValueGradient {
  31086. /**
  31087. * Gets or sets the gradient value (between 0 and 1)
  31088. */
  31089. gradient: number;
  31090. /**
  31091. * Gets or sets first associated color
  31092. */
  31093. color1: Color4;
  31094. /**
  31095. * Gets or sets second associated color
  31096. */
  31097. color2?: Color4;
  31098. /**
  31099. * Will get a color picked randomly between color1 and color2.
  31100. * If color2 is undefined then color1 will be used
  31101. * @param result defines the target Color4 to store the result in
  31102. */
  31103. getColorToRef(result: Color4): void;
  31104. }
  31105. /** Class used to store color 3 gradient */
  31106. export class Color3Gradient implements IValueGradient {
  31107. /**
  31108. * Gets or sets the gradient value (between 0 and 1)
  31109. */
  31110. gradient: number;
  31111. /**
  31112. * Gets or sets the associated color
  31113. */
  31114. color: Color3;
  31115. }
  31116. /** Class used to store factor gradient */
  31117. export class FactorGradient implements IValueGradient {
  31118. /**
  31119. * Gets or sets the gradient value (between 0 and 1)
  31120. */
  31121. gradient: number;
  31122. /**
  31123. * Gets or sets first associated factor
  31124. */
  31125. factor1: number;
  31126. /**
  31127. * Gets or sets second associated factor
  31128. */
  31129. factor2?: number;
  31130. /**
  31131. * Will get a number picked randomly between factor1 and factor2.
  31132. * If factor2 is undefined then factor1 will be used
  31133. * @returns the picked number
  31134. */
  31135. getFactor(): number;
  31136. }
  31137. /**
  31138. * @ignore
  31139. * Application error to support additional information when loading a file
  31140. */
  31141. export class LoadFileError extends Error {
  31142. /** defines the optional web request */
  31143. request?: WebRequest | undefined;
  31144. private static _setPrototypeOf;
  31145. /**
  31146. * Creates a new LoadFileError
  31147. * @param message defines the message of the error
  31148. * @param request defines the optional web request
  31149. */
  31150. constructor(message: string,
  31151. /** defines the optional web request */
  31152. request?: WebRequest | undefined);
  31153. }
  31154. /**
  31155. * Class used to define a retry strategy when error happens while loading assets
  31156. */
  31157. export class RetryStrategy {
  31158. /**
  31159. * Function used to defines an exponential back off strategy
  31160. * @param maxRetries defines the maximum number of retries (3 by default)
  31161. * @param baseInterval defines the interval between retries
  31162. * @returns the strategy function to use
  31163. */
  31164. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31165. }
  31166. /**
  31167. * File request interface
  31168. */
  31169. export interface IFileRequest {
  31170. /**
  31171. * Raised when the request is complete (success or error).
  31172. */
  31173. onCompleteObservable: Observable<IFileRequest>;
  31174. /**
  31175. * Aborts the request for a file.
  31176. */
  31177. abort: () => void;
  31178. }
  31179. /**
  31180. * Class containing a set of static utilities functions
  31181. */
  31182. export class Tools {
  31183. /**
  31184. * Gets or sets the base URL to use to load assets
  31185. */
  31186. static BaseUrl: string;
  31187. /**
  31188. * Enable/Disable Custom HTTP Request Headers globally.
  31189. * default = false
  31190. * @see CustomRequestHeaders
  31191. */
  31192. static UseCustomRequestHeaders: boolean;
  31193. /**
  31194. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31195. * i.e. when loading files, where the server/service expects an Authorization header
  31196. */
  31197. static CustomRequestHeaders: {
  31198. [key: string]: string;
  31199. };
  31200. /**
  31201. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31202. */
  31203. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31204. /**
  31205. * Default behaviour for cors in the application.
  31206. * It can be a string if the expected behavior is identical in the entire app.
  31207. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31208. */
  31209. static CorsBehavior: string | ((url: string | string[]) => string);
  31210. /**
  31211. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31212. * @ignorenaming
  31213. */
  31214. static UseFallbackTexture: boolean;
  31215. /**
  31216. * Use this object to register external classes like custom textures or material
  31217. * to allow the laoders to instantiate them
  31218. */
  31219. static RegisteredExternalClasses: {
  31220. [key: string]: Object;
  31221. };
  31222. /**
  31223. * Texture content used if a texture cannot loaded
  31224. * @ignorenaming
  31225. */
  31226. static fallbackTexture: string;
  31227. /**
  31228. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31229. * @param u defines the coordinate on X axis
  31230. * @param v defines the coordinate on Y axis
  31231. * @param width defines the width of the source data
  31232. * @param height defines the height of the source data
  31233. * @param pixels defines the source byte array
  31234. * @param color defines the output color
  31235. */
  31236. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31237. /**
  31238. * Interpolates between a and b via alpha
  31239. * @param a The lower value (returned when alpha = 0)
  31240. * @param b The upper value (returned when alpha = 1)
  31241. * @param alpha The interpolation-factor
  31242. * @return The mixed value
  31243. */
  31244. static Mix(a: number, b: number, alpha: number): number;
  31245. /**
  31246. * Tries to instantiate a new object from a given class name
  31247. * @param className defines the class name to instantiate
  31248. * @returns the new object or null if the system was not able to do the instantiation
  31249. */
  31250. static Instantiate(className: string): any;
  31251. /**
  31252. * Provides a slice function that will work even on IE
  31253. * @param data defines the array to slice
  31254. * @param start defines the start of the data (optional)
  31255. * @param end defines the end of the data (optional)
  31256. * @returns the new sliced array
  31257. */
  31258. static Slice<T>(data: T, start?: number, end?: number): T;
  31259. /**
  31260. * Polyfill for setImmediate
  31261. * @param action defines the action to execute after the current execution block
  31262. */
  31263. static SetImmediate(action: () => void): void;
  31264. /**
  31265. * Function indicating if a number is an exponent of 2
  31266. * @param value defines the value to test
  31267. * @returns true if the value is an exponent of 2
  31268. */
  31269. static IsExponentOfTwo(value: number): boolean;
  31270. private static _tmpFloatArray;
  31271. /**
  31272. * Returns the nearest 32-bit single precision float representation of a Number
  31273. * @param value A Number. If the parameter is of a different type, it will get converted
  31274. * to a number or to NaN if it cannot be converted
  31275. * @returns number
  31276. */
  31277. static FloatRound(value: number): number;
  31278. /**
  31279. * Find the next highest power of two.
  31280. * @param x Number to start search from.
  31281. * @return Next highest power of two.
  31282. */
  31283. static CeilingPOT(x: number): number;
  31284. /**
  31285. * Find the next lowest power of two.
  31286. * @param x Number to start search from.
  31287. * @return Next lowest power of two.
  31288. */
  31289. static FloorPOT(x: number): number;
  31290. /**
  31291. * Find the nearest power of two.
  31292. * @param x Number to start search from.
  31293. * @return Next nearest power of two.
  31294. */
  31295. static NearestPOT(x: number): number;
  31296. /**
  31297. * Get the closest exponent of two
  31298. * @param value defines the value to approximate
  31299. * @param max defines the maximum value to return
  31300. * @param mode defines how to define the closest value
  31301. * @returns closest exponent of two of the given value
  31302. */
  31303. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31304. /**
  31305. * Extracts the filename from a path
  31306. * @param path defines the path to use
  31307. * @returns the filename
  31308. */
  31309. static GetFilename(path: string): string;
  31310. /**
  31311. * Extracts the "folder" part of a path (everything before the filename).
  31312. * @param uri The URI to extract the info from
  31313. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31314. * @returns The "folder" part of the path
  31315. */
  31316. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31317. /**
  31318. * Extracts text content from a DOM element hierarchy
  31319. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31320. */
  31321. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31322. /**
  31323. * Convert an angle in radians to degrees
  31324. * @param angle defines the angle to convert
  31325. * @returns the angle in degrees
  31326. */
  31327. static ToDegrees(angle: number): number;
  31328. /**
  31329. * Convert an angle in degrees to radians
  31330. * @param angle defines the angle to convert
  31331. * @returns the angle in radians
  31332. */
  31333. static ToRadians(angle: number): number;
  31334. /**
  31335. * Encode a buffer to a base64 string
  31336. * @param buffer defines the buffer to encode
  31337. * @returns the encoded string
  31338. */
  31339. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31340. /**
  31341. * Extracts minimum and maximum values from a list of indexed positions
  31342. * @param positions defines the positions to use
  31343. * @param indices defines the indices to the positions
  31344. * @param indexStart defines the start index
  31345. * @param indexCount defines the end index
  31346. * @param bias defines bias value to add to the result
  31347. * @return minimum and maximum values
  31348. */
  31349. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31350. minimum: Vector3;
  31351. maximum: Vector3;
  31352. };
  31353. /**
  31354. * Extracts minimum and maximum values from a list of positions
  31355. * @param positions defines the positions to use
  31356. * @param start defines the start index in the positions array
  31357. * @param count defines the number of positions to handle
  31358. * @param bias defines bias value to add to the result
  31359. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31360. * @return minimum and maximum values
  31361. */
  31362. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31363. minimum: Vector3;
  31364. maximum: Vector3;
  31365. };
  31366. /**
  31367. * Returns an array if obj is not an array
  31368. * @param obj defines the object to evaluate as an array
  31369. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31370. * @returns either obj directly if obj is an array or a new array containing obj
  31371. */
  31372. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31373. /**
  31374. * Gets the pointer prefix to use
  31375. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31376. */
  31377. static GetPointerPrefix(): string;
  31378. /**
  31379. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31380. * @param func - the function to be called
  31381. * @param requester - the object that will request the next frame. Falls back to window.
  31382. * @returns frame number
  31383. */
  31384. static QueueNewFrame(func: () => void, requester?: any): number;
  31385. /**
  31386. * Ask the browser to promote the current element to fullscreen rendering mode
  31387. * @param element defines the DOM element to promote
  31388. */
  31389. static RequestFullscreen(element: HTMLElement): void;
  31390. /**
  31391. * Asks the browser to exit fullscreen mode
  31392. */
  31393. static ExitFullscreen(): void;
  31394. /**
  31395. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31396. * @param url define the url we are trying
  31397. * @param element define the dom element where to configure the cors policy
  31398. */
  31399. static SetCorsBehavior(url: string | string[], element: {
  31400. crossOrigin: string | null;
  31401. }): void;
  31402. /**
  31403. * Removes unwanted characters from an url
  31404. * @param url defines the url to clean
  31405. * @returns the cleaned url
  31406. */
  31407. static CleanUrl(url: string): string;
  31408. /**
  31409. * Gets or sets a function used to pre-process url before using them to load assets
  31410. */
  31411. static PreprocessUrl: (url: string) => string;
  31412. /**
  31413. * Loads an image as an HTMLImageElement.
  31414. * @param input url string, ArrayBuffer, or Blob to load
  31415. * @param onLoad callback called when the image successfully loads
  31416. * @param onError callback called when the image fails to load
  31417. * @param offlineProvider offline provider for caching
  31418. * @returns the HTMLImageElement of the loaded image
  31419. */
  31420. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31421. /**
  31422. * Loads a file
  31423. * @param url url string, ArrayBuffer, or Blob to load
  31424. * @param onSuccess callback called when the file successfully loads
  31425. * @param onProgress callback called while file is loading (if the server supports this mode)
  31426. * @param offlineProvider defines the offline provider for caching
  31427. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31428. * @param onError callback called when the file fails to load
  31429. * @returns a file request object
  31430. */
  31431. 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;
  31432. /**
  31433. * Load a script (identified by an url). When the url returns, the
  31434. * content of this file is added into a new script element, attached to the DOM (body element)
  31435. * @param scriptUrl defines the url of the script to laod
  31436. * @param onSuccess defines the callback called when the script is loaded
  31437. * @param onError defines the callback to call if an error occurs
  31438. */
  31439. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  31440. /**
  31441. * Loads a file from a blob
  31442. * @param fileToLoad defines the blob to use
  31443. * @param callback defines the callback to call when data is loaded
  31444. * @param progressCallback defines the callback to call during loading process
  31445. * @returns a file request object
  31446. */
  31447. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31448. /**
  31449. * Loads a file
  31450. * @param fileToLoad defines the file to load
  31451. * @param callback defines the callback to call when data is loaded
  31452. * @param progressCallBack defines the callback to call during loading process
  31453. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31454. * @returns a file request object
  31455. */
  31456. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31457. /**
  31458. * Creates a data url from a given string content
  31459. * @param content defines the content to convert
  31460. * @returns the new data url link
  31461. */
  31462. static FileAsURL(content: string): string;
  31463. /**
  31464. * Format the given number to a specific decimal format
  31465. * @param value defines the number to format
  31466. * @param decimals defines the number of decimals to use
  31467. * @returns the formatted string
  31468. */
  31469. static Format(value: number, decimals?: number): string;
  31470. /**
  31471. * Checks if a given vector is inside a specific range
  31472. * @param v defines the vector to test
  31473. * @param min defines the minimum range
  31474. * @param max defines the maximum range
  31475. */
  31476. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31477. /**
  31478. * Tries to copy an object by duplicating every property
  31479. * @param source defines the source object
  31480. * @param destination defines the target object
  31481. * @param doNotCopyList defines a list of properties to avoid
  31482. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31483. */
  31484. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31485. /**
  31486. * Gets a boolean indicating if the given object has no own property
  31487. * @param obj defines the object to test
  31488. * @returns true if object has no own property
  31489. */
  31490. static IsEmpty(obj: any): boolean;
  31491. /**
  31492. * Function used to register events at window level
  31493. * @param events defines the events to register
  31494. */
  31495. static RegisterTopRootEvents(events: {
  31496. name: string;
  31497. handler: Nullable<(e: FocusEvent) => any>;
  31498. }[]): void;
  31499. /**
  31500. * Function used to unregister events from window level
  31501. * @param events defines the events to unregister
  31502. */
  31503. static UnregisterTopRootEvents(events: {
  31504. name: string;
  31505. handler: Nullable<(e: FocusEvent) => any>;
  31506. }[]): void;
  31507. /**
  31508. * @ignore
  31509. */
  31510. static _ScreenshotCanvas: HTMLCanvasElement;
  31511. /**
  31512. * Dumps the current bound framebuffer
  31513. * @param width defines the rendering width
  31514. * @param height defines the rendering height
  31515. * @param engine defines the hosting engine
  31516. * @param successCallback defines the callback triggered once the data are available
  31517. * @param mimeType defines the mime type of the result
  31518. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31519. */
  31520. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31521. /**
  31522. * Converts the canvas data to blob.
  31523. * This acts as a polyfill for browsers not supporting the to blob function.
  31524. * @param canvas Defines the canvas to extract the data from
  31525. * @param successCallback Defines the callback triggered once the data are available
  31526. * @param mimeType Defines the mime type of the result
  31527. */
  31528. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31529. /**
  31530. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31531. * @param successCallback defines the callback triggered once the data are available
  31532. * @param mimeType defines the mime type of the result
  31533. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31534. */
  31535. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31536. /**
  31537. * Downloads a blob in the browser
  31538. * @param blob defines the blob to download
  31539. * @param fileName defines the name of the downloaded file
  31540. */
  31541. static Download(blob: Blob, fileName: string): void;
  31542. /**
  31543. * Captures a screenshot of the current rendering
  31544. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31545. * @param engine defines the rendering engine
  31546. * @param camera defines the source camera
  31547. * @param size This parameter can be set to a single number or to an object with the
  31548. * following (optional) properties: precision, width, height. If a single number is passed,
  31549. * it will be used for both width and height. If an object is passed, the screenshot size
  31550. * will be derived from the parameters. The precision property is a multiplier allowing
  31551. * rendering at a higher or lower resolution
  31552. * @param successCallback defines the callback receives a single parameter which contains the
  31553. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31554. * src parameter of an <img> to display it
  31555. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31556. * Check your browser for supported MIME types
  31557. */
  31558. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31559. /**
  31560. * Generates an image screenshot from the specified camera.
  31561. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31562. * @param engine The engine to use for rendering
  31563. * @param camera The camera to use for rendering
  31564. * @param size This parameter can be set to a single number or to an object with the
  31565. * following (optional) properties: precision, width, height. If a single number is passed,
  31566. * it will be used for both width and height. If an object is passed, the screenshot size
  31567. * will be derived from the parameters. The precision property is a multiplier allowing
  31568. * rendering at a higher or lower resolution
  31569. * @param successCallback The callback receives a single parameter which contains the
  31570. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31571. * src parameter of an <img> to display it
  31572. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31573. * Check your browser for supported MIME types
  31574. * @param samples Texture samples (default: 1)
  31575. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31576. * @param fileName A name for for the downloaded file.
  31577. */
  31578. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31579. /**
  31580. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31581. * Be aware Math.random() could cause collisions, but:
  31582. * "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"
  31583. * @returns a pseudo random id
  31584. */
  31585. static RandomId(): string;
  31586. /**
  31587. * Test if the given uri is a base64 string
  31588. * @param uri The uri to test
  31589. * @return True if the uri is a base64 string or false otherwise
  31590. */
  31591. static IsBase64(uri: string): boolean;
  31592. /**
  31593. * Decode the given base64 uri.
  31594. * @param uri The uri to decode
  31595. * @return The decoded base64 data.
  31596. */
  31597. static DecodeBase64(uri: string): ArrayBuffer;
  31598. /**
  31599. * No log
  31600. */
  31601. static readonly NoneLogLevel: number;
  31602. /**
  31603. * Only message logs
  31604. */
  31605. static readonly MessageLogLevel: number;
  31606. /**
  31607. * Only warning logs
  31608. */
  31609. static readonly WarningLogLevel: number;
  31610. /**
  31611. * Only error logs
  31612. */
  31613. static readonly ErrorLogLevel: number;
  31614. /**
  31615. * All logs
  31616. */
  31617. static readonly AllLogLevel: number;
  31618. /**
  31619. * Gets a value indicating the number of loading errors
  31620. * @ignorenaming
  31621. */
  31622. static readonly errorsCount: number;
  31623. /**
  31624. * Callback called when a new log is added
  31625. */
  31626. static OnNewCacheEntry: (entry: string) => void;
  31627. /**
  31628. * Log a message to the console
  31629. * @param message defines the message to log
  31630. */
  31631. static Log(message: string): void;
  31632. /**
  31633. * Write a warning message to the console
  31634. * @param message defines the message to log
  31635. */
  31636. static Warn(message: string): void;
  31637. /**
  31638. * Write an error message to the console
  31639. * @param message defines the message to log
  31640. */
  31641. static Error(message: string): void;
  31642. /**
  31643. * Gets current log cache (list of logs)
  31644. */
  31645. static readonly LogCache: string;
  31646. /**
  31647. * Clears the log cache
  31648. */
  31649. static ClearLogCache(): void;
  31650. /**
  31651. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31652. */
  31653. static LogLevels: number;
  31654. /**
  31655. * Checks if the loaded document was accessed via `file:`-Protocol.
  31656. * @returns boolean
  31657. */
  31658. static IsFileURL(): boolean;
  31659. /**
  31660. * Checks if the window object exists
  31661. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31662. */
  31663. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31664. /**
  31665. * No performance log
  31666. */
  31667. static readonly PerformanceNoneLogLevel: number;
  31668. /**
  31669. * Use user marks to log performance
  31670. */
  31671. static readonly PerformanceUserMarkLogLevel: number;
  31672. /**
  31673. * Log performance to the console
  31674. */
  31675. static readonly PerformanceConsoleLogLevel: number;
  31676. private static _performance;
  31677. /**
  31678. * Sets the current performance log level
  31679. */
  31680. static PerformanceLogLevel: number;
  31681. private static _StartPerformanceCounterDisabled;
  31682. private static _EndPerformanceCounterDisabled;
  31683. private static _StartUserMark;
  31684. private static _EndUserMark;
  31685. private static _StartPerformanceConsole;
  31686. private static _EndPerformanceConsole;
  31687. /**
  31688. * Starts a performance counter
  31689. */
  31690. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31691. /**
  31692. * Ends a specific performance coutner
  31693. */
  31694. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31695. /**
  31696. * Gets either window.performance.now() if supported or Date.now() else
  31697. */
  31698. static readonly Now: number;
  31699. /**
  31700. * This method will return the name of the class used to create the instance of the given object.
  31701. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31702. * @param object the object to get the class name from
  31703. * @param isType defines if the object is actually a type
  31704. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31705. */
  31706. static GetClassName(object: any, isType?: boolean): string;
  31707. /**
  31708. * Gets the first element of an array satisfying a given predicate
  31709. * @param array defines the array to browse
  31710. * @param predicate defines the predicate to use
  31711. * @returns null if not found or the element
  31712. */
  31713. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31714. /**
  31715. * This method will return the name of the full name of the class, including its owning module (if any).
  31716. * 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).
  31717. * @param object the object to get the class name from
  31718. * @param isType defines if the object is actually a type
  31719. * @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.
  31720. * @ignorenaming
  31721. */
  31722. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31723. /**
  31724. * Returns a promise that resolves after the given amount of time.
  31725. * @param delay Number of milliseconds to delay
  31726. * @returns Promise that resolves after the given amount of time
  31727. */
  31728. static DelayAsync(delay: number): Promise<void>;
  31729. /**
  31730. * Gets the current gradient from an array of IValueGradient
  31731. * @param ratio defines the current ratio to get
  31732. * @param gradients defines the array of IValueGradient
  31733. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31734. */
  31735. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31736. }
  31737. /**
  31738. * This class is used to track a performance counter which is number based.
  31739. * The user has access to many properties which give statistics of different nature.
  31740. *
  31741. * The implementer can track two kinds of Performance Counter: time and count.
  31742. * 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.
  31743. * 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.
  31744. */
  31745. export class PerfCounter {
  31746. /**
  31747. * Gets or sets a global boolean to turn on and off all the counters
  31748. */
  31749. static Enabled: boolean;
  31750. /**
  31751. * Returns the smallest value ever
  31752. */
  31753. readonly min: number;
  31754. /**
  31755. * Returns the biggest value ever
  31756. */
  31757. readonly max: number;
  31758. /**
  31759. * Returns the average value since the performance counter is running
  31760. */
  31761. readonly average: number;
  31762. /**
  31763. * Returns the average value of the last second the counter was monitored
  31764. */
  31765. readonly lastSecAverage: number;
  31766. /**
  31767. * Returns the current value
  31768. */
  31769. readonly current: number;
  31770. /**
  31771. * Gets the accumulated total
  31772. */
  31773. readonly total: number;
  31774. /**
  31775. * Gets the total value count
  31776. */
  31777. readonly count: number;
  31778. /**
  31779. * Creates a new counter
  31780. */
  31781. constructor();
  31782. /**
  31783. * Call this method to start monitoring a new frame.
  31784. * 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.
  31785. */
  31786. fetchNewFrame(): void;
  31787. /**
  31788. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31789. * @param newCount the count value to add to the monitored count
  31790. * @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.
  31791. */
  31792. addCount(newCount: number, fetchResult: boolean): void;
  31793. /**
  31794. * Start monitoring this performance counter
  31795. */
  31796. beginMonitoring(): void;
  31797. /**
  31798. * Compute the time lapsed since the previous beginMonitoring() call.
  31799. * @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
  31800. */
  31801. endMonitoring(newFrame?: boolean): void;
  31802. private _fetchResult;
  31803. private _startMonitoringTime;
  31804. private _min;
  31805. private _max;
  31806. private _average;
  31807. private _current;
  31808. private _totalValueCount;
  31809. private _totalAccumulated;
  31810. private _lastSecAverage;
  31811. private _lastSecAccumulated;
  31812. private _lastSecTime;
  31813. private _lastSecValueCount;
  31814. }
  31815. /**
  31816. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31817. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31818. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31819. * @param name The name of the class, case should be preserved
  31820. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31821. */
  31822. export function className(name: string, module?: string): (target: Object) => void;
  31823. /**
  31824. * An implementation of a loop for asynchronous functions.
  31825. */
  31826. export class AsyncLoop {
  31827. /**
  31828. * Defines the number of iterations for the loop
  31829. */
  31830. iterations: number;
  31831. /**
  31832. * Defines the current index of the loop.
  31833. */
  31834. index: number;
  31835. private _done;
  31836. private _fn;
  31837. private _successCallback;
  31838. /**
  31839. * Constructor.
  31840. * @param iterations the number of iterations.
  31841. * @param func the function to run each iteration
  31842. * @param successCallback the callback that will be called upon succesful execution
  31843. * @param offset starting offset.
  31844. */
  31845. constructor(
  31846. /**
  31847. * Defines the number of iterations for the loop
  31848. */
  31849. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31850. /**
  31851. * Execute the next iteration. Must be called after the last iteration was finished.
  31852. */
  31853. executeNext(): void;
  31854. /**
  31855. * Break the loop and run the success callback.
  31856. */
  31857. breakLoop(): void;
  31858. /**
  31859. * Create and run an async loop.
  31860. * @param iterations the number of iterations.
  31861. * @param fn the function to run each iteration
  31862. * @param successCallback the callback that will be called upon succesful execution
  31863. * @param offset starting offset.
  31864. * @returns the created async loop object
  31865. */
  31866. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31867. /**
  31868. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31869. * @param iterations total number of iterations
  31870. * @param syncedIterations number of synchronous iterations in each async iteration.
  31871. * @param fn the function to call each iteration.
  31872. * @param callback a success call back that will be called when iterating stops.
  31873. * @param breakFunction a break condition (optional)
  31874. * @param timeout timeout settings for the setTimeout function. default - 0.
  31875. * @returns the created async loop object
  31876. */
  31877. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31878. }
  31879. }
  31880. declare module "babylonjs/Collisions/collisionCoordinator" {
  31881. import { Nullable } from "babylonjs/types";
  31882. import { Scene } from "babylonjs/scene";
  31883. import { Vector3 } from "babylonjs/Maths/math";
  31884. import { Collider } from "babylonjs/Collisions/collider";
  31885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31886. /** @hidden */
  31887. export interface ICollisionCoordinator {
  31888. createCollider(): Collider;
  31889. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31890. init(scene: Scene): void;
  31891. }
  31892. /** @hidden */
  31893. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31894. private _scene;
  31895. private _scaledPosition;
  31896. private _scaledVelocity;
  31897. private _finalPosition;
  31898. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31899. createCollider(): Collider;
  31900. init(scene: Scene): void;
  31901. private _collideWithWorld;
  31902. }
  31903. }
  31904. declare module "babylonjs/Animations/animationGroup" {
  31905. import { Animatable } from "babylonjs/Animations/animatable";
  31906. import { Animation } from "babylonjs/Animations/animation";
  31907. import { Scene, IDisposable } from "babylonjs/scene";
  31908. import { Observable } from "babylonjs/Misc/observable";
  31909. import { Nullable } from "babylonjs/types";
  31910. /**
  31911. * This class defines the direct association between an animation and a target
  31912. */
  31913. export class TargetedAnimation {
  31914. /**
  31915. * Animation to perform
  31916. */
  31917. animation: Animation;
  31918. /**
  31919. * Target to animate
  31920. */
  31921. target: any;
  31922. }
  31923. /**
  31924. * Use this class to create coordinated animations on multiple targets
  31925. */
  31926. export class AnimationGroup implements IDisposable {
  31927. /** The name of the animation group */
  31928. name: string;
  31929. private _scene;
  31930. private _targetedAnimations;
  31931. private _animatables;
  31932. private _from;
  31933. private _to;
  31934. private _isStarted;
  31935. private _isPaused;
  31936. private _speedRatio;
  31937. /**
  31938. * Gets or sets the unique id of the node
  31939. */
  31940. uniqueId: number;
  31941. /**
  31942. * This observable will notify when one animation have ended
  31943. */
  31944. onAnimationEndObservable: Observable<TargetedAnimation>;
  31945. /**
  31946. * Observer raised when one animation loops
  31947. */
  31948. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31949. /**
  31950. * This observable will notify when all animations have ended.
  31951. */
  31952. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31953. /**
  31954. * This observable will notify when all animations have paused.
  31955. */
  31956. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31957. /**
  31958. * This observable will notify when all animations are playing.
  31959. */
  31960. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31961. /**
  31962. * Gets the first frame
  31963. */
  31964. readonly from: number;
  31965. /**
  31966. * Gets the last frame
  31967. */
  31968. readonly to: number;
  31969. /**
  31970. * Define if the animations are started
  31971. */
  31972. readonly isStarted: boolean;
  31973. /**
  31974. * Gets a value indicating that the current group is playing
  31975. */
  31976. readonly isPlaying: boolean;
  31977. /**
  31978. * Gets or sets the speed ratio to use for all animations
  31979. */
  31980. /**
  31981. * Gets or sets the speed ratio to use for all animations
  31982. */
  31983. speedRatio: number;
  31984. /**
  31985. * Gets the targeted animations for this animation group
  31986. */
  31987. readonly targetedAnimations: Array<TargetedAnimation>;
  31988. /**
  31989. * returning the list of animatables controlled by this animation group.
  31990. */
  31991. readonly animatables: Array<Animatable>;
  31992. /**
  31993. * Instantiates a new Animation Group.
  31994. * This helps managing several animations at once.
  31995. * @see http://doc.babylonjs.com/how_to/group
  31996. * @param name Defines the name of the group
  31997. * @param scene Defines the scene the group belongs to
  31998. */
  31999. constructor(
  32000. /** The name of the animation group */
  32001. name: string, scene?: Nullable<Scene>);
  32002. /**
  32003. * Add an animation (with its target) in the group
  32004. * @param animation defines the animation we want to add
  32005. * @param target defines the target of the animation
  32006. * @returns the TargetedAnimation object
  32007. */
  32008. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32009. /**
  32010. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32011. * It can add constant keys at begin or end
  32012. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32013. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32014. * @returns the animation group
  32015. */
  32016. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32017. /**
  32018. * Start all animations on given targets
  32019. * @param loop defines if animations must loop
  32020. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32021. * @param from defines the from key (optional)
  32022. * @param to defines the to key (optional)
  32023. * @returns the current animation group
  32024. */
  32025. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32026. /**
  32027. * Pause all animations
  32028. * @returns the animation group
  32029. */
  32030. pause(): AnimationGroup;
  32031. /**
  32032. * Play all animations to initial state
  32033. * This function will start() the animations if they were not started or will restart() them if they were paused
  32034. * @param loop defines if animations must loop
  32035. * @returns the animation group
  32036. */
  32037. play(loop?: boolean): AnimationGroup;
  32038. /**
  32039. * Reset all animations to initial state
  32040. * @returns the animation group
  32041. */
  32042. reset(): AnimationGroup;
  32043. /**
  32044. * Restart animations from key 0
  32045. * @returns the animation group
  32046. */
  32047. restart(): AnimationGroup;
  32048. /**
  32049. * Stop all animations
  32050. * @returns the animation group
  32051. */
  32052. stop(): AnimationGroup;
  32053. /**
  32054. * Set animation weight for all animatables
  32055. * @param weight defines the weight to use
  32056. * @return the animationGroup
  32057. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32058. */
  32059. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32060. /**
  32061. * Synchronize and normalize all animatables with a source animatable
  32062. * @param root defines the root animatable to synchronize with
  32063. * @return the animationGroup
  32064. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32065. */
  32066. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32067. /**
  32068. * Goes to a specific frame in this animation group
  32069. * @param frame the frame number to go to
  32070. * @return the animationGroup
  32071. */
  32072. goToFrame(frame: number): AnimationGroup;
  32073. /**
  32074. * Dispose all associated resources
  32075. */
  32076. dispose(): void;
  32077. private _checkAnimationGroupEnded;
  32078. /**
  32079. * Clone the current animation group and returns a copy
  32080. * @param newName defines the name of the new group
  32081. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32082. * @returns the new aniamtion group
  32083. */
  32084. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32085. /**
  32086. * Returns a new AnimationGroup object parsed from the source provided.
  32087. * @param parsedAnimationGroup defines the source
  32088. * @param scene defines the scene that will receive the animationGroup
  32089. * @returns a new AnimationGroup
  32090. */
  32091. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32092. /**
  32093. * Returns the string "AnimationGroup"
  32094. * @returns "AnimationGroup"
  32095. */
  32096. getClassName(): string;
  32097. /**
  32098. * Creates a detailled string about the object
  32099. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32100. * @returns a string representing the object
  32101. */
  32102. toString(fullDetails?: boolean): string;
  32103. }
  32104. }
  32105. declare module "babylonjs/scene" {
  32106. import { Nullable } from "babylonjs/types";
  32107. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32108. import { Observable } from "babylonjs/Misc/observable";
  32109. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32110. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32111. import { Geometry } from "babylonjs/Meshes/geometry";
  32112. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32113. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32114. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32115. import { Mesh } from "babylonjs/Meshes/mesh";
  32116. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32117. import { Bone } from "babylonjs/Bones/bone";
  32118. import { Skeleton } from "babylonjs/Bones/skeleton";
  32119. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32120. import { Camera } from "babylonjs/Cameras/camera";
  32121. import { AbstractScene } from "babylonjs/abstractScene";
  32122. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32123. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32124. import { Material } from "babylonjs/Materials/material";
  32125. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32126. import { Effect } from "babylonjs/Materials/effect";
  32127. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32128. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32129. import { Light } from "babylonjs/Lights/light";
  32130. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32131. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32132. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32133. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32134. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32135. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32136. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32137. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32138. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  32139. import { Engine } from "babylonjs/Engines/engine";
  32140. import { Node } from "babylonjs/node";
  32141. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32142. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32143. import { WebRequest } from "babylonjs/Misc/webRequest";
  32144. import { Ray } from "babylonjs/Culling/ray";
  32145. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32146. import { Animation } from "babylonjs/Animations/animation";
  32147. import { Animatable } from "babylonjs/Animations/animatable";
  32148. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32149. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32150. import { Collider } from "babylonjs/Collisions/collider";
  32151. /**
  32152. * Define an interface for all classes that will hold resources
  32153. */
  32154. export interface IDisposable {
  32155. /**
  32156. * Releases all held resources
  32157. */
  32158. dispose(): void;
  32159. }
  32160. /** Interface defining initialization parameters for Scene class */
  32161. export interface SceneOptions {
  32162. /**
  32163. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32164. * It will improve performance when the number of geometries becomes important.
  32165. */
  32166. useGeometryUniqueIdsMap?: boolean;
  32167. /**
  32168. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32169. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32170. */
  32171. useMaterialMeshMap?: boolean;
  32172. /**
  32173. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32174. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32175. */
  32176. useClonedMeshhMap?: boolean;
  32177. }
  32178. /**
  32179. * Represents a scene to be rendered by the engine.
  32180. * @see http://doc.babylonjs.com/features/scene
  32181. */
  32182. export class Scene extends AbstractScene implements IAnimatable {
  32183. private static _uniqueIdCounter;
  32184. /** The fog is deactivated */
  32185. static readonly FOGMODE_NONE: number;
  32186. /** The fog density is following an exponential function */
  32187. static readonly FOGMODE_EXP: number;
  32188. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32189. static readonly FOGMODE_EXP2: number;
  32190. /** The fog density is following a linear function. */
  32191. static readonly FOGMODE_LINEAR: number;
  32192. /**
  32193. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32194. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32195. */
  32196. static MinDeltaTime: number;
  32197. /**
  32198. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32199. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32200. */
  32201. static MaxDeltaTime: number;
  32202. /**
  32203. * Factory used to create the default material.
  32204. * @param name The name of the material to create
  32205. * @param scene The scene to create the material for
  32206. * @returns The default material
  32207. */
  32208. static DefaultMaterialFactory(scene: Scene): Material;
  32209. /**
  32210. * Factory used to create the a collision coordinator.
  32211. * @returns The collision coordinator
  32212. */
  32213. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32214. /** @hidden */
  32215. readonly _isScene: boolean;
  32216. /**
  32217. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32218. */
  32219. autoClear: boolean;
  32220. /**
  32221. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32222. */
  32223. autoClearDepthAndStencil: boolean;
  32224. /**
  32225. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32226. */
  32227. clearColor: Color4;
  32228. /**
  32229. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32230. */
  32231. ambientColor: Color3;
  32232. /** @hidden */
  32233. _environmentBRDFTexture: BaseTexture;
  32234. /** @hidden */
  32235. protected _environmentTexture: Nullable<BaseTexture>;
  32236. /**
  32237. * Texture used in all pbr material as the reflection texture.
  32238. * As in the majority of the scene they are the same (exception for multi room and so on),
  32239. * this is easier to reference from here than from all the materials.
  32240. */
  32241. /**
  32242. * Texture used in all pbr material as the reflection texture.
  32243. * As in the majority of the scene they are the same (exception for multi room and so on),
  32244. * this is easier to set here than in all the materials.
  32245. */
  32246. environmentTexture: Nullable<BaseTexture>;
  32247. /** @hidden */
  32248. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32249. /**
  32250. * Default image processing configuration used either in the rendering
  32251. * Forward main pass or through the imageProcessingPostProcess if present.
  32252. * As in the majority of the scene they are the same (exception for multi camera),
  32253. * this is easier to reference from here than from all the materials and post process.
  32254. *
  32255. * No setter as we it is a shared configuration, you can set the values instead.
  32256. */
  32257. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32258. private _forceWireframe;
  32259. /**
  32260. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32261. */
  32262. forceWireframe: boolean;
  32263. private _forcePointsCloud;
  32264. /**
  32265. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32266. */
  32267. forcePointsCloud: boolean;
  32268. /**
  32269. * Gets or sets the active clipplane 1
  32270. */
  32271. clipPlane: Nullable<Plane>;
  32272. /**
  32273. * Gets or sets the active clipplane 2
  32274. */
  32275. clipPlane2: Nullable<Plane>;
  32276. /**
  32277. * Gets or sets the active clipplane 3
  32278. */
  32279. clipPlane3: Nullable<Plane>;
  32280. /**
  32281. * Gets or sets the active clipplane 4
  32282. */
  32283. clipPlane4: Nullable<Plane>;
  32284. /**
  32285. * Gets or sets a boolean indicating if animations are enabled
  32286. */
  32287. animationsEnabled: boolean;
  32288. private _animationPropertiesOverride;
  32289. /**
  32290. * Gets or sets the animation properties override
  32291. */
  32292. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32293. /**
  32294. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32295. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32296. */
  32297. useConstantAnimationDeltaTime: boolean;
  32298. /**
  32299. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32300. * Please note that it requires to run a ray cast through the scene on every frame
  32301. */
  32302. constantlyUpdateMeshUnderPointer: boolean;
  32303. /**
  32304. * Defines the HTML cursor to use when hovering over interactive elements
  32305. */
  32306. hoverCursor: string;
  32307. /**
  32308. * Defines the HTML default cursor to use (empty by default)
  32309. */
  32310. defaultCursor: string;
  32311. /**
  32312. * This is used to call preventDefault() on pointer down
  32313. * in order to block unwanted artifacts like system double clicks
  32314. */
  32315. preventDefaultOnPointerDown: boolean;
  32316. /**
  32317. * This is used to call preventDefault() on pointer up
  32318. * in order to block unwanted artifacts like system double clicks
  32319. */
  32320. preventDefaultOnPointerUp: boolean;
  32321. /**
  32322. * Gets or sets user defined metadata
  32323. */
  32324. metadata: any;
  32325. /**
  32326. * For internal use only. Please do not use.
  32327. */
  32328. reservedDataStore: any;
  32329. /**
  32330. * Gets the name of the plugin used to load this scene (null by default)
  32331. */
  32332. loadingPluginName: string;
  32333. /**
  32334. * Use this array to add regular expressions used to disable offline support for specific urls
  32335. */
  32336. disableOfflineSupportExceptionRules: RegExp[];
  32337. /**
  32338. * An event triggered when the scene is disposed.
  32339. */
  32340. onDisposeObservable: Observable<Scene>;
  32341. private _onDisposeObserver;
  32342. /** Sets a function to be executed when this scene is disposed. */
  32343. onDispose: () => void;
  32344. /**
  32345. * An event triggered before rendering the scene (right after animations and physics)
  32346. */
  32347. onBeforeRenderObservable: Observable<Scene>;
  32348. private _onBeforeRenderObserver;
  32349. /** Sets a function to be executed before rendering this scene */
  32350. beforeRender: Nullable<() => void>;
  32351. /**
  32352. * An event triggered after rendering the scene
  32353. */
  32354. onAfterRenderObservable: Observable<Scene>;
  32355. private _onAfterRenderObserver;
  32356. /** Sets a function to be executed after rendering this scene */
  32357. afterRender: Nullable<() => void>;
  32358. /**
  32359. * An event triggered before animating the scene
  32360. */
  32361. onBeforeAnimationsObservable: Observable<Scene>;
  32362. /**
  32363. * An event triggered after animations processing
  32364. */
  32365. onAfterAnimationsObservable: Observable<Scene>;
  32366. /**
  32367. * An event triggered before draw calls are ready to be sent
  32368. */
  32369. onBeforeDrawPhaseObservable: Observable<Scene>;
  32370. /**
  32371. * An event triggered after draw calls have been sent
  32372. */
  32373. onAfterDrawPhaseObservable: Observable<Scene>;
  32374. /**
  32375. * An event triggered when the scene is ready
  32376. */
  32377. onReadyObservable: Observable<Scene>;
  32378. /**
  32379. * An event triggered before rendering a camera
  32380. */
  32381. onBeforeCameraRenderObservable: Observable<Camera>;
  32382. private _onBeforeCameraRenderObserver;
  32383. /** Sets a function to be executed before rendering a camera*/
  32384. beforeCameraRender: () => void;
  32385. /**
  32386. * An event triggered after rendering a camera
  32387. */
  32388. onAfterCameraRenderObservable: Observable<Camera>;
  32389. private _onAfterCameraRenderObserver;
  32390. /** Sets a function to be executed after rendering a camera*/
  32391. afterCameraRender: () => void;
  32392. /**
  32393. * An event triggered when active meshes evaluation is about to start
  32394. */
  32395. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32396. /**
  32397. * An event triggered when active meshes evaluation is done
  32398. */
  32399. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32400. /**
  32401. * An event triggered when particles rendering is about to start
  32402. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32403. */
  32404. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32405. /**
  32406. * An event triggered when particles rendering is done
  32407. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32408. */
  32409. onAfterParticlesRenderingObservable: Observable<Scene>;
  32410. /**
  32411. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32412. */
  32413. onDataLoadedObservable: Observable<Scene>;
  32414. /**
  32415. * An event triggered when a camera is created
  32416. */
  32417. onNewCameraAddedObservable: Observable<Camera>;
  32418. /**
  32419. * An event triggered when a camera is removed
  32420. */
  32421. onCameraRemovedObservable: Observable<Camera>;
  32422. /**
  32423. * An event triggered when a light is created
  32424. */
  32425. onNewLightAddedObservable: Observable<Light>;
  32426. /**
  32427. * An event triggered when a light is removed
  32428. */
  32429. onLightRemovedObservable: Observable<Light>;
  32430. /**
  32431. * An event triggered when a geometry is created
  32432. */
  32433. onNewGeometryAddedObservable: Observable<Geometry>;
  32434. /**
  32435. * An event triggered when a geometry is removed
  32436. */
  32437. onGeometryRemovedObservable: Observable<Geometry>;
  32438. /**
  32439. * An event triggered when a transform node is created
  32440. */
  32441. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32442. /**
  32443. * An event triggered when a transform node is removed
  32444. */
  32445. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32446. /**
  32447. * An event triggered when a mesh is created
  32448. */
  32449. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32450. /**
  32451. * An event triggered when a mesh is removed
  32452. */
  32453. onMeshRemovedObservable: Observable<AbstractMesh>;
  32454. /**
  32455. * An event triggered when a skeleton is created
  32456. */
  32457. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32458. /**
  32459. * An event triggered when a skeleton is removed
  32460. */
  32461. onSkeletonRemovedObservable: Observable<Skeleton>;
  32462. /**
  32463. * An event triggered when a material is created
  32464. */
  32465. onNewMaterialAddedObservable: Observable<Material>;
  32466. /**
  32467. * An event triggered when a material is removed
  32468. */
  32469. onMaterialRemovedObservable: Observable<Material>;
  32470. /**
  32471. * An event triggered when a texture is created
  32472. */
  32473. onNewTextureAddedObservable: Observable<BaseTexture>;
  32474. /**
  32475. * An event triggered when a texture is removed
  32476. */
  32477. onTextureRemovedObservable: Observable<BaseTexture>;
  32478. /**
  32479. * An event triggered when render targets are about to be rendered
  32480. * Can happen multiple times per frame.
  32481. */
  32482. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32483. /**
  32484. * An event triggered when render targets were rendered.
  32485. * Can happen multiple times per frame.
  32486. */
  32487. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32488. /**
  32489. * An event triggered before calculating deterministic simulation step
  32490. */
  32491. onBeforeStepObservable: Observable<Scene>;
  32492. /**
  32493. * An event triggered after calculating deterministic simulation step
  32494. */
  32495. onAfterStepObservable: Observable<Scene>;
  32496. /**
  32497. * An event triggered when the activeCamera property is updated
  32498. */
  32499. onActiveCameraChanged: Observable<Scene>;
  32500. /**
  32501. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32502. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32503. * 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)
  32504. */
  32505. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32506. /**
  32507. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32508. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32509. * 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)
  32510. */
  32511. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32512. /**
  32513. * This Observable will when a mesh has been imported into the scene.
  32514. */
  32515. onMeshImportedObservable: Observable<AbstractMesh>;
  32516. /**
  32517. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32518. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32519. */
  32520. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32521. /** @hidden */
  32522. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32523. /**
  32524. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32525. */
  32526. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32527. /**
  32528. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32529. */
  32530. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32531. /**
  32532. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32533. */
  32534. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32535. private _onPointerMove;
  32536. private _onPointerDown;
  32537. private _onPointerUp;
  32538. /** Callback called when a pointer move is detected */
  32539. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32540. /** Callback called when a pointer down is detected */
  32541. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32542. /** Callback called when a pointer up is detected */
  32543. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32544. /** Callback called when a pointer pick is detected */
  32545. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32546. /**
  32547. * 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).
  32548. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32549. */
  32550. onPrePointerObservable: Observable<PointerInfoPre>;
  32551. /**
  32552. * Observable event triggered each time an input event is received from the rendering canvas
  32553. */
  32554. onPointerObservable: Observable<PointerInfo>;
  32555. /**
  32556. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32557. */
  32558. readonly unTranslatedPointer: Vector2;
  32559. /** The distance in pixel that you have to move to prevent some events */
  32560. static DragMovementThreshold: number;
  32561. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32562. static LongPressDelay: number;
  32563. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32564. static DoubleClickDelay: number;
  32565. /** If you need to check double click without raising a single click at first click, enable this flag */
  32566. static ExclusiveDoubleClickMode: boolean;
  32567. private _initClickEvent;
  32568. private _initActionManager;
  32569. private _delayedSimpleClick;
  32570. private _delayedSimpleClickTimeout;
  32571. private _previousDelayedSimpleClickTimeout;
  32572. private _meshPickProceed;
  32573. private _previousButtonPressed;
  32574. private _currentPickResult;
  32575. private _previousPickResult;
  32576. private _totalPointersPressed;
  32577. private _doubleClickOccured;
  32578. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32579. cameraToUseForPointers: Nullable<Camera>;
  32580. private _pointerX;
  32581. private _pointerY;
  32582. private _unTranslatedPointerX;
  32583. private _unTranslatedPointerY;
  32584. private _startingPointerPosition;
  32585. private _previousStartingPointerPosition;
  32586. private _startingPointerTime;
  32587. private _previousStartingPointerTime;
  32588. private _pointerCaptures;
  32589. private _timeAccumulator;
  32590. private _currentStepId;
  32591. private _currentInternalStep;
  32592. /** @hidden */
  32593. _mirroredCameraPosition: Nullable<Vector3>;
  32594. /**
  32595. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32596. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32597. */
  32598. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32599. /**
  32600. * Observable event triggered each time an keyboard event is received from the hosting window
  32601. */
  32602. onKeyboardObservable: Observable<KeyboardInfo>;
  32603. private _onKeyDown;
  32604. private _onKeyUp;
  32605. private _onCanvasFocusObserver;
  32606. private _onCanvasBlurObserver;
  32607. private _useRightHandedSystem;
  32608. /**
  32609. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32610. */
  32611. useRightHandedSystem: boolean;
  32612. /**
  32613. * Sets the step Id used by deterministic lock step
  32614. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32615. * @param newStepId defines the step Id
  32616. */
  32617. setStepId(newStepId: number): void;
  32618. /**
  32619. * Gets the step Id used by deterministic lock step
  32620. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32621. * @returns the step Id
  32622. */
  32623. getStepId(): number;
  32624. /**
  32625. * Gets the internal step used by deterministic lock step
  32626. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32627. * @returns the internal step
  32628. */
  32629. getInternalStep(): number;
  32630. private _fogEnabled;
  32631. /**
  32632. * Gets or sets a boolean indicating if fog is enabled on this scene
  32633. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32634. * (Default is true)
  32635. */
  32636. fogEnabled: boolean;
  32637. private _fogMode;
  32638. /**
  32639. * Gets or sets the fog mode to use
  32640. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32641. * | mode | value |
  32642. * | --- | --- |
  32643. * | FOGMODE_NONE | 0 |
  32644. * | FOGMODE_EXP | 1 |
  32645. * | FOGMODE_EXP2 | 2 |
  32646. * | FOGMODE_LINEAR | 3 |
  32647. */
  32648. fogMode: number;
  32649. /**
  32650. * Gets or sets the fog color to use
  32651. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32652. * (Default is Color3(0.2, 0.2, 0.3))
  32653. */
  32654. fogColor: Color3;
  32655. /**
  32656. * Gets or sets the fog density to use
  32657. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32658. * (Default is 0.1)
  32659. */
  32660. fogDensity: number;
  32661. /**
  32662. * Gets or sets the fog start distance to use
  32663. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32664. * (Default is 0)
  32665. */
  32666. fogStart: number;
  32667. /**
  32668. * Gets or sets the fog end distance to use
  32669. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32670. * (Default is 1000)
  32671. */
  32672. fogEnd: number;
  32673. private _shadowsEnabled;
  32674. /**
  32675. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32676. */
  32677. shadowsEnabled: boolean;
  32678. private _lightsEnabled;
  32679. /**
  32680. * Gets or sets a boolean indicating if lights are enabled on this scene
  32681. */
  32682. lightsEnabled: boolean;
  32683. /** All of the active cameras added to this scene. */
  32684. activeCameras: Camera[];
  32685. private _activeCamera;
  32686. /** Gets or sets the current active camera */
  32687. activeCamera: Nullable<Camera>;
  32688. private _defaultMaterial;
  32689. /** The default material used on meshes when no material is affected */
  32690. /** The default material used on meshes when no material is affected */
  32691. defaultMaterial: Material;
  32692. private _texturesEnabled;
  32693. /**
  32694. * Gets or sets a boolean indicating if textures are enabled on this scene
  32695. */
  32696. texturesEnabled: boolean;
  32697. /**
  32698. * Gets or sets a boolean indicating if particles are enabled on this scene
  32699. */
  32700. particlesEnabled: boolean;
  32701. /**
  32702. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32703. */
  32704. spritesEnabled: boolean;
  32705. private _skeletonsEnabled;
  32706. /**
  32707. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32708. */
  32709. skeletonsEnabled: boolean;
  32710. /**
  32711. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32712. */
  32713. lensFlaresEnabled: boolean;
  32714. /**
  32715. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32716. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32717. */
  32718. collisionsEnabled: boolean;
  32719. private _collisionCoordinator;
  32720. /** @hidden */
  32721. readonly collisionCoordinator: ICollisionCoordinator;
  32722. /**
  32723. * Defines the gravity applied to this scene (used only for collisions)
  32724. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32725. */
  32726. gravity: Vector3;
  32727. /**
  32728. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32729. */
  32730. postProcessesEnabled: boolean;
  32731. /**
  32732. * The list of postprocesses added to the scene
  32733. */
  32734. postProcesses: PostProcess[];
  32735. /**
  32736. * Gets the current postprocess manager
  32737. */
  32738. postProcessManager: PostProcessManager;
  32739. /**
  32740. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32741. */
  32742. renderTargetsEnabled: boolean;
  32743. /**
  32744. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32745. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32746. */
  32747. dumpNextRenderTargets: boolean;
  32748. /**
  32749. * The list of user defined render targets added to the scene
  32750. */
  32751. customRenderTargets: RenderTargetTexture[];
  32752. /**
  32753. * Defines if texture loading must be delayed
  32754. * If true, textures will only be loaded when they need to be rendered
  32755. */
  32756. useDelayedTextureLoading: boolean;
  32757. /**
  32758. * Gets the list of meshes imported to the scene through SceneLoader
  32759. */
  32760. importedMeshesFiles: String[];
  32761. /**
  32762. * Gets or sets a boolean indicating if probes are enabled on this scene
  32763. */
  32764. probesEnabled: boolean;
  32765. /**
  32766. * Gets or sets the current offline provider to use to store scene data
  32767. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32768. */
  32769. offlineProvider: IOfflineProvider;
  32770. /**
  32771. * Gets or sets the action manager associated with the scene
  32772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32773. */
  32774. actionManager: AbstractActionManager;
  32775. private _meshesForIntersections;
  32776. /**
  32777. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32778. */
  32779. proceduralTexturesEnabled: boolean;
  32780. private _engine;
  32781. private _totalVertices;
  32782. /** @hidden */
  32783. _activeIndices: PerfCounter;
  32784. /** @hidden */
  32785. _activeParticles: PerfCounter;
  32786. /** @hidden */
  32787. _activeBones: PerfCounter;
  32788. private _animationRatio;
  32789. /** @hidden */
  32790. _animationTimeLast: number;
  32791. /** @hidden */
  32792. _animationTime: number;
  32793. /**
  32794. * Gets or sets a general scale for animation speed
  32795. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32796. */
  32797. animationTimeScale: number;
  32798. /** @hidden */
  32799. _cachedMaterial: Nullable<Material>;
  32800. /** @hidden */
  32801. _cachedEffect: Nullable<Effect>;
  32802. /** @hidden */
  32803. _cachedVisibility: Nullable<number>;
  32804. private _renderId;
  32805. private _frameId;
  32806. private _executeWhenReadyTimeoutId;
  32807. private _intermediateRendering;
  32808. private _viewUpdateFlag;
  32809. private _projectionUpdateFlag;
  32810. private _alternateViewUpdateFlag;
  32811. private _alternateProjectionUpdateFlag;
  32812. /** @hidden */
  32813. _toBeDisposed: Nullable<IDisposable>[];
  32814. private _activeRequests;
  32815. /** @hidden */
  32816. _pendingData: any[];
  32817. private _isDisposed;
  32818. /**
  32819. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32820. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32821. */
  32822. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32823. private _activeMeshes;
  32824. private _processedMaterials;
  32825. private _renderTargets;
  32826. /** @hidden */
  32827. _activeParticleSystems: SmartArray<IParticleSystem>;
  32828. private _activeSkeletons;
  32829. private _softwareSkinnedMeshes;
  32830. private _renderingManager;
  32831. /** @hidden */
  32832. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32833. private _transformMatrix;
  32834. private _sceneUbo;
  32835. private _alternateSceneUbo;
  32836. private _viewMatrix;
  32837. private _projectionMatrix;
  32838. private _alternateViewMatrix;
  32839. private _alternateProjectionMatrix;
  32840. private _alternateTransformMatrix;
  32841. private _useAlternateCameraConfiguration;
  32842. private _alternateRendering;
  32843. private _wheelEventName;
  32844. /** @hidden */
  32845. _forcedViewPosition: Nullable<Vector3>;
  32846. /** @hidden */
  32847. readonly _isAlternateRenderingEnabled: boolean;
  32848. private _frustumPlanes;
  32849. /**
  32850. * Gets the list of frustum planes (built from the active camera)
  32851. */
  32852. readonly frustumPlanes: Plane[];
  32853. /**
  32854. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32855. * This is useful if there are more lights that the maximum simulteanous authorized
  32856. */
  32857. requireLightSorting: boolean;
  32858. /** @hidden */
  32859. readonly useMaterialMeshMap: boolean;
  32860. /** @hidden */
  32861. readonly useClonedMeshhMap: boolean;
  32862. private _pointerOverMesh;
  32863. private _pickedDownMesh;
  32864. private _pickedUpMesh;
  32865. private _externalData;
  32866. private _uid;
  32867. /**
  32868. * @hidden
  32869. * Backing store of defined scene components.
  32870. */
  32871. _components: ISceneComponent[];
  32872. /**
  32873. * @hidden
  32874. * Backing store of defined scene components.
  32875. */
  32876. _serializableComponents: ISceneSerializableComponent[];
  32877. /**
  32878. * List of components to register on the next registration step.
  32879. */
  32880. private _transientComponents;
  32881. /**
  32882. * Registers the transient components if needed.
  32883. */
  32884. private _registerTransientComponents;
  32885. /**
  32886. * @hidden
  32887. * Add a component to the scene.
  32888. * Note that the ccomponent could be registered on th next frame if this is called after
  32889. * the register component stage.
  32890. * @param component Defines the component to add to the scene
  32891. */
  32892. _addComponent(component: ISceneComponent): void;
  32893. /**
  32894. * @hidden
  32895. * Gets a component from the scene.
  32896. * @param name defines the name of the component to retrieve
  32897. * @returns the component or null if not present
  32898. */
  32899. _getComponent(name: string): Nullable<ISceneComponent>;
  32900. /**
  32901. * @hidden
  32902. * Defines the actions happening before camera updates.
  32903. */
  32904. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32905. /**
  32906. * @hidden
  32907. * Defines the actions happening before clear the canvas.
  32908. */
  32909. _beforeClearStage: Stage<SimpleStageAction>;
  32910. /**
  32911. * @hidden
  32912. * Defines the actions when collecting render targets for the frame.
  32913. */
  32914. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32915. /**
  32916. * @hidden
  32917. * Defines the actions happening for one camera in the frame.
  32918. */
  32919. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32920. /**
  32921. * @hidden
  32922. * Defines the actions happening during the per mesh ready checks.
  32923. */
  32924. _isReadyForMeshStage: Stage<MeshStageAction>;
  32925. /**
  32926. * @hidden
  32927. * Defines the actions happening before evaluate active mesh checks.
  32928. */
  32929. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32930. /**
  32931. * @hidden
  32932. * Defines the actions happening during the evaluate sub mesh checks.
  32933. */
  32934. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32935. /**
  32936. * @hidden
  32937. * Defines the actions happening during the active mesh stage.
  32938. */
  32939. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32940. /**
  32941. * @hidden
  32942. * Defines the actions happening during the per camera render target step.
  32943. */
  32944. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32945. /**
  32946. * @hidden
  32947. * Defines the actions happening just before the active camera is drawing.
  32948. */
  32949. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32950. /**
  32951. * @hidden
  32952. * Defines the actions happening just before a render target is drawing.
  32953. */
  32954. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32955. /**
  32956. * @hidden
  32957. * Defines the actions happening just before a rendering group is drawing.
  32958. */
  32959. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32960. /**
  32961. * @hidden
  32962. * Defines the actions happening just before a mesh is drawing.
  32963. */
  32964. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32965. /**
  32966. * @hidden
  32967. * Defines the actions happening just after a mesh has been drawn.
  32968. */
  32969. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32970. /**
  32971. * @hidden
  32972. * Defines the actions happening just after a rendering group has been drawn.
  32973. */
  32974. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32975. /**
  32976. * @hidden
  32977. * Defines the actions happening just after the active camera has been drawn.
  32978. */
  32979. _afterCameraDrawStage: Stage<CameraStageAction>;
  32980. /**
  32981. * @hidden
  32982. * Defines the actions happening just after a render target has been drawn.
  32983. */
  32984. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32985. /**
  32986. * @hidden
  32987. * Defines the actions happening just after rendering all cameras and computing intersections.
  32988. */
  32989. _afterRenderStage: Stage<SimpleStageAction>;
  32990. /**
  32991. * @hidden
  32992. * Defines the actions happening when a pointer move event happens.
  32993. */
  32994. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32995. /**
  32996. * @hidden
  32997. * Defines the actions happening when a pointer down event happens.
  32998. */
  32999. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33000. /**
  33001. * @hidden
  33002. * Defines the actions happening when a pointer up event happens.
  33003. */
  33004. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33005. /**
  33006. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33007. */
  33008. private geometriesByUniqueId;
  33009. /**
  33010. * Creates a new Scene
  33011. * @param engine defines the engine to use to render this scene
  33012. * @param options defines the scene options
  33013. */
  33014. constructor(engine: Engine, options?: SceneOptions);
  33015. private _defaultMeshCandidates;
  33016. /**
  33017. * @hidden
  33018. */
  33019. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33020. private _defaultSubMeshCandidates;
  33021. /**
  33022. * @hidden
  33023. */
  33024. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33025. /**
  33026. * Sets the default candidate providers for the scene.
  33027. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33028. * and getCollidingSubMeshCandidates to their default function
  33029. */
  33030. setDefaultCandidateProviders(): void;
  33031. /**
  33032. * Gets the mesh that is currently under the pointer
  33033. */
  33034. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33035. /**
  33036. * Gets or sets the current on-screen X position of the pointer
  33037. */
  33038. pointerX: number;
  33039. /**
  33040. * Gets or sets the current on-screen Y position of the pointer
  33041. */
  33042. pointerY: number;
  33043. /**
  33044. * Gets the cached material (ie. the latest rendered one)
  33045. * @returns the cached material
  33046. */
  33047. getCachedMaterial(): Nullable<Material>;
  33048. /**
  33049. * Gets the cached effect (ie. the latest rendered one)
  33050. * @returns the cached effect
  33051. */
  33052. getCachedEffect(): Nullable<Effect>;
  33053. /**
  33054. * Gets the cached visibility state (ie. the latest rendered one)
  33055. * @returns the cached visibility state
  33056. */
  33057. getCachedVisibility(): Nullable<number>;
  33058. /**
  33059. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33060. * @param material defines the current material
  33061. * @param effect defines the current effect
  33062. * @param visibility defines the current visibility state
  33063. * @returns true if one parameter is not cached
  33064. */
  33065. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33066. /**
  33067. * Gets the engine associated with the scene
  33068. * @returns an Engine
  33069. */
  33070. getEngine(): Engine;
  33071. /**
  33072. * Gets the total number of vertices rendered per frame
  33073. * @returns the total number of vertices rendered per frame
  33074. */
  33075. getTotalVertices(): number;
  33076. /**
  33077. * Gets the performance counter for total vertices
  33078. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33079. */
  33080. readonly totalVerticesPerfCounter: PerfCounter;
  33081. /**
  33082. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33083. * @returns the total number of active indices rendered per frame
  33084. */
  33085. getActiveIndices(): number;
  33086. /**
  33087. * Gets the performance counter for active indices
  33088. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33089. */
  33090. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33091. /**
  33092. * Gets the total number of active particles rendered per frame
  33093. * @returns the total number of active particles rendered per frame
  33094. */
  33095. getActiveParticles(): number;
  33096. /**
  33097. * Gets the performance counter for active particles
  33098. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33099. */
  33100. readonly activeParticlesPerfCounter: PerfCounter;
  33101. /**
  33102. * Gets the total number of active bones rendered per frame
  33103. * @returns the total number of active bones rendered per frame
  33104. */
  33105. getActiveBones(): number;
  33106. /**
  33107. * Gets the performance counter for active bones
  33108. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33109. */
  33110. readonly activeBonesPerfCounter: PerfCounter;
  33111. /**
  33112. * Gets the array of active meshes
  33113. * @returns an array of AbstractMesh
  33114. */
  33115. getActiveMeshes(): SmartArray<AbstractMesh>;
  33116. /**
  33117. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33118. * @returns a number
  33119. */
  33120. getAnimationRatio(): number;
  33121. /**
  33122. * Gets an unique Id for the current render phase
  33123. * @returns a number
  33124. */
  33125. getRenderId(): number;
  33126. /**
  33127. * Gets an unique Id for the current frame
  33128. * @returns a number
  33129. */
  33130. getFrameId(): number;
  33131. /** Call this function if you want to manually increment the render Id*/
  33132. incrementRenderId(): void;
  33133. private _updatePointerPosition;
  33134. private _createUbo;
  33135. private _createAlternateUbo;
  33136. private _setRayOnPointerInfo;
  33137. /**
  33138. * Use this method to simulate a pointer move on a mesh
  33139. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33140. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33141. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33142. * @returns the current scene
  33143. */
  33144. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33145. private _processPointerMove;
  33146. private _checkPrePointerObservable;
  33147. /**
  33148. * Use this method to simulate a pointer down on a mesh
  33149. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33150. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33151. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33152. * @returns the current scene
  33153. */
  33154. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33155. private _processPointerDown;
  33156. /**
  33157. * Use this method to simulate a pointer up on a mesh
  33158. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33159. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33160. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33161. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33162. * @returns the current scene
  33163. */
  33164. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33165. private _processPointerUp;
  33166. /**
  33167. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33168. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33169. * @returns true if the pointer was captured
  33170. */
  33171. isPointerCaptured(pointerId?: number): boolean;
  33172. /** @hidden */
  33173. _isPointerSwiping(): boolean;
  33174. /**
  33175. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33176. * @param attachUp defines if you want to attach events to pointerup
  33177. * @param attachDown defines if you want to attach events to pointerdown
  33178. * @param attachMove defines if you want to attach events to pointermove
  33179. */
  33180. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33181. /** Detaches all event handlers*/
  33182. detachControl(): void;
  33183. /**
  33184. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33185. * Delay loaded resources are not taking in account
  33186. * @return true if all required resources are ready
  33187. */
  33188. isReady(): boolean;
  33189. /** Resets all cached information relative to material (including effect and visibility) */
  33190. resetCachedMaterial(): void;
  33191. /**
  33192. * Registers a function to be called before every frame render
  33193. * @param func defines the function to register
  33194. */
  33195. registerBeforeRender(func: () => void): void;
  33196. /**
  33197. * Unregisters a function called before every frame render
  33198. * @param func defines the function to unregister
  33199. */
  33200. unregisterBeforeRender(func: () => void): void;
  33201. /**
  33202. * Registers a function to be called after every frame render
  33203. * @param func defines the function to register
  33204. */
  33205. registerAfterRender(func: () => void): void;
  33206. /**
  33207. * Unregisters a function called after every frame render
  33208. * @param func defines the function to unregister
  33209. */
  33210. unregisterAfterRender(func: () => void): void;
  33211. private _executeOnceBeforeRender;
  33212. /**
  33213. * The provided function will run before render once and will be disposed afterwards.
  33214. * A timeout delay can be provided so that the function will be executed in N ms.
  33215. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33216. * @param func The function to be executed.
  33217. * @param timeout optional delay in ms
  33218. */
  33219. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33220. /** @hidden */
  33221. _addPendingData(data: any): void;
  33222. /** @hidden */
  33223. _removePendingData(data: any): void;
  33224. /**
  33225. * Returns the number of items waiting to be loaded
  33226. * @returns the number of items waiting to be loaded
  33227. */
  33228. getWaitingItemsCount(): number;
  33229. /**
  33230. * Returns a boolean indicating if the scene is still loading data
  33231. */
  33232. readonly isLoading: boolean;
  33233. /**
  33234. * Registers a function to be executed when the scene is ready
  33235. * @param {Function} func - the function to be executed
  33236. */
  33237. executeWhenReady(func: () => void): void;
  33238. /**
  33239. * Returns a promise that resolves when the scene is ready
  33240. * @returns A promise that resolves when the scene is ready
  33241. */
  33242. whenReadyAsync(): Promise<void>;
  33243. /** @hidden */
  33244. _checkIsReady(): void;
  33245. /**
  33246. * Gets all animatable attached to the scene
  33247. */
  33248. readonly animatables: Animatable[];
  33249. /**
  33250. * Resets the last animation time frame.
  33251. * Useful to override when animations start running when loading a scene for the first time.
  33252. */
  33253. resetLastAnimationTimeFrame(): void;
  33254. /** @hidden */
  33255. _switchToAlternateCameraConfiguration(active: boolean): void;
  33256. /**
  33257. * Gets the current view matrix
  33258. * @returns a Matrix
  33259. */
  33260. getViewMatrix(): Matrix;
  33261. /**
  33262. * Gets the current projection matrix
  33263. * @returns a Matrix
  33264. */
  33265. getProjectionMatrix(): Matrix;
  33266. /**
  33267. * Gets the current transform matrix
  33268. * @returns a Matrix made of View * Projection
  33269. */
  33270. getTransformMatrix(): Matrix;
  33271. /**
  33272. * Sets the current transform matrix
  33273. * @param view defines the View matrix to use
  33274. * @param projection defines the Projection matrix to use
  33275. */
  33276. setTransformMatrix(view: Matrix, projection: Matrix): void;
  33277. /** @hidden */
  33278. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  33279. /**
  33280. * Gets the uniform buffer used to store scene data
  33281. * @returns a UniformBuffer
  33282. */
  33283. getSceneUniformBuffer(): UniformBuffer;
  33284. /**
  33285. * Gets an unique (relatively to the current scene) Id
  33286. * @returns an unique number for the scene
  33287. */
  33288. getUniqueId(): number;
  33289. /**
  33290. * Add a mesh to the list of scene's meshes
  33291. * @param newMesh defines the mesh to add
  33292. * @param recursive if all child meshes should also be added to the scene
  33293. */
  33294. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33295. /**
  33296. * Remove a mesh for the list of scene's meshes
  33297. * @param toRemove defines the mesh to remove
  33298. * @param recursive if all child meshes should also be removed from the scene
  33299. * @returns the index where the mesh was in the mesh list
  33300. */
  33301. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33302. /**
  33303. * Add a transform node to the list of scene's transform nodes
  33304. * @param newTransformNode defines the transform node to add
  33305. */
  33306. addTransformNode(newTransformNode: TransformNode): void;
  33307. /**
  33308. * Remove a transform node for the list of scene's transform nodes
  33309. * @param toRemove defines the transform node to remove
  33310. * @returns the index where the transform node was in the transform node list
  33311. */
  33312. removeTransformNode(toRemove: TransformNode): number;
  33313. /**
  33314. * Remove a skeleton for the list of scene's skeletons
  33315. * @param toRemove defines the skeleton to remove
  33316. * @returns the index where the skeleton was in the skeleton list
  33317. */
  33318. removeSkeleton(toRemove: Skeleton): number;
  33319. /**
  33320. * Remove a morph target for the list of scene's morph targets
  33321. * @param toRemove defines the morph target to remove
  33322. * @returns the index where the morph target was in the morph target list
  33323. */
  33324. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33325. /**
  33326. * Remove a light for the list of scene's lights
  33327. * @param toRemove defines the light to remove
  33328. * @returns the index where the light was in the light list
  33329. */
  33330. removeLight(toRemove: Light): number;
  33331. /**
  33332. * Remove a camera for the list of scene's cameras
  33333. * @param toRemove defines the camera to remove
  33334. * @returns the index where the camera was in the camera list
  33335. */
  33336. removeCamera(toRemove: Camera): number;
  33337. /**
  33338. * Remove a particle system for the list of scene's particle systems
  33339. * @param toRemove defines the particle system to remove
  33340. * @returns the index where the particle system was in the particle system list
  33341. */
  33342. removeParticleSystem(toRemove: IParticleSystem): number;
  33343. /**
  33344. * Remove a animation for the list of scene's animations
  33345. * @param toRemove defines the animation to remove
  33346. * @returns the index where the animation was in the animation list
  33347. */
  33348. removeAnimation(toRemove: Animation): number;
  33349. /**
  33350. * Removes the given animation group from this scene.
  33351. * @param toRemove The animation group to remove
  33352. * @returns The index of the removed animation group
  33353. */
  33354. removeAnimationGroup(toRemove: AnimationGroup): number;
  33355. /**
  33356. * Removes the given multi-material from this scene.
  33357. * @param toRemove The multi-material to remove
  33358. * @returns The index of the removed multi-material
  33359. */
  33360. removeMultiMaterial(toRemove: MultiMaterial): number;
  33361. /**
  33362. * Removes the given material from this scene.
  33363. * @param toRemove The material to remove
  33364. * @returns The index of the removed material
  33365. */
  33366. removeMaterial(toRemove: Material): number;
  33367. /**
  33368. * Removes the given action manager from this scene.
  33369. * @param toRemove The action manager to remove
  33370. * @returns The index of the removed action manager
  33371. */
  33372. removeActionManager(toRemove: AbstractActionManager): number;
  33373. /**
  33374. * Removes the given texture from this scene.
  33375. * @param toRemove The texture to remove
  33376. * @returns The index of the removed texture
  33377. */
  33378. removeTexture(toRemove: BaseTexture): number;
  33379. /**
  33380. * Adds the given light to this scene
  33381. * @param newLight The light to add
  33382. */
  33383. addLight(newLight: Light): void;
  33384. /**
  33385. * Sorts the list list based on light priorities
  33386. */
  33387. sortLightsByPriority(): void;
  33388. /**
  33389. * Adds the given camera to this scene
  33390. * @param newCamera The camera to add
  33391. */
  33392. addCamera(newCamera: Camera): void;
  33393. /**
  33394. * Adds the given skeleton to this scene
  33395. * @param newSkeleton The skeleton to add
  33396. */
  33397. addSkeleton(newSkeleton: Skeleton): void;
  33398. /**
  33399. * Adds the given particle system to this scene
  33400. * @param newParticleSystem The particle system to add
  33401. */
  33402. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33403. /**
  33404. * Adds the given animation to this scene
  33405. * @param newAnimation The animation to add
  33406. */
  33407. addAnimation(newAnimation: Animation): void;
  33408. /**
  33409. * Adds the given animation group to this scene.
  33410. * @param newAnimationGroup The animation group to add
  33411. */
  33412. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33413. /**
  33414. * Adds the given multi-material to this scene
  33415. * @param newMultiMaterial The multi-material to add
  33416. */
  33417. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33418. /**
  33419. * Adds the given material to this scene
  33420. * @param newMaterial The material to add
  33421. */
  33422. addMaterial(newMaterial: Material): void;
  33423. /**
  33424. * Adds the given morph target to this scene
  33425. * @param newMorphTargetManager The morph target to add
  33426. */
  33427. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33428. /**
  33429. * Adds the given geometry to this scene
  33430. * @param newGeometry The geometry to add
  33431. */
  33432. addGeometry(newGeometry: Geometry): void;
  33433. /**
  33434. * Adds the given action manager to this scene
  33435. * @param newActionManager The action manager to add
  33436. */
  33437. addActionManager(newActionManager: AbstractActionManager): void;
  33438. /**
  33439. * Adds the given texture to this scene.
  33440. * @param newTexture The texture to add
  33441. */
  33442. addTexture(newTexture: BaseTexture): void;
  33443. /**
  33444. * Switch active camera
  33445. * @param newCamera defines the new active camera
  33446. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33447. */
  33448. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33449. /**
  33450. * sets the active camera of the scene using its ID
  33451. * @param id defines the camera's ID
  33452. * @return the new active camera or null if none found.
  33453. */
  33454. setActiveCameraByID(id: string): Nullable<Camera>;
  33455. /**
  33456. * sets the active camera of the scene using its name
  33457. * @param name defines the camera's name
  33458. * @returns the new active camera or null if none found.
  33459. */
  33460. setActiveCameraByName(name: string): Nullable<Camera>;
  33461. /**
  33462. * get an animation group using its name
  33463. * @param name defines the material's name
  33464. * @return the animation group or null if none found.
  33465. */
  33466. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33467. /**
  33468. * get a material using its id
  33469. * @param id defines the material's ID
  33470. * @return the material or null if none found.
  33471. */
  33472. getMaterialByID(id: string): Nullable<Material>;
  33473. /**
  33474. * Gets a material using its name
  33475. * @param name defines the material's name
  33476. * @return the material or null if none found.
  33477. */
  33478. getMaterialByName(name: string): Nullable<Material>;
  33479. /**
  33480. * Gets a camera using its id
  33481. * @param id defines the id to look for
  33482. * @returns the camera or null if not found
  33483. */
  33484. getCameraByID(id: string): Nullable<Camera>;
  33485. /**
  33486. * Gets a camera using its unique id
  33487. * @param uniqueId defines the unique id to look for
  33488. * @returns the camera or null if not found
  33489. */
  33490. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33491. /**
  33492. * Gets a camera using its name
  33493. * @param name defines the camera's name
  33494. * @return the camera or null if none found.
  33495. */
  33496. getCameraByName(name: string): Nullable<Camera>;
  33497. /**
  33498. * Gets a bone using its id
  33499. * @param id defines the bone's id
  33500. * @return the bone or null if not found
  33501. */
  33502. getBoneByID(id: string): Nullable<Bone>;
  33503. /**
  33504. * Gets a bone using its id
  33505. * @param name defines the bone's name
  33506. * @return the bone or null if not found
  33507. */
  33508. getBoneByName(name: string): Nullable<Bone>;
  33509. /**
  33510. * Gets a light node using its name
  33511. * @param name defines the the light's name
  33512. * @return the light or null if none found.
  33513. */
  33514. getLightByName(name: string): Nullable<Light>;
  33515. /**
  33516. * Gets a light node using its id
  33517. * @param id defines the light's id
  33518. * @return the light or null if none found.
  33519. */
  33520. getLightByID(id: string): Nullable<Light>;
  33521. /**
  33522. * Gets a light node using its scene-generated unique ID
  33523. * @param uniqueId defines the light's unique id
  33524. * @return the light or null if none found.
  33525. */
  33526. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33527. /**
  33528. * Gets a particle system by id
  33529. * @param id defines the particle system id
  33530. * @return the corresponding system or null if none found
  33531. */
  33532. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33533. /**
  33534. * Gets a geometry using its ID
  33535. * @param id defines the geometry's id
  33536. * @return the geometry or null if none found.
  33537. */
  33538. getGeometryByID(id: string): Nullable<Geometry>;
  33539. private _getGeometryByUniqueID;
  33540. /**
  33541. * Add a new geometry to this scene
  33542. * @param geometry defines the geometry to be added to the scene.
  33543. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33544. * @return a boolean defining if the geometry was added or not
  33545. */
  33546. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33547. /**
  33548. * Removes an existing geometry
  33549. * @param geometry defines the geometry to be removed from the scene
  33550. * @return a boolean defining if the geometry was removed or not
  33551. */
  33552. removeGeometry(geometry: Geometry): boolean;
  33553. /**
  33554. * Gets the list of geometries attached to the scene
  33555. * @returns an array of Geometry
  33556. */
  33557. getGeometries(): Geometry[];
  33558. /**
  33559. * Gets the first added mesh found of a given ID
  33560. * @param id defines the id to search for
  33561. * @return the mesh found or null if not found at all
  33562. */
  33563. getMeshByID(id: string): Nullable<AbstractMesh>;
  33564. /**
  33565. * Gets a list of meshes using their id
  33566. * @param id defines the id to search for
  33567. * @returns a list of meshes
  33568. */
  33569. getMeshesByID(id: string): Array<AbstractMesh>;
  33570. /**
  33571. * Gets the first added transform node found of a given ID
  33572. * @param id defines the id to search for
  33573. * @return the found transform node or null if not found at all.
  33574. */
  33575. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33576. /**
  33577. * Gets a list of transform nodes using their id
  33578. * @param id defines the id to search for
  33579. * @returns a list of transform nodes
  33580. */
  33581. getTransformNodesByID(id: string): Array<TransformNode>;
  33582. /**
  33583. * Gets a mesh with its auto-generated unique id
  33584. * @param uniqueId defines the unique id to search for
  33585. * @return the found mesh or null if not found at all.
  33586. */
  33587. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33588. /**
  33589. * Gets a the last added mesh using a given id
  33590. * @param id defines the id to search for
  33591. * @return the found mesh or null if not found at all.
  33592. */
  33593. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33594. /**
  33595. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33596. * @param id defines the id to search for
  33597. * @return the found node or null if not found at all
  33598. */
  33599. getLastEntryByID(id: string): Nullable<Node>;
  33600. /**
  33601. * Gets a node (Mesh, Camera, Light) using a given id
  33602. * @param id defines the id to search for
  33603. * @return the found node or null if not found at all
  33604. */
  33605. getNodeByID(id: string): Nullable<Node>;
  33606. /**
  33607. * Gets a node (Mesh, Camera, Light) using a given name
  33608. * @param name defines the name to search for
  33609. * @return the found node or null if not found at all.
  33610. */
  33611. getNodeByName(name: string): Nullable<Node>;
  33612. /**
  33613. * Gets a mesh using a given name
  33614. * @param name defines the name to search for
  33615. * @return the found mesh or null if not found at all.
  33616. */
  33617. getMeshByName(name: string): Nullable<AbstractMesh>;
  33618. /**
  33619. * Gets a transform node using a given name
  33620. * @param name defines the name to search for
  33621. * @return the found transform node or null if not found at all.
  33622. */
  33623. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33624. /**
  33625. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33626. * @param id defines the id to search for
  33627. * @return the found skeleton or null if not found at all.
  33628. */
  33629. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33630. /**
  33631. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33632. * @param id defines the id to search for
  33633. * @return the found skeleton or null if not found at all.
  33634. */
  33635. getSkeletonById(id: string): Nullable<Skeleton>;
  33636. /**
  33637. * Gets a skeleton using a given name
  33638. * @param name defines the name to search for
  33639. * @return the found skeleton or null if not found at all.
  33640. */
  33641. getSkeletonByName(name: string): Nullable<Skeleton>;
  33642. /**
  33643. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33644. * @param id defines the id to search for
  33645. * @return the found morph target manager or null if not found at all.
  33646. */
  33647. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33648. /**
  33649. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33650. * @param id defines the id to search for
  33651. * @return the found morph target or null if not found at all.
  33652. */
  33653. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33654. /**
  33655. * Gets a boolean indicating if the given mesh is active
  33656. * @param mesh defines the mesh to look for
  33657. * @returns true if the mesh is in the active list
  33658. */
  33659. isActiveMesh(mesh: AbstractMesh): boolean;
  33660. /**
  33661. * Return a unique id as a string which can serve as an identifier for the scene
  33662. */
  33663. readonly uid: string;
  33664. /**
  33665. * Add an externaly attached data from its key.
  33666. * This method call will fail and return false, if such key already exists.
  33667. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33668. * @param key the unique key that identifies the data
  33669. * @param data the data object to associate to the key for this Engine instance
  33670. * @return true if no such key were already present and the data was added successfully, false otherwise
  33671. */
  33672. addExternalData<T>(key: string, data: T): boolean;
  33673. /**
  33674. * Get an externaly attached data from its key
  33675. * @param key the unique key that identifies the data
  33676. * @return the associated data, if present (can be null), or undefined if not present
  33677. */
  33678. getExternalData<T>(key: string): Nullable<T>;
  33679. /**
  33680. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33681. * @param key the unique key that identifies the data
  33682. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33683. * @return the associated data, can be null if the factory returned null.
  33684. */
  33685. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33686. /**
  33687. * Remove an externaly attached data from the Engine instance
  33688. * @param key the unique key that identifies the data
  33689. * @return true if the data was successfully removed, false if it doesn't exist
  33690. */
  33691. removeExternalData(key: string): boolean;
  33692. private _evaluateSubMesh;
  33693. /**
  33694. * Clear the processed materials smart array preventing retention point in material dispose.
  33695. */
  33696. freeProcessedMaterials(): void;
  33697. private _preventFreeActiveMeshesAndRenderingGroups;
  33698. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33699. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33700. * when disposing several meshes in a row or a hierarchy of meshes.
  33701. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33702. */
  33703. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33704. /**
  33705. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33706. */
  33707. freeActiveMeshes(): void;
  33708. /**
  33709. * Clear the info related to rendering groups preventing retention points during dispose.
  33710. */
  33711. freeRenderingGroups(): void;
  33712. /** @hidden */
  33713. _isInIntermediateRendering(): boolean;
  33714. /**
  33715. * Lambda returning the list of potentially active meshes.
  33716. */
  33717. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33718. /**
  33719. * Lambda returning the list of potentially active sub meshes.
  33720. */
  33721. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33722. /**
  33723. * Lambda returning the list of potentially intersecting sub meshes.
  33724. */
  33725. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33726. /**
  33727. * Lambda returning the list of potentially colliding sub meshes.
  33728. */
  33729. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33730. private _activeMeshesFrozen;
  33731. /**
  33732. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33733. * @returns the current scene
  33734. */
  33735. freezeActiveMeshes(): Scene;
  33736. /**
  33737. * Use this function to restart evaluating active meshes on every frame
  33738. * @returns the current scene
  33739. */
  33740. unfreezeActiveMeshes(): Scene;
  33741. private _evaluateActiveMeshes;
  33742. private _activeMesh;
  33743. /**
  33744. * Update the transform matrix to update from the current active camera
  33745. * @param force defines a boolean used to force the update even if cache is up to date
  33746. */
  33747. updateTransformMatrix(force?: boolean): void;
  33748. /**
  33749. * 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)
  33750. * @param alternateCamera defines the camera to use
  33751. */
  33752. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33753. /** @hidden */
  33754. _allowPostProcessClearColor: boolean;
  33755. private _renderForCamera;
  33756. private _processSubCameras;
  33757. private _checkIntersections;
  33758. /** @hidden */
  33759. _advancePhysicsEngineStep(step: number): void;
  33760. /**
  33761. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33762. */
  33763. getDeterministicFrameTime: () => number;
  33764. /** @hidden */
  33765. _animate(): void;
  33766. /**
  33767. * Render the scene
  33768. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33769. */
  33770. render(updateCameras?: boolean): void;
  33771. /**
  33772. * Freeze all materials
  33773. * A frozen material will not be updatable but should be faster to render
  33774. */
  33775. freezeMaterials(): void;
  33776. /**
  33777. * Unfreeze all materials
  33778. * A frozen material will not be updatable but should be faster to render
  33779. */
  33780. unfreezeMaterials(): void;
  33781. /**
  33782. * Releases all held ressources
  33783. */
  33784. dispose(): void;
  33785. /**
  33786. * Gets if the scene is already disposed
  33787. */
  33788. readonly isDisposed: boolean;
  33789. /**
  33790. * Call this function to reduce memory footprint of the scene.
  33791. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33792. */
  33793. clearCachedVertexData(): void;
  33794. /**
  33795. * This function will remove the local cached buffer data from texture.
  33796. * It will save memory but will prevent the texture from being rebuilt
  33797. */
  33798. cleanCachedTextureBuffer(): void;
  33799. /**
  33800. * Get the world extend vectors with an optional filter
  33801. *
  33802. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33803. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33804. */
  33805. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33806. min: Vector3;
  33807. max: Vector3;
  33808. };
  33809. /**
  33810. * Creates a ray that can be used to pick in the scene
  33811. * @param x defines the x coordinate of the origin (on-screen)
  33812. * @param y defines the y coordinate of the origin (on-screen)
  33813. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33814. * @param camera defines the camera to use for the picking
  33815. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33816. * @returns a Ray
  33817. */
  33818. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33819. /**
  33820. * Creates a ray that can be used to pick in the scene
  33821. * @param x defines the x coordinate of the origin (on-screen)
  33822. * @param y defines the y coordinate of the origin (on-screen)
  33823. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33824. * @param result defines the ray where to store the picking ray
  33825. * @param camera defines the camera to use for the picking
  33826. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33827. * @returns the current scene
  33828. */
  33829. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33830. /**
  33831. * Creates a ray that can be used to pick in the scene
  33832. * @param x defines the x coordinate of the origin (on-screen)
  33833. * @param y defines the y coordinate of the origin (on-screen)
  33834. * @param camera defines the camera to use for the picking
  33835. * @returns a Ray
  33836. */
  33837. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33838. /**
  33839. * Creates a ray that can be used to pick in the scene
  33840. * @param x defines the x coordinate of the origin (on-screen)
  33841. * @param y defines the y coordinate of the origin (on-screen)
  33842. * @param result defines the ray where to store the picking ray
  33843. * @param camera defines the camera to use for the picking
  33844. * @returns the current scene
  33845. */
  33846. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33847. /** Launch a ray to try to pick a mesh in the scene
  33848. * @param x position on screen
  33849. * @param y position on screen
  33850. * @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
  33851. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33852. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33853. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33854. * @returns a PickingInfo
  33855. */
  33856. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33857. /** Use the given ray to pick a mesh in the scene
  33858. * @param ray The ray to use to pick meshes
  33859. * @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
  33860. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33861. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33862. * @returns a PickingInfo
  33863. */
  33864. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33865. /**
  33866. * Launch a ray to try to pick a mesh in the scene
  33867. * @param x X position on screen
  33868. * @param y Y position on screen
  33869. * @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
  33870. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33871. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33872. * @returns an array of PickingInfo
  33873. */
  33874. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33875. /**
  33876. * Launch a ray to try to pick a mesh in the scene
  33877. * @param ray Ray to use
  33878. * @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
  33879. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33880. * @returns an array of PickingInfo
  33881. */
  33882. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33883. /**
  33884. * Force the value of meshUnderPointer
  33885. * @param mesh defines the mesh to use
  33886. */
  33887. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33888. /**
  33889. * Gets the mesh under the pointer
  33890. * @returns a Mesh or null if no mesh is under the pointer
  33891. */
  33892. getPointerOverMesh(): Nullable<AbstractMesh>;
  33893. /** @hidden */
  33894. _rebuildGeometries(): void;
  33895. /** @hidden */
  33896. _rebuildTextures(): void;
  33897. private _getByTags;
  33898. /**
  33899. * Get a list of meshes by tags
  33900. * @param tagsQuery defines the tags query to use
  33901. * @param forEach defines a predicate used to filter results
  33902. * @returns an array of Mesh
  33903. */
  33904. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33905. /**
  33906. * Get a list of cameras by tags
  33907. * @param tagsQuery defines the tags query to use
  33908. * @param forEach defines a predicate used to filter results
  33909. * @returns an array of Camera
  33910. */
  33911. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33912. /**
  33913. * Get a list of lights by tags
  33914. * @param tagsQuery defines the tags query to use
  33915. * @param forEach defines a predicate used to filter results
  33916. * @returns an array of Light
  33917. */
  33918. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33919. /**
  33920. * Get a list of materials by tags
  33921. * @param tagsQuery defines the tags query to use
  33922. * @param forEach defines a predicate used to filter results
  33923. * @returns an array of Material
  33924. */
  33925. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33926. /**
  33927. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33928. * This allowed control for front to back rendering or reversly depending of the special needs.
  33929. *
  33930. * @param renderingGroupId The rendering group id corresponding to its index
  33931. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33932. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33933. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33934. */
  33935. 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;
  33936. /**
  33937. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33938. *
  33939. * @param renderingGroupId The rendering group id corresponding to its index
  33940. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33941. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33942. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33943. */
  33944. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33945. /**
  33946. * Gets the current auto clear configuration for one rendering group of the rendering
  33947. * manager.
  33948. * @param index the rendering group index to get the information for
  33949. * @returns The auto clear setup for the requested rendering group
  33950. */
  33951. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33952. private _blockMaterialDirtyMechanism;
  33953. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33954. blockMaterialDirtyMechanism: boolean;
  33955. /**
  33956. * Will flag all materials as dirty to trigger new shader compilation
  33957. * @param flag defines the flag used to specify which material part must be marked as dirty
  33958. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33959. */
  33960. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33961. /** @hidden */
  33962. _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;
  33963. /** @hidden */
  33964. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33965. }
  33966. }
  33967. declare module "babylonjs/assetContainer" {
  33968. import { AbstractScene } from "babylonjs/abstractScene";
  33969. import { Scene } from "babylonjs/scene";
  33970. import { Mesh } from "babylonjs/Meshes/mesh";
  33971. /**
  33972. * Set of assets to keep when moving a scene into an asset container.
  33973. */
  33974. export class KeepAssets extends AbstractScene {
  33975. }
  33976. /**
  33977. * Container with a set of assets that can be added or removed from a scene.
  33978. */
  33979. export class AssetContainer extends AbstractScene {
  33980. /**
  33981. * The scene the AssetContainer belongs to.
  33982. */
  33983. scene: Scene;
  33984. /**
  33985. * Instantiates an AssetContainer.
  33986. * @param scene The scene the AssetContainer belongs to.
  33987. */
  33988. constructor(scene: Scene);
  33989. /**
  33990. * Adds all the assets from the container to the scene.
  33991. */
  33992. addAllToScene(): void;
  33993. /**
  33994. * Removes all the assets in the container from the scene
  33995. */
  33996. removeAllFromScene(): void;
  33997. /**
  33998. * Disposes all the assets in the container
  33999. */
  34000. dispose(): void;
  34001. private _moveAssets;
  34002. /**
  34003. * Removes all the assets contained in the scene and adds them to the container.
  34004. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34005. */
  34006. moveAllFromScene(keepAssets?: KeepAssets): void;
  34007. /**
  34008. * 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.
  34009. * @returns the root mesh
  34010. */
  34011. createRootMesh(): Mesh;
  34012. }
  34013. }
  34014. declare module "babylonjs/abstractScene" {
  34015. import { Scene } from "babylonjs/scene";
  34016. import { Nullable } from "babylonjs/types";
  34017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34018. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34019. import { Geometry } from "babylonjs/Meshes/geometry";
  34020. import { Skeleton } from "babylonjs/Bones/skeleton";
  34021. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34022. import { AssetContainer } from "babylonjs/assetContainer";
  34023. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34024. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34025. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34026. import { Material } from "babylonjs/Materials/material";
  34027. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34028. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34029. import { Camera } from "babylonjs/Cameras/camera";
  34030. import { Light } from "babylonjs/Lights/light";
  34031. import { Node } from "babylonjs/node";
  34032. import { Animation } from "babylonjs/Animations/animation";
  34033. /**
  34034. * Defines how the parser contract is defined.
  34035. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34036. */
  34037. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34038. /**
  34039. * Defines how the individual parser contract is defined.
  34040. * These parser can parse an individual asset
  34041. */
  34042. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34043. /**
  34044. * Base class of the scene acting as a container for the different elements composing a scene.
  34045. * This class is dynamically extended by the different components of the scene increasing
  34046. * flexibility and reducing coupling
  34047. */
  34048. export abstract class AbstractScene {
  34049. /**
  34050. * Stores the list of available parsers in the application.
  34051. */
  34052. private static _BabylonFileParsers;
  34053. /**
  34054. * Stores the list of available individual parsers in the application.
  34055. */
  34056. private static _IndividualBabylonFileParsers;
  34057. /**
  34058. * Adds a parser in the list of available ones
  34059. * @param name Defines the name of the parser
  34060. * @param parser Defines the parser to add
  34061. */
  34062. static AddParser(name: string, parser: BabylonFileParser): void;
  34063. /**
  34064. * Gets a general parser from the list of avaialble ones
  34065. * @param name Defines the name of the parser
  34066. * @returns the requested parser or null
  34067. */
  34068. static GetParser(name: string): Nullable<BabylonFileParser>;
  34069. /**
  34070. * Adds n individual parser in the list of available ones
  34071. * @param name Defines the name of the parser
  34072. * @param parser Defines the parser to add
  34073. */
  34074. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34075. /**
  34076. * Gets an individual parser from the list of avaialble ones
  34077. * @param name Defines the name of the parser
  34078. * @returns the requested parser or null
  34079. */
  34080. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34081. /**
  34082. * Parser json data and populate both a scene and its associated container object
  34083. * @param jsonData Defines the data to parse
  34084. * @param scene Defines the scene to parse the data for
  34085. * @param container Defines the container attached to the parsing sequence
  34086. * @param rootUrl Defines the root url of the data
  34087. */
  34088. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34089. /**
  34090. * Gets the list of root nodes (ie. nodes with no parent)
  34091. */
  34092. rootNodes: Node[];
  34093. /** All of the cameras added to this scene
  34094. * @see http://doc.babylonjs.com/babylon101/cameras
  34095. */
  34096. cameras: Camera[];
  34097. /**
  34098. * All of the lights added to this scene
  34099. * @see http://doc.babylonjs.com/babylon101/lights
  34100. */
  34101. lights: Light[];
  34102. /**
  34103. * All of the (abstract) meshes added to this scene
  34104. */
  34105. meshes: AbstractMesh[];
  34106. /**
  34107. * The list of skeletons added to the scene
  34108. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34109. */
  34110. skeletons: Skeleton[];
  34111. /**
  34112. * All of the particle systems added to this scene
  34113. * @see http://doc.babylonjs.com/babylon101/particles
  34114. */
  34115. particleSystems: IParticleSystem[];
  34116. /**
  34117. * Gets a list of Animations associated with the scene
  34118. */
  34119. animations: Animation[];
  34120. /**
  34121. * All of the animation groups added to this scene
  34122. * @see http://doc.babylonjs.com/how_to/group
  34123. */
  34124. animationGroups: AnimationGroup[];
  34125. /**
  34126. * All of the multi-materials added to this scene
  34127. * @see http://doc.babylonjs.com/how_to/multi_materials
  34128. */
  34129. multiMaterials: MultiMaterial[];
  34130. /**
  34131. * All of the materials added to this scene
  34132. * In the context of a Scene, it is not supposed to be modified manually.
  34133. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34134. * Note also that the order of the Material wihin the array is not significant and might change.
  34135. * @see http://doc.babylonjs.com/babylon101/materials
  34136. */
  34137. materials: Material[];
  34138. /**
  34139. * The list of morph target managers added to the scene
  34140. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34141. */
  34142. morphTargetManagers: MorphTargetManager[];
  34143. /**
  34144. * The list of geometries used in the scene.
  34145. */
  34146. geometries: Geometry[];
  34147. /**
  34148. * All of the tranform nodes added to this scene
  34149. * In the context of a Scene, it is not supposed to be modified manually.
  34150. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34151. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34152. * @see http://doc.babylonjs.com/how_to/transformnode
  34153. */
  34154. transformNodes: TransformNode[];
  34155. /**
  34156. * ActionManagers available on the scene.
  34157. */
  34158. actionManagers: AbstractActionManager[];
  34159. /**
  34160. * Textures to keep.
  34161. */
  34162. textures: BaseTexture[];
  34163. }
  34164. }
  34165. declare module "babylonjs/Audio/sound" {
  34166. import { Observable } from "babylonjs/Misc/observable";
  34167. import { Vector3 } from "babylonjs/Maths/math";
  34168. import { Nullable } from "babylonjs/types";
  34169. import { Scene } from "babylonjs/scene";
  34170. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34171. /**
  34172. * Defines a sound that can be played in the application.
  34173. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34174. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34175. */
  34176. export class Sound {
  34177. /**
  34178. * The name of the sound in the scene.
  34179. */
  34180. name: string;
  34181. /**
  34182. * Does the sound autoplay once loaded.
  34183. */
  34184. autoplay: boolean;
  34185. /**
  34186. * Does the sound loop after it finishes playing once.
  34187. */
  34188. loop: boolean;
  34189. /**
  34190. * Does the sound use a custom attenuation curve to simulate the falloff
  34191. * happening when the source gets further away from the camera.
  34192. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34193. */
  34194. useCustomAttenuation: boolean;
  34195. /**
  34196. * The sound track id this sound belongs to.
  34197. */
  34198. soundTrackId: number;
  34199. /**
  34200. * Is this sound currently played.
  34201. */
  34202. isPlaying: boolean;
  34203. /**
  34204. * Is this sound currently paused.
  34205. */
  34206. isPaused: boolean;
  34207. /**
  34208. * Does this sound enables spatial sound.
  34209. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34210. */
  34211. spatialSound: boolean;
  34212. /**
  34213. * Define the reference distance the sound should be heard perfectly.
  34214. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34215. */
  34216. refDistance: number;
  34217. /**
  34218. * Define the roll off factor of spatial sounds.
  34219. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34220. */
  34221. rolloffFactor: number;
  34222. /**
  34223. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34224. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34225. */
  34226. maxDistance: number;
  34227. /**
  34228. * Define the distance attenuation model the sound will follow.
  34229. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34230. */
  34231. distanceModel: string;
  34232. /**
  34233. * @hidden
  34234. * Back Compat
  34235. **/
  34236. onended: () => any;
  34237. /**
  34238. * Observable event when the current playing sound finishes.
  34239. */
  34240. onEndedObservable: Observable<Sound>;
  34241. private _panningModel;
  34242. private _playbackRate;
  34243. private _streaming;
  34244. private _startTime;
  34245. private _startOffset;
  34246. private _position;
  34247. /** @hidden */
  34248. _positionInEmitterSpace: boolean;
  34249. private _localDirection;
  34250. private _volume;
  34251. private _isReadyToPlay;
  34252. private _isDirectional;
  34253. private _readyToPlayCallback;
  34254. private _audioBuffer;
  34255. private _soundSource;
  34256. private _streamingSource;
  34257. private _soundPanner;
  34258. private _soundGain;
  34259. private _inputAudioNode;
  34260. private _outputAudioNode;
  34261. private _coneInnerAngle;
  34262. private _coneOuterAngle;
  34263. private _coneOuterGain;
  34264. private _scene;
  34265. private _connectedTransformNode;
  34266. private _customAttenuationFunction;
  34267. private _registerFunc;
  34268. private _isOutputConnected;
  34269. private _htmlAudioElement;
  34270. private _urlType;
  34271. /** @hidden */
  34272. static _SceneComponentInitialization: (scene: Scene) => void;
  34273. /**
  34274. * Create a sound and attach it to a scene
  34275. * @param name Name of your sound
  34276. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34277. * @param scene defines the scene the sound belongs to
  34278. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34279. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34280. */
  34281. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34282. /**
  34283. * Release the sound and its associated resources
  34284. */
  34285. dispose(): void;
  34286. /**
  34287. * Gets if the sounds is ready to be played or not.
  34288. * @returns true if ready, otherwise false
  34289. */
  34290. isReady(): boolean;
  34291. private _soundLoaded;
  34292. /**
  34293. * Sets the data of the sound from an audiobuffer
  34294. * @param audioBuffer The audioBuffer containing the data
  34295. */
  34296. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34297. /**
  34298. * Updates the current sounds options such as maxdistance, loop...
  34299. * @param options A JSON object containing values named as the object properties
  34300. */
  34301. updateOptions(options: any): void;
  34302. private _createSpatialParameters;
  34303. private _updateSpatialParameters;
  34304. /**
  34305. * Switch the panning model to HRTF:
  34306. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34307. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34308. */
  34309. switchPanningModelToHRTF(): void;
  34310. /**
  34311. * Switch the panning model to Equal Power:
  34312. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34313. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34314. */
  34315. switchPanningModelToEqualPower(): void;
  34316. private _switchPanningModel;
  34317. /**
  34318. * Connect this sound to a sound track audio node like gain...
  34319. * @param soundTrackAudioNode the sound track audio node to connect to
  34320. */
  34321. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34322. /**
  34323. * Transform this sound into a directional source
  34324. * @param coneInnerAngle Size of the inner cone in degree
  34325. * @param coneOuterAngle Size of the outer cone in degree
  34326. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34327. */
  34328. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34329. /**
  34330. * Gets or sets the inner angle for the directional cone.
  34331. */
  34332. /**
  34333. * Gets or sets the inner angle for the directional cone.
  34334. */
  34335. directionalConeInnerAngle: number;
  34336. /**
  34337. * Gets or sets the outer angle for the directional cone.
  34338. */
  34339. /**
  34340. * Gets or sets the outer angle for the directional cone.
  34341. */
  34342. directionalConeOuterAngle: number;
  34343. /**
  34344. * Sets the position of the emitter if spatial sound is enabled
  34345. * @param newPosition Defines the new posisiton
  34346. */
  34347. setPosition(newPosition: Vector3): void;
  34348. /**
  34349. * Sets the local direction of the emitter if spatial sound is enabled
  34350. * @param newLocalDirection Defines the new local direction
  34351. */
  34352. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34353. private _updateDirection;
  34354. /** @hidden */
  34355. updateDistanceFromListener(): void;
  34356. /**
  34357. * Sets a new custom attenuation function for the sound.
  34358. * @param callback Defines the function used for the attenuation
  34359. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34360. */
  34361. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34362. /**
  34363. * Play the sound
  34364. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34365. * @param offset (optional) Start the sound setting it at a specific time
  34366. */
  34367. play(time?: number, offset?: number): void;
  34368. private _onended;
  34369. /**
  34370. * Stop the sound
  34371. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34372. */
  34373. stop(time?: number): void;
  34374. /**
  34375. * Put the sound in pause
  34376. */
  34377. pause(): void;
  34378. /**
  34379. * Sets a dedicated volume for this sounds
  34380. * @param newVolume Define the new volume of the sound
  34381. * @param time Define in how long the sound should be at this value
  34382. */
  34383. setVolume(newVolume: number, time?: number): void;
  34384. /**
  34385. * Set the sound play back rate
  34386. * @param newPlaybackRate Define the playback rate the sound should be played at
  34387. */
  34388. setPlaybackRate(newPlaybackRate: number): void;
  34389. /**
  34390. * Gets the volume of the sound.
  34391. * @returns the volume of the sound
  34392. */
  34393. getVolume(): number;
  34394. /**
  34395. * Attach the sound to a dedicated mesh
  34396. * @param transformNode The transform node to connect the sound with
  34397. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34398. */
  34399. attachToMesh(transformNode: TransformNode): void;
  34400. /**
  34401. * Detach the sound from the previously attached mesh
  34402. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34403. */
  34404. detachFromMesh(): void;
  34405. private _onRegisterAfterWorldMatrixUpdate;
  34406. /**
  34407. * Clone the current sound in the scene.
  34408. * @returns the new sound clone
  34409. */
  34410. clone(): Nullable<Sound>;
  34411. /**
  34412. * Gets the current underlying audio buffer containing the data
  34413. * @returns the audio buffer
  34414. */
  34415. getAudioBuffer(): Nullable<AudioBuffer>;
  34416. /**
  34417. * Serializes the Sound in a JSON representation
  34418. * @returns the JSON representation of the sound
  34419. */
  34420. serialize(): any;
  34421. /**
  34422. * Parse a JSON representation of a sound to innstantiate in a given scene
  34423. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34424. * @param scene Define the scene the new parsed sound should be created in
  34425. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34426. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34427. * @returns the newly parsed sound
  34428. */
  34429. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34430. }
  34431. }
  34432. declare module "babylonjs/Actions/directAudioActions" {
  34433. import { Action } from "babylonjs/Actions/action";
  34434. import { Condition } from "babylonjs/Actions/condition";
  34435. import { Sound } from "babylonjs/Audio/sound";
  34436. /**
  34437. * This defines an action helpful to play a defined sound on a triggered action.
  34438. */
  34439. export class PlaySoundAction extends Action {
  34440. private _sound;
  34441. /**
  34442. * Instantiate the action
  34443. * @param triggerOptions defines the trigger options
  34444. * @param sound defines the sound to play
  34445. * @param condition defines the trigger related conditions
  34446. */
  34447. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34448. /** @hidden */
  34449. _prepare(): void;
  34450. /**
  34451. * Execute the action and play the sound.
  34452. */
  34453. execute(): void;
  34454. /**
  34455. * Serializes the actions and its related information.
  34456. * @param parent defines the object to serialize in
  34457. * @returns the serialized object
  34458. */
  34459. serialize(parent: any): any;
  34460. }
  34461. /**
  34462. * This defines an action helpful to stop a defined sound on a triggered action.
  34463. */
  34464. export class StopSoundAction extends Action {
  34465. private _sound;
  34466. /**
  34467. * Instantiate the action
  34468. * @param triggerOptions defines the trigger options
  34469. * @param sound defines the sound to stop
  34470. * @param condition defines the trigger related conditions
  34471. */
  34472. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34473. /** @hidden */
  34474. _prepare(): void;
  34475. /**
  34476. * Execute the action and stop the sound.
  34477. */
  34478. execute(): void;
  34479. /**
  34480. * Serializes the actions and its related information.
  34481. * @param parent defines the object to serialize in
  34482. * @returns the serialized object
  34483. */
  34484. serialize(parent: any): any;
  34485. }
  34486. }
  34487. declare module "babylonjs/Actions/interpolateValueAction" {
  34488. import { Action } from "babylonjs/Actions/action";
  34489. import { Condition } from "babylonjs/Actions/condition";
  34490. import { Observable } from "babylonjs/Misc/observable";
  34491. /**
  34492. * This defines an action responsible to change the value of a property
  34493. * by interpolating between its current value and the newly set one once triggered.
  34494. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34495. */
  34496. export class InterpolateValueAction extends Action {
  34497. /**
  34498. * Defines the path of the property where the value should be interpolated
  34499. */
  34500. propertyPath: string;
  34501. /**
  34502. * Defines the target value at the end of the interpolation.
  34503. */
  34504. value: any;
  34505. /**
  34506. * Defines the time it will take for the property to interpolate to the value.
  34507. */
  34508. duration: number;
  34509. /**
  34510. * Defines if the other scene animations should be stopped when the action has been triggered
  34511. */
  34512. stopOtherAnimations?: boolean;
  34513. /**
  34514. * Defines a callback raised once the interpolation animation has been done.
  34515. */
  34516. onInterpolationDone?: () => void;
  34517. /**
  34518. * Observable triggered once the interpolation animation has been done.
  34519. */
  34520. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34521. private _target;
  34522. private _effectiveTarget;
  34523. private _property;
  34524. /**
  34525. * Instantiate the action
  34526. * @param triggerOptions defines the trigger options
  34527. * @param target defines the object containing the value to interpolate
  34528. * @param propertyPath defines the path to the property in the target object
  34529. * @param value defines the target value at the end of the interpolation
  34530. * @param duration deines the time it will take for the property to interpolate to the value.
  34531. * @param condition defines the trigger related conditions
  34532. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34533. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34534. */
  34535. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34536. /** @hidden */
  34537. _prepare(): void;
  34538. /**
  34539. * Execute the action starts the value interpolation.
  34540. */
  34541. execute(): void;
  34542. /**
  34543. * Serializes the actions and its related information.
  34544. * @param parent defines the object to serialize in
  34545. * @returns the serialized object
  34546. */
  34547. serialize(parent: any): any;
  34548. }
  34549. }
  34550. declare module "babylonjs/Actions/index" {
  34551. export * from "babylonjs/Actions/action";
  34552. export * from "babylonjs/Actions/actionEvent";
  34553. export * from "babylonjs/Actions/actionManager";
  34554. export * from "babylonjs/Actions/condition";
  34555. export * from "babylonjs/Actions/directActions";
  34556. export * from "babylonjs/Actions/directAudioActions";
  34557. export * from "babylonjs/Actions/interpolateValueAction";
  34558. }
  34559. declare module "babylonjs/Animations/index" {
  34560. export * from "babylonjs/Animations/animatable";
  34561. export * from "babylonjs/Animations/animation";
  34562. export * from "babylonjs/Animations/animationGroup";
  34563. export * from "babylonjs/Animations/animationPropertiesOverride";
  34564. export * from "babylonjs/Animations/easing";
  34565. export * from "babylonjs/Animations/runtimeAnimation";
  34566. export * from "babylonjs/Animations/animationEvent";
  34567. export * from "babylonjs/Animations/animationGroup";
  34568. export * from "babylonjs/Animations/animationKey";
  34569. export * from "babylonjs/Animations/animationRange";
  34570. }
  34571. declare module "babylonjs/Audio/soundTrack" {
  34572. import { Sound } from "babylonjs/Audio/sound";
  34573. import { Analyser } from "babylonjs/Audio/analyser";
  34574. import { Scene } from "babylonjs/scene";
  34575. /**
  34576. * Options allowed during the creation of a sound track.
  34577. */
  34578. export interface ISoundTrackOptions {
  34579. /**
  34580. * The volume the sound track should take during creation
  34581. */
  34582. volume?: number;
  34583. /**
  34584. * Define if the sound track is the main sound track of the scene
  34585. */
  34586. mainTrack?: boolean;
  34587. }
  34588. /**
  34589. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34590. * It will be also used in a future release to apply effects on a specific track.
  34591. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34592. */
  34593. export class SoundTrack {
  34594. /**
  34595. * The unique identifier of the sound track in the scene.
  34596. */
  34597. id: number;
  34598. /**
  34599. * The list of sounds included in the sound track.
  34600. */
  34601. soundCollection: Array<Sound>;
  34602. private _outputAudioNode;
  34603. private _scene;
  34604. private _isMainTrack;
  34605. private _connectedAnalyser;
  34606. private _options;
  34607. private _isInitialized;
  34608. /**
  34609. * Creates a new sound track.
  34610. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34611. * @param scene Define the scene the sound track belongs to
  34612. * @param options
  34613. */
  34614. constructor(scene: Scene, options?: ISoundTrackOptions);
  34615. private _initializeSoundTrackAudioGraph;
  34616. /**
  34617. * Release the sound track and its associated resources
  34618. */
  34619. dispose(): void;
  34620. /**
  34621. * Adds a sound to this sound track
  34622. * @param sound define the cound to add
  34623. * @ignoreNaming
  34624. */
  34625. AddSound(sound: Sound): void;
  34626. /**
  34627. * Removes a sound to this sound track
  34628. * @param sound define the cound to remove
  34629. * @ignoreNaming
  34630. */
  34631. RemoveSound(sound: Sound): void;
  34632. /**
  34633. * Set a global volume for the full sound track.
  34634. * @param newVolume Define the new volume of the sound track
  34635. */
  34636. setVolume(newVolume: number): void;
  34637. /**
  34638. * Switch the panning model to HRTF:
  34639. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34640. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34641. */
  34642. switchPanningModelToHRTF(): void;
  34643. /**
  34644. * Switch the panning model to Equal Power:
  34645. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34646. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34647. */
  34648. switchPanningModelToEqualPower(): void;
  34649. /**
  34650. * Connect the sound track to an audio analyser allowing some amazing
  34651. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34652. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34653. * @param analyser The analyser to connect to the engine
  34654. */
  34655. connectToAnalyser(analyser: Analyser): void;
  34656. }
  34657. }
  34658. declare module "babylonjs/Audio/audioSceneComponent" {
  34659. import { Sound } from "babylonjs/Audio/sound";
  34660. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34661. import { Nullable } from "babylonjs/types";
  34662. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34663. import { Scene } from "babylonjs/scene";
  34664. import { AbstractScene } from "babylonjs/abstractScene";
  34665. module "babylonjs/abstractScene" {
  34666. interface AbstractScene {
  34667. /**
  34668. * The list of sounds used in the scene.
  34669. */
  34670. sounds: Nullable<Array<Sound>>;
  34671. }
  34672. }
  34673. module "babylonjs/scene" {
  34674. interface Scene {
  34675. /**
  34676. * @hidden
  34677. * Backing field
  34678. */
  34679. _mainSoundTrack: SoundTrack;
  34680. /**
  34681. * The main sound track played by the scene.
  34682. * It cotains your primary collection of sounds.
  34683. */
  34684. mainSoundTrack: SoundTrack;
  34685. /**
  34686. * The list of sound tracks added to the scene
  34687. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34688. */
  34689. soundTracks: Nullable<Array<SoundTrack>>;
  34690. /**
  34691. * Gets a sound using a given name
  34692. * @param name defines the name to search for
  34693. * @return the found sound or null if not found at all.
  34694. */
  34695. getSoundByName(name: string): Nullable<Sound>;
  34696. /**
  34697. * Gets or sets if audio support is enabled
  34698. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34699. */
  34700. audioEnabled: boolean;
  34701. /**
  34702. * Gets or sets if audio will be output to headphones
  34703. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34704. */
  34705. headphone: boolean;
  34706. }
  34707. }
  34708. /**
  34709. * Defines the sound scene component responsible to manage any sounds
  34710. * in a given scene.
  34711. */
  34712. export class AudioSceneComponent implements ISceneSerializableComponent {
  34713. /**
  34714. * The component name helpfull to identify the component in the list of scene components.
  34715. */
  34716. readonly name: string;
  34717. /**
  34718. * The scene the component belongs to.
  34719. */
  34720. scene: Scene;
  34721. private _audioEnabled;
  34722. /**
  34723. * Gets whether audio is enabled or not.
  34724. * Please use related enable/disable method to switch state.
  34725. */
  34726. readonly audioEnabled: boolean;
  34727. private _headphone;
  34728. /**
  34729. * Gets whether audio is outputing to headphone or not.
  34730. * Please use the according Switch methods to change output.
  34731. */
  34732. readonly headphone: boolean;
  34733. /**
  34734. * Creates a new instance of the component for the given scene
  34735. * @param scene Defines the scene to register the component in
  34736. */
  34737. constructor(scene: Scene);
  34738. /**
  34739. * Registers the component in a given scene
  34740. */
  34741. register(): void;
  34742. /**
  34743. * Rebuilds the elements related to this component in case of
  34744. * context lost for instance.
  34745. */
  34746. rebuild(): void;
  34747. /**
  34748. * Serializes the component data to the specified json object
  34749. * @param serializationObject The object to serialize to
  34750. */
  34751. serialize(serializationObject: any): void;
  34752. /**
  34753. * Adds all the element from the container to the scene
  34754. * @param container the container holding the elements
  34755. */
  34756. addFromContainer(container: AbstractScene): void;
  34757. /**
  34758. * Removes all the elements in the container from the scene
  34759. * @param container contains the elements to remove
  34760. */
  34761. removeFromContainer(container: AbstractScene): void;
  34762. /**
  34763. * Disposes the component and the associated ressources.
  34764. */
  34765. dispose(): void;
  34766. /**
  34767. * Disables audio in the associated scene.
  34768. */
  34769. disableAudio(): void;
  34770. /**
  34771. * Enables audio in the associated scene.
  34772. */
  34773. enableAudio(): void;
  34774. /**
  34775. * Switch audio to headphone output.
  34776. */
  34777. switchAudioModeForHeadphones(): void;
  34778. /**
  34779. * Switch audio to normal speakers.
  34780. */
  34781. switchAudioModeForNormalSpeakers(): void;
  34782. private _afterRender;
  34783. }
  34784. }
  34785. declare module "babylonjs/Audio/weightedsound" {
  34786. import { Sound } from "babylonjs/Audio/sound";
  34787. /**
  34788. * Wraps one or more Sound objects and selects one with random weight for playback.
  34789. */
  34790. export class WeightedSound {
  34791. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34792. loop: boolean;
  34793. private _coneInnerAngle;
  34794. private _coneOuterAngle;
  34795. private _volume;
  34796. /** A Sound is currently playing. */
  34797. isPlaying: boolean;
  34798. /** A Sound is currently paused. */
  34799. isPaused: boolean;
  34800. private _sounds;
  34801. private _weights;
  34802. private _currentIndex?;
  34803. /**
  34804. * Creates a new WeightedSound from the list of sounds given.
  34805. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34806. * @param sounds Array of Sounds that will be selected from.
  34807. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34808. */
  34809. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34810. /**
  34811. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34812. */
  34813. /**
  34814. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34815. */
  34816. directionalConeInnerAngle: number;
  34817. /**
  34818. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34819. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34820. */
  34821. /**
  34822. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34823. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34824. */
  34825. directionalConeOuterAngle: number;
  34826. /**
  34827. * Playback volume.
  34828. */
  34829. /**
  34830. * Playback volume.
  34831. */
  34832. volume: number;
  34833. private _onended;
  34834. /**
  34835. * Suspend playback
  34836. */
  34837. pause(): void;
  34838. /**
  34839. * Stop playback
  34840. */
  34841. stop(): void;
  34842. /**
  34843. * Start playback.
  34844. * @param startOffset Position the clip head at a specific time in seconds.
  34845. */
  34846. play(startOffset?: number): void;
  34847. }
  34848. }
  34849. declare module "babylonjs/Audio/index" {
  34850. export * from "babylonjs/Audio/analyser";
  34851. export * from "babylonjs/Audio/audioEngine";
  34852. export * from "babylonjs/Audio/audioSceneComponent";
  34853. export * from "babylonjs/Audio/sound";
  34854. export * from "babylonjs/Audio/soundTrack";
  34855. export * from "babylonjs/Audio/weightedsound";
  34856. }
  34857. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34858. import { Behavior } from "babylonjs/Behaviors/behavior";
  34859. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34860. import { BackEase } from "babylonjs/Animations/easing";
  34861. /**
  34862. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34863. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34864. */
  34865. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34866. /**
  34867. * Gets the name of the behavior.
  34868. */
  34869. readonly name: string;
  34870. /**
  34871. * The easing function used by animations
  34872. */
  34873. static EasingFunction: BackEase;
  34874. /**
  34875. * The easing mode used by animations
  34876. */
  34877. static EasingMode: number;
  34878. /**
  34879. * The duration of the animation, in milliseconds
  34880. */
  34881. transitionDuration: number;
  34882. /**
  34883. * Length of the distance animated by the transition when lower radius is reached
  34884. */
  34885. lowerRadiusTransitionRange: number;
  34886. /**
  34887. * Length of the distance animated by the transition when upper radius is reached
  34888. */
  34889. upperRadiusTransitionRange: number;
  34890. private _autoTransitionRange;
  34891. /**
  34892. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34893. */
  34894. /**
  34895. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34896. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34897. */
  34898. autoTransitionRange: boolean;
  34899. private _attachedCamera;
  34900. private _onAfterCheckInputsObserver;
  34901. private _onMeshTargetChangedObserver;
  34902. /**
  34903. * Initializes the behavior.
  34904. */
  34905. init(): void;
  34906. /**
  34907. * Attaches the behavior to its arc rotate camera.
  34908. * @param camera Defines the camera to attach the behavior to
  34909. */
  34910. attach(camera: ArcRotateCamera): void;
  34911. /**
  34912. * Detaches the behavior from its current arc rotate camera.
  34913. */
  34914. detach(): void;
  34915. private _radiusIsAnimating;
  34916. private _radiusBounceTransition;
  34917. private _animatables;
  34918. private _cachedWheelPrecision;
  34919. /**
  34920. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34921. * @param radiusLimit The limit to check against.
  34922. * @return Bool to indicate if at limit.
  34923. */
  34924. private _isRadiusAtLimit;
  34925. /**
  34926. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34927. * @param radiusDelta The delta by which to animate to. Can be negative.
  34928. */
  34929. private _applyBoundRadiusAnimation;
  34930. /**
  34931. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34932. */
  34933. protected _clearAnimationLocks(): void;
  34934. /**
  34935. * Stops and removes all animations that have been applied to the camera
  34936. */
  34937. stopAllAnimations(): void;
  34938. }
  34939. }
  34940. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  34941. import { Behavior } from "babylonjs/Behaviors/behavior";
  34942. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34943. import { ExponentialEase } from "babylonjs/Animations/easing";
  34944. import { Nullable } from "babylonjs/types";
  34945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34946. import { Vector3 } from "babylonjs/Maths/math";
  34947. /**
  34948. * 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.
  34949. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34950. */
  34951. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34952. /**
  34953. * Gets the name of the behavior.
  34954. */
  34955. readonly name: string;
  34956. private _mode;
  34957. private _radiusScale;
  34958. private _positionScale;
  34959. private _defaultElevation;
  34960. private _elevationReturnTime;
  34961. private _elevationReturnWaitTime;
  34962. private _zoomStopsAnimation;
  34963. private _framingTime;
  34964. /**
  34965. * The easing function used by animations
  34966. */
  34967. static EasingFunction: ExponentialEase;
  34968. /**
  34969. * The easing mode used by animations
  34970. */
  34971. static EasingMode: number;
  34972. /**
  34973. * Sets the current mode used by the behavior
  34974. */
  34975. /**
  34976. * Gets current mode used by the behavior.
  34977. */
  34978. mode: number;
  34979. /**
  34980. * Sets the scale applied to the radius (1 by default)
  34981. */
  34982. /**
  34983. * Gets the scale applied to the radius
  34984. */
  34985. radiusScale: number;
  34986. /**
  34987. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34988. */
  34989. /**
  34990. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34991. */
  34992. positionScale: number;
  34993. /**
  34994. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34995. * behaviour is triggered, in radians.
  34996. */
  34997. /**
  34998. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34999. * behaviour is triggered, in radians.
  35000. */
  35001. defaultElevation: number;
  35002. /**
  35003. * Sets the time (in milliseconds) taken to return to the default beta position.
  35004. * Negative value indicates camera should not return to default.
  35005. */
  35006. /**
  35007. * Gets the time (in milliseconds) taken to return to the default beta position.
  35008. * Negative value indicates camera should not return to default.
  35009. */
  35010. elevationReturnTime: number;
  35011. /**
  35012. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35013. */
  35014. /**
  35015. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35016. */
  35017. elevationReturnWaitTime: number;
  35018. /**
  35019. * Sets the flag that indicates if user zooming should stop animation.
  35020. */
  35021. /**
  35022. * Gets the flag that indicates if user zooming should stop animation.
  35023. */
  35024. zoomStopsAnimation: boolean;
  35025. /**
  35026. * Sets the transition time when framing the mesh, in milliseconds
  35027. */
  35028. /**
  35029. * Gets the transition time when framing the mesh, in milliseconds
  35030. */
  35031. framingTime: number;
  35032. /**
  35033. * Define if the behavior should automatically change the configured
  35034. * camera limits and sensibilities.
  35035. */
  35036. autoCorrectCameraLimitsAndSensibility: boolean;
  35037. private _onPrePointerObservableObserver;
  35038. private _onAfterCheckInputsObserver;
  35039. private _onMeshTargetChangedObserver;
  35040. private _attachedCamera;
  35041. private _isPointerDown;
  35042. private _lastInteractionTime;
  35043. /**
  35044. * Initializes the behavior.
  35045. */
  35046. init(): void;
  35047. /**
  35048. * Attaches the behavior to its arc rotate camera.
  35049. * @param camera Defines the camera to attach the behavior to
  35050. */
  35051. attach(camera: ArcRotateCamera): void;
  35052. /**
  35053. * Detaches the behavior from its current arc rotate camera.
  35054. */
  35055. detach(): void;
  35056. private _animatables;
  35057. private _betaIsAnimating;
  35058. private _betaTransition;
  35059. private _radiusTransition;
  35060. private _vectorTransition;
  35061. /**
  35062. * Targets the given mesh and updates zoom level accordingly.
  35063. * @param mesh The mesh to target.
  35064. * @param radius Optional. If a cached radius position already exists, overrides default.
  35065. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35066. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35067. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35068. */
  35069. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35070. /**
  35071. * Targets the given mesh with its children and updates zoom level accordingly.
  35072. * @param mesh The mesh to target.
  35073. * @param radius Optional. If a cached radius position already exists, overrides default.
  35074. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35075. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35076. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35077. */
  35078. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35079. /**
  35080. * Targets the given meshes with their children and updates zoom level accordingly.
  35081. * @param meshes The mesh to target.
  35082. * @param radius Optional. If a cached radius position already exists, overrides default.
  35083. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35084. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35085. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35086. */
  35087. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35088. /**
  35089. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35090. * @param minimumWorld Determines the smaller position of the bounding box extend
  35091. * @param maximumWorld Determines the bigger position of the bounding box extend
  35092. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35093. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35094. */
  35095. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35096. /**
  35097. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35098. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35099. * frustum width.
  35100. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35101. * to fully enclose the mesh in the viewing frustum.
  35102. */
  35103. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35104. /**
  35105. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35106. * is automatically returned to its default position (expected to be above ground plane).
  35107. */
  35108. private _maintainCameraAboveGround;
  35109. /**
  35110. * Returns the frustum slope based on the canvas ratio and camera FOV
  35111. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35112. */
  35113. private _getFrustumSlope;
  35114. /**
  35115. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35116. */
  35117. private _clearAnimationLocks;
  35118. /**
  35119. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35120. */
  35121. private _applyUserInteraction;
  35122. /**
  35123. * Stops and removes all animations that have been applied to the camera
  35124. */
  35125. stopAllAnimations(): void;
  35126. /**
  35127. * Gets a value indicating if the user is moving the camera
  35128. */
  35129. readonly isUserIsMoving: boolean;
  35130. /**
  35131. * The camera can move all the way towards the mesh.
  35132. */
  35133. static IgnoreBoundsSizeMode: number;
  35134. /**
  35135. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35136. */
  35137. static FitFrustumSidesMode: number;
  35138. }
  35139. }
  35140. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35141. import { Nullable } from "babylonjs/types";
  35142. import { Camera } from "babylonjs/Cameras/camera";
  35143. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35144. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35145. /**
  35146. * Base class for Camera Pointer Inputs.
  35147. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35148. * for example usage.
  35149. */
  35150. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35151. /**
  35152. * Defines the camera the input is attached to.
  35153. */
  35154. abstract camera: Camera;
  35155. /**
  35156. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35157. */
  35158. protected _altKey: boolean;
  35159. protected _ctrlKey: boolean;
  35160. protected _metaKey: boolean;
  35161. protected _shiftKey: boolean;
  35162. /**
  35163. * Which mouse buttons were pressed at time of last mouse event.
  35164. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35165. */
  35166. protected _buttonsPressed: number;
  35167. /**
  35168. * Defines the buttons associated with the input to handle camera move.
  35169. */
  35170. buttons: number[];
  35171. /**
  35172. * Attach the input controls to a specific dom element to get the input from.
  35173. * @param element Defines the element the controls should be listened from
  35174. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35175. */
  35176. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35177. /**
  35178. * Detach the current controls from the specified dom element.
  35179. * @param element Defines the element to stop listening the inputs from
  35180. */
  35181. detachControl(element: Nullable<HTMLElement>): void;
  35182. /**
  35183. * Gets the class name of the current input.
  35184. * @returns the class name
  35185. */
  35186. getClassName(): string;
  35187. /**
  35188. * Get the friendly name associated with the input class.
  35189. * @returns the input friendly name
  35190. */
  35191. getSimpleName(): string;
  35192. /**
  35193. * Called on pointer POINTERDOUBLETAP event.
  35194. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35195. */
  35196. protected onDoubleTap(type: string): void;
  35197. /**
  35198. * Called on pointer POINTERMOVE event if only a single touch is active.
  35199. * Override this method to provide functionality.
  35200. */
  35201. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35202. /**
  35203. * Called on pointer POINTERMOVE event if multiple touches are active.
  35204. * Override this method to provide functionality.
  35205. */
  35206. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35207. /**
  35208. * Called on JS contextmenu event.
  35209. * Override this method to provide functionality.
  35210. */
  35211. protected onContextMenu(evt: PointerEvent): void;
  35212. /**
  35213. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35214. * press.
  35215. * Override this method to provide functionality.
  35216. */
  35217. protected onButtonDown(evt: PointerEvent): void;
  35218. /**
  35219. * Called each time a new POINTERUP event occurs. Ie, for each button
  35220. * release.
  35221. * Override this method to provide functionality.
  35222. */
  35223. protected onButtonUp(evt: PointerEvent): void;
  35224. /**
  35225. * Called when window becomes inactive.
  35226. * Override this method to provide functionality.
  35227. */
  35228. protected onLostFocus(): void;
  35229. private _pointerInput;
  35230. private _observer;
  35231. private _onLostFocus;
  35232. private pointA;
  35233. private pointB;
  35234. }
  35235. }
  35236. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35237. import { Nullable } from "babylonjs/types";
  35238. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35239. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35240. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35241. /**
  35242. * Manage the pointers inputs to control an arc rotate camera.
  35243. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35244. */
  35245. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35246. /**
  35247. * Defines the camera the input is attached to.
  35248. */
  35249. camera: ArcRotateCamera;
  35250. /**
  35251. * Gets the class name of the current input.
  35252. * @returns the class name
  35253. */
  35254. getClassName(): string;
  35255. /**
  35256. * Defines the buttons associated with the input to handle camera move.
  35257. */
  35258. buttons: number[];
  35259. /**
  35260. * Defines the pointer angular sensibility along the X axis or how fast is
  35261. * the camera rotating.
  35262. */
  35263. angularSensibilityX: number;
  35264. /**
  35265. * Defines the pointer angular sensibility along the Y axis or how fast is
  35266. * the camera rotating.
  35267. */
  35268. angularSensibilityY: number;
  35269. /**
  35270. * Defines the pointer pinch precision or how fast is the camera zooming.
  35271. */
  35272. pinchPrecision: number;
  35273. /**
  35274. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35275. * from 0.
  35276. * It defines the percentage of current camera.radius to use as delta when
  35277. * pinch zoom is used.
  35278. */
  35279. pinchDeltaPercentage: number;
  35280. /**
  35281. * Defines the pointer panning sensibility or how fast is the camera moving.
  35282. */
  35283. panningSensibility: number;
  35284. /**
  35285. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35286. */
  35287. multiTouchPanning: boolean;
  35288. /**
  35289. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35290. * zoom (pinch) through multitouch.
  35291. */
  35292. multiTouchPanAndZoom: boolean;
  35293. /**
  35294. * Revers pinch action direction.
  35295. */
  35296. pinchInwards: boolean;
  35297. private _isPanClick;
  35298. private _twoFingerActivityCount;
  35299. private _isPinching;
  35300. /**
  35301. * Called on pointer POINTERMOVE event if only a single touch is active.
  35302. */
  35303. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35304. /**
  35305. * Called on pointer POINTERDOUBLETAP event.
  35306. */
  35307. protected onDoubleTap(type: string): void;
  35308. /**
  35309. * Called on pointer POINTERMOVE event if multiple touches are active.
  35310. */
  35311. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35312. /**
  35313. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35314. * press.
  35315. */
  35316. protected onButtonDown(evt: PointerEvent): void;
  35317. /**
  35318. * Called each time a new POINTERUP event occurs. Ie, for each button
  35319. * release.
  35320. */
  35321. protected onButtonUp(evt: PointerEvent): void;
  35322. /**
  35323. * Called when window becomes inactive.
  35324. */
  35325. protected onLostFocus(): void;
  35326. }
  35327. }
  35328. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35329. import { Nullable } from "babylonjs/types";
  35330. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35331. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35332. /**
  35333. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35334. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35335. */
  35336. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35337. /**
  35338. * Defines the camera the input is attached to.
  35339. */
  35340. camera: ArcRotateCamera;
  35341. /**
  35342. * Defines the list of key codes associated with the up action (increase alpha)
  35343. */
  35344. keysUp: number[];
  35345. /**
  35346. * Defines the list of key codes associated with the down action (decrease alpha)
  35347. */
  35348. keysDown: number[];
  35349. /**
  35350. * Defines the list of key codes associated with the left action (increase beta)
  35351. */
  35352. keysLeft: number[];
  35353. /**
  35354. * Defines the list of key codes associated with the right action (decrease beta)
  35355. */
  35356. keysRight: number[];
  35357. /**
  35358. * Defines the list of key codes associated with the reset action.
  35359. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35360. */
  35361. keysReset: number[];
  35362. /**
  35363. * Defines the panning sensibility of the inputs.
  35364. * (How fast is the camera paning)
  35365. */
  35366. panningSensibility: number;
  35367. /**
  35368. * Defines the zooming sensibility of the inputs.
  35369. * (How fast is the camera zooming)
  35370. */
  35371. zoomingSensibility: number;
  35372. /**
  35373. * Defines wether maintaining the alt key down switch the movement mode from
  35374. * orientation to zoom.
  35375. */
  35376. useAltToZoom: boolean;
  35377. /**
  35378. * Rotation speed of the camera
  35379. */
  35380. angularSpeed: number;
  35381. private _keys;
  35382. private _ctrlPressed;
  35383. private _altPressed;
  35384. private _onCanvasBlurObserver;
  35385. private _onKeyboardObserver;
  35386. private _engine;
  35387. private _scene;
  35388. /**
  35389. * Attach the input controls to a specific dom element to get the input from.
  35390. * @param element Defines the element the controls should be listened from
  35391. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35392. */
  35393. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35394. /**
  35395. * Detach the current controls from the specified dom element.
  35396. * @param element Defines the element to stop listening the inputs from
  35397. */
  35398. detachControl(element: Nullable<HTMLElement>): void;
  35399. /**
  35400. * Update the current camera state depending on the inputs that have been used this frame.
  35401. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35402. */
  35403. checkInputs(): void;
  35404. /**
  35405. * Gets the class name of the current intput.
  35406. * @returns the class name
  35407. */
  35408. getClassName(): string;
  35409. /**
  35410. * Get the friendly name associated with the input class.
  35411. * @returns the input friendly name
  35412. */
  35413. getSimpleName(): string;
  35414. }
  35415. }
  35416. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35417. import { Nullable } from "babylonjs/types";
  35418. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35419. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35420. /**
  35421. * Manage the mouse wheel inputs to control an arc rotate camera.
  35422. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35423. */
  35424. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35425. /**
  35426. * Defines the camera the input is attached to.
  35427. */
  35428. camera: ArcRotateCamera;
  35429. /**
  35430. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35431. */
  35432. wheelPrecision: number;
  35433. /**
  35434. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35435. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35436. */
  35437. wheelDeltaPercentage: number;
  35438. private _wheel;
  35439. private _observer;
  35440. /**
  35441. * Attach the input controls to a specific dom element to get the input from.
  35442. * @param element Defines the element the controls should be listened from
  35443. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35444. */
  35445. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35446. /**
  35447. * Detach the current controls from the specified dom element.
  35448. * @param element Defines the element to stop listening the inputs from
  35449. */
  35450. detachControl(element: Nullable<HTMLElement>): void;
  35451. /**
  35452. * Gets the class name of the current intput.
  35453. * @returns the class name
  35454. */
  35455. getClassName(): string;
  35456. /**
  35457. * Get the friendly name associated with the input class.
  35458. * @returns the input friendly name
  35459. */
  35460. getSimpleName(): string;
  35461. }
  35462. }
  35463. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35464. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35465. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35466. /**
  35467. * Default Inputs manager for the ArcRotateCamera.
  35468. * It groups all the default supported inputs for ease of use.
  35469. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35470. */
  35471. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35472. /**
  35473. * Instantiates a new ArcRotateCameraInputsManager.
  35474. * @param camera Defines the camera the inputs belong to
  35475. */
  35476. constructor(camera: ArcRotateCamera);
  35477. /**
  35478. * Add mouse wheel input support to the input manager.
  35479. * @returns the current input manager
  35480. */
  35481. addMouseWheel(): ArcRotateCameraInputsManager;
  35482. /**
  35483. * Add pointers input support to the input manager.
  35484. * @returns the current input manager
  35485. */
  35486. addPointers(): ArcRotateCameraInputsManager;
  35487. /**
  35488. * Add keyboard input support to the input manager.
  35489. * @returns the current input manager
  35490. */
  35491. addKeyboard(): ArcRotateCameraInputsManager;
  35492. }
  35493. }
  35494. declare module "babylonjs/Cameras/arcRotateCamera" {
  35495. import { Observable } from "babylonjs/Misc/observable";
  35496. import { Nullable } from "babylonjs/types";
  35497. import { Scene } from "babylonjs/scene";
  35498. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35499. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35500. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35501. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35502. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35503. import { Camera } from "babylonjs/Cameras/camera";
  35504. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35505. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35506. import { Collider } from "babylonjs/Collisions/collider";
  35507. /**
  35508. * This represents an orbital type of camera.
  35509. *
  35510. * 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.
  35511. * 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.
  35512. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35513. */
  35514. export class ArcRotateCamera extends TargetCamera {
  35515. /**
  35516. * Defines the rotation angle of the camera along the longitudinal axis.
  35517. */
  35518. alpha: number;
  35519. /**
  35520. * Defines the rotation angle of the camera along the latitudinal axis.
  35521. */
  35522. beta: number;
  35523. /**
  35524. * Defines the radius of the camera from it s target point.
  35525. */
  35526. radius: number;
  35527. protected _target: Vector3;
  35528. protected _targetHost: Nullable<AbstractMesh>;
  35529. /**
  35530. * Defines the target point of the camera.
  35531. * The camera looks towards it form the radius distance.
  35532. */
  35533. target: Vector3;
  35534. /**
  35535. * Define the current local position of the camera in the scene
  35536. */
  35537. position: Vector3;
  35538. /**
  35539. * Current inertia value on the longitudinal axis.
  35540. * The bigger this number the longer it will take for the camera to stop.
  35541. */
  35542. inertialAlphaOffset: number;
  35543. /**
  35544. * Current inertia value on the latitudinal axis.
  35545. * The bigger this number the longer it will take for the camera to stop.
  35546. */
  35547. inertialBetaOffset: number;
  35548. /**
  35549. * Current inertia value on the radius axis.
  35550. * The bigger this number the longer it will take for the camera to stop.
  35551. */
  35552. inertialRadiusOffset: number;
  35553. /**
  35554. * Minimum allowed angle on the longitudinal axis.
  35555. * This can help limiting how the Camera is able to move in the scene.
  35556. */
  35557. lowerAlphaLimit: Nullable<number>;
  35558. /**
  35559. * Maximum allowed angle on the longitudinal axis.
  35560. * This can help limiting how the Camera is able to move in the scene.
  35561. */
  35562. upperAlphaLimit: Nullable<number>;
  35563. /**
  35564. * Minimum allowed angle on the latitudinal axis.
  35565. * This can help limiting how the Camera is able to move in the scene.
  35566. */
  35567. lowerBetaLimit: number;
  35568. /**
  35569. * Maximum allowed angle on the latitudinal axis.
  35570. * This can help limiting how the Camera is able to move in the scene.
  35571. */
  35572. upperBetaLimit: number;
  35573. /**
  35574. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35575. * This can help limiting how the Camera is able to move in the scene.
  35576. */
  35577. lowerRadiusLimit: Nullable<number>;
  35578. /**
  35579. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35580. * This can help limiting how the Camera is able to move in the scene.
  35581. */
  35582. upperRadiusLimit: Nullable<number>;
  35583. /**
  35584. * Defines the current inertia value used during panning of the camera along the X axis.
  35585. */
  35586. inertialPanningX: number;
  35587. /**
  35588. * Defines the current inertia value used during panning of the camera along the Y axis.
  35589. */
  35590. inertialPanningY: number;
  35591. /**
  35592. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35593. * Basically if your fingers moves away from more than this distance you will be considered
  35594. * in pinch mode.
  35595. */
  35596. pinchToPanMaxDistance: number;
  35597. /**
  35598. * Defines the maximum distance the camera can pan.
  35599. * This could help keeping the cammera always in your scene.
  35600. */
  35601. panningDistanceLimit: Nullable<number>;
  35602. /**
  35603. * Defines the target of the camera before paning.
  35604. */
  35605. panningOriginTarget: Vector3;
  35606. /**
  35607. * Defines the value of the inertia used during panning.
  35608. * 0 would mean stop inertia and one would mean no decelleration at all.
  35609. */
  35610. panningInertia: number;
  35611. /**
  35612. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35613. */
  35614. angularSensibilityX: number;
  35615. /**
  35616. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35617. */
  35618. angularSensibilityY: number;
  35619. /**
  35620. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35621. */
  35622. pinchPrecision: number;
  35623. /**
  35624. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35625. * It will be used instead of pinchDeltaPrecision if different from 0.
  35626. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35627. */
  35628. pinchDeltaPercentage: number;
  35629. /**
  35630. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35631. */
  35632. panningSensibility: number;
  35633. /**
  35634. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35635. */
  35636. keysUp: number[];
  35637. /**
  35638. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35639. */
  35640. keysDown: number[];
  35641. /**
  35642. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35643. */
  35644. keysLeft: number[];
  35645. /**
  35646. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35647. */
  35648. keysRight: number[];
  35649. /**
  35650. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35651. */
  35652. wheelPrecision: number;
  35653. /**
  35654. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35655. * It will be used instead of pinchDeltaPrecision if different from 0.
  35656. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35657. */
  35658. wheelDeltaPercentage: number;
  35659. /**
  35660. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35661. */
  35662. zoomOnFactor: number;
  35663. /**
  35664. * Defines a screen offset for the camera position.
  35665. */
  35666. targetScreenOffset: Vector2;
  35667. /**
  35668. * Allows the camera to be completely reversed.
  35669. * If false the camera can not arrive upside down.
  35670. */
  35671. allowUpsideDown: boolean;
  35672. /**
  35673. * Define if double tap/click is used to restore the previously saved state of the camera.
  35674. */
  35675. useInputToRestoreState: boolean;
  35676. /** @hidden */
  35677. _viewMatrix: Matrix;
  35678. /** @hidden */
  35679. _useCtrlForPanning: boolean;
  35680. /** @hidden */
  35681. _panningMouseButton: number;
  35682. /**
  35683. * Defines the input associated to the camera.
  35684. */
  35685. inputs: ArcRotateCameraInputsManager;
  35686. /** @hidden */
  35687. _reset: () => void;
  35688. /**
  35689. * Defines the allowed panning axis.
  35690. */
  35691. panningAxis: Vector3;
  35692. protected _localDirection: Vector3;
  35693. protected _transformedDirection: Vector3;
  35694. private _bouncingBehavior;
  35695. /**
  35696. * Gets the bouncing behavior of the camera if it has been enabled.
  35697. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35698. */
  35699. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35700. /**
  35701. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35702. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35703. */
  35704. useBouncingBehavior: boolean;
  35705. private _framingBehavior;
  35706. /**
  35707. * Gets the framing behavior of the camera if it has been enabled.
  35708. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35709. */
  35710. readonly framingBehavior: Nullable<FramingBehavior>;
  35711. /**
  35712. * Defines if the framing behavior of the camera is enabled on the camera.
  35713. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35714. */
  35715. useFramingBehavior: boolean;
  35716. private _autoRotationBehavior;
  35717. /**
  35718. * Gets the auto rotation behavior of the camera if it has been enabled.
  35719. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35720. */
  35721. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35722. /**
  35723. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35724. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35725. */
  35726. useAutoRotationBehavior: boolean;
  35727. /**
  35728. * Observable triggered when the mesh target has been changed on the camera.
  35729. */
  35730. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35731. /**
  35732. * Event raised when the camera is colliding with a mesh.
  35733. */
  35734. onCollide: (collidedMesh: AbstractMesh) => void;
  35735. /**
  35736. * Defines whether the camera should check collision with the objects oh the scene.
  35737. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35738. */
  35739. checkCollisions: boolean;
  35740. /**
  35741. * Defines the collision radius of the camera.
  35742. * This simulates a sphere around the camera.
  35743. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35744. */
  35745. collisionRadius: Vector3;
  35746. protected _collider: Collider;
  35747. protected _previousPosition: Vector3;
  35748. protected _collisionVelocity: Vector3;
  35749. protected _newPosition: Vector3;
  35750. protected _previousAlpha: number;
  35751. protected _previousBeta: number;
  35752. protected _previousRadius: number;
  35753. protected _collisionTriggered: boolean;
  35754. protected _targetBoundingCenter: Nullable<Vector3>;
  35755. private _computationVector;
  35756. private _tempAxisVector;
  35757. private _tempAxisRotationMatrix;
  35758. /**
  35759. * Instantiates a new ArcRotateCamera in a given scene
  35760. * @param name Defines the name of the camera
  35761. * @param alpha Defines the camera rotation along the logitudinal axis
  35762. * @param beta Defines the camera rotation along the latitudinal axis
  35763. * @param radius Defines the camera distance from its target
  35764. * @param target Defines the camera target
  35765. * @param scene Defines the scene the camera belongs to
  35766. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35767. */
  35768. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35769. /** @hidden */
  35770. _initCache(): void;
  35771. /** @hidden */
  35772. _updateCache(ignoreParentClass?: boolean): void;
  35773. protected _getTargetPosition(): Vector3;
  35774. private _storedAlpha;
  35775. private _storedBeta;
  35776. private _storedRadius;
  35777. private _storedTarget;
  35778. /**
  35779. * Stores the current state of the camera (alpha, beta, radius and target)
  35780. * @returns the camera itself
  35781. */
  35782. storeState(): Camera;
  35783. /**
  35784. * @hidden
  35785. * Restored camera state. You must call storeState() first
  35786. */
  35787. _restoreStateValues(): boolean;
  35788. /** @hidden */
  35789. _isSynchronizedViewMatrix(): boolean;
  35790. /**
  35791. * Attached controls to the current camera.
  35792. * @param element Defines the element the controls should be listened from
  35793. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35794. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35795. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35796. */
  35797. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35798. /**
  35799. * Detach the current controls from the camera.
  35800. * The camera will stop reacting to inputs.
  35801. * @param element Defines the element to stop listening the inputs from
  35802. */
  35803. detachControl(element: HTMLElement): void;
  35804. /** @hidden */
  35805. _checkInputs(): void;
  35806. protected _checkLimits(): void;
  35807. /**
  35808. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35809. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  35810. */
  35811. rebuildAnglesAndRadius(updateView?: boolean): void;
  35812. /**
  35813. * Use a position to define the current camera related information like aplha, beta and radius
  35814. * @param position Defines the position to set the camera at
  35815. */
  35816. setPosition(position: Vector3): void;
  35817. /**
  35818. * Defines the target the camera should look at.
  35819. * This will automatically adapt alpha beta and radius to fit within the new target.
  35820. * @param target Defines the new target as a Vector or a mesh
  35821. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35822. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35823. */
  35824. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35825. /** @hidden */
  35826. _getViewMatrix(): Matrix;
  35827. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35828. /**
  35829. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35830. * @param meshes Defines the mesh to zoom on
  35831. * @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)
  35832. */
  35833. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35834. /**
  35835. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35836. * The target will be changed but the radius
  35837. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35838. * @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)
  35839. */
  35840. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35841. min: Vector3;
  35842. max: Vector3;
  35843. distance: number;
  35844. }, doNotUpdateMaxZ?: boolean): void;
  35845. /**
  35846. * @override
  35847. * Override Camera.createRigCamera
  35848. */
  35849. createRigCamera(name: string, cameraIndex: number): Camera;
  35850. /**
  35851. * @hidden
  35852. * @override
  35853. * Override Camera._updateRigCameras
  35854. */
  35855. _updateRigCameras(): void;
  35856. /**
  35857. * Destroy the camera and release the current resources hold by it.
  35858. */
  35859. dispose(): void;
  35860. /**
  35861. * Gets the current object class name.
  35862. * @return the class name
  35863. */
  35864. getClassName(): string;
  35865. }
  35866. }
  35867. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35868. import { Behavior } from "babylonjs/Behaviors/behavior";
  35869. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35870. /**
  35871. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35872. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35873. */
  35874. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35875. /**
  35876. * Gets the name of the behavior.
  35877. */
  35878. readonly name: string;
  35879. private _zoomStopsAnimation;
  35880. private _idleRotationSpeed;
  35881. private _idleRotationWaitTime;
  35882. private _idleRotationSpinupTime;
  35883. /**
  35884. * Sets the flag that indicates if user zooming should stop animation.
  35885. */
  35886. /**
  35887. * Gets the flag that indicates if user zooming should stop animation.
  35888. */
  35889. zoomStopsAnimation: boolean;
  35890. /**
  35891. * Sets the default speed at which the camera rotates around the model.
  35892. */
  35893. /**
  35894. * Gets the default speed at which the camera rotates around the model.
  35895. */
  35896. idleRotationSpeed: number;
  35897. /**
  35898. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35899. */
  35900. /**
  35901. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35902. */
  35903. idleRotationWaitTime: number;
  35904. /**
  35905. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35906. */
  35907. /**
  35908. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35909. */
  35910. idleRotationSpinupTime: number;
  35911. /**
  35912. * Gets a value indicating if the camera is currently rotating because of this behavior
  35913. */
  35914. readonly rotationInProgress: boolean;
  35915. private _onPrePointerObservableObserver;
  35916. private _onAfterCheckInputsObserver;
  35917. private _attachedCamera;
  35918. private _isPointerDown;
  35919. private _lastFrameTime;
  35920. private _lastInteractionTime;
  35921. private _cameraRotationSpeed;
  35922. /**
  35923. * Initializes the behavior.
  35924. */
  35925. init(): void;
  35926. /**
  35927. * Attaches the behavior to its arc rotate camera.
  35928. * @param camera Defines the camera to attach the behavior to
  35929. */
  35930. attach(camera: ArcRotateCamera): void;
  35931. /**
  35932. * Detaches the behavior from its current arc rotate camera.
  35933. */
  35934. detach(): void;
  35935. /**
  35936. * Returns true if user is scrolling.
  35937. * @return true if user is scrolling.
  35938. */
  35939. private _userIsZooming;
  35940. private _lastFrameRadius;
  35941. private _shouldAnimationStopForInteraction;
  35942. /**
  35943. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35944. */
  35945. private _applyUserInteraction;
  35946. private _userIsMoving;
  35947. }
  35948. }
  35949. declare module "babylonjs/Behaviors/Cameras/index" {
  35950. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35951. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35952. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  35953. }
  35954. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  35955. import { Mesh } from "babylonjs/Meshes/mesh";
  35956. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35957. import { Behavior } from "babylonjs/Behaviors/behavior";
  35958. /**
  35959. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35960. */
  35961. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35962. private ui;
  35963. /**
  35964. * The name of the behavior
  35965. */
  35966. name: string;
  35967. /**
  35968. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35969. */
  35970. distanceAwayFromFace: number;
  35971. /**
  35972. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35973. */
  35974. distanceAwayFromBottomOfFace: number;
  35975. private _faceVectors;
  35976. private _target;
  35977. private _scene;
  35978. private _onRenderObserver;
  35979. private _tmpMatrix;
  35980. private _tmpVector;
  35981. /**
  35982. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35983. * @param ui The transform node that should be attched to the mesh
  35984. */
  35985. constructor(ui: TransformNode);
  35986. /**
  35987. * Initializes the behavior
  35988. */
  35989. init(): void;
  35990. private _closestFace;
  35991. private _zeroVector;
  35992. private _lookAtTmpMatrix;
  35993. private _lookAtToRef;
  35994. /**
  35995. * Attaches the AttachToBoxBehavior to the passed in mesh
  35996. * @param target The mesh that the specified node will be attached to
  35997. */
  35998. attach(target: Mesh): void;
  35999. /**
  36000. * Detaches the behavior from the mesh
  36001. */
  36002. detach(): void;
  36003. }
  36004. }
  36005. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36006. import { Behavior } from "babylonjs/Behaviors/behavior";
  36007. import { Mesh } from "babylonjs/Meshes/mesh";
  36008. /**
  36009. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36010. */
  36011. export class FadeInOutBehavior implements Behavior<Mesh> {
  36012. /**
  36013. * Time in milliseconds to delay before fading in (Default: 0)
  36014. */
  36015. delay: number;
  36016. /**
  36017. * Time in milliseconds for the mesh to fade in (Default: 300)
  36018. */
  36019. fadeInTime: number;
  36020. private _millisecondsPerFrame;
  36021. private _hovered;
  36022. private _hoverValue;
  36023. private _ownerNode;
  36024. /**
  36025. * Instatiates the FadeInOutBehavior
  36026. */
  36027. constructor();
  36028. /**
  36029. * The name of the behavior
  36030. */
  36031. readonly name: string;
  36032. /**
  36033. * Initializes the behavior
  36034. */
  36035. init(): void;
  36036. /**
  36037. * Attaches the fade behavior on the passed in mesh
  36038. * @param ownerNode The mesh that will be faded in/out once attached
  36039. */
  36040. attach(ownerNode: Mesh): void;
  36041. /**
  36042. * Detaches the behavior from the mesh
  36043. */
  36044. detach(): void;
  36045. /**
  36046. * Triggers the mesh to begin fading in or out
  36047. * @param value if the object should fade in or out (true to fade in)
  36048. */
  36049. fadeIn(value: boolean): void;
  36050. private _update;
  36051. private _setAllVisibility;
  36052. }
  36053. }
  36054. declare module "babylonjs/Misc/pivotTools" {
  36055. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36056. /**
  36057. * Class containing a set of static utilities functions for managing Pivots
  36058. * @hidden
  36059. */
  36060. export class PivotTools {
  36061. private static _PivotCached;
  36062. private static _OldPivotPoint;
  36063. private static _PivotTranslation;
  36064. private static _PivotTmpVector;
  36065. /** @hidden */
  36066. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36067. /** @hidden */
  36068. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36069. }
  36070. }
  36071. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36072. import { Scene } from "babylonjs/scene";
  36073. import { Vector4, Plane } from "babylonjs/Maths/math";
  36074. import { Mesh } from "babylonjs/Meshes/mesh";
  36075. /**
  36076. * Class containing static functions to help procedurally build meshes
  36077. */
  36078. export class PlaneBuilder {
  36079. /**
  36080. * Creates a plane mesh
  36081. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36082. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36083. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36084. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36085. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36087. * @param name defines the name of the mesh
  36088. * @param options defines the options used to create the mesh
  36089. * @param scene defines the hosting scene
  36090. * @returns the plane mesh
  36091. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36092. */
  36093. static CreatePlane(name: string, options: {
  36094. size?: number;
  36095. width?: number;
  36096. height?: number;
  36097. sideOrientation?: number;
  36098. frontUVs?: Vector4;
  36099. backUVs?: Vector4;
  36100. updatable?: boolean;
  36101. sourcePlane?: Plane;
  36102. }, scene: Scene): Mesh;
  36103. }
  36104. }
  36105. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36106. import { Behavior } from "babylonjs/Behaviors/behavior";
  36107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36108. import { Observable } from "babylonjs/Misc/observable";
  36109. import { Vector3 } from "babylonjs/Maths/math";
  36110. import { Ray } from "babylonjs/Culling/ray";
  36111. import "babylonjs/Meshes/Builders/planeBuilder";
  36112. /**
  36113. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36114. */
  36115. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36116. private static _AnyMouseID;
  36117. private _attachedNode;
  36118. private _dragPlane;
  36119. private _scene;
  36120. private _pointerObserver;
  36121. private _beforeRenderObserver;
  36122. private static _planeScene;
  36123. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36124. /**
  36125. * 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)
  36126. */
  36127. maxDragAngle: number;
  36128. /**
  36129. * @hidden
  36130. */
  36131. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36132. /**
  36133. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36134. */
  36135. currentDraggingPointerID: number;
  36136. /**
  36137. * The last position where the pointer hit the drag plane in world space
  36138. */
  36139. lastDragPosition: Vector3;
  36140. /**
  36141. * If the behavior is currently in a dragging state
  36142. */
  36143. dragging: boolean;
  36144. /**
  36145. * 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)
  36146. */
  36147. dragDeltaRatio: number;
  36148. /**
  36149. * If the drag plane orientation should be updated during the dragging (Default: true)
  36150. */
  36151. updateDragPlane: boolean;
  36152. private _debugMode;
  36153. private _moving;
  36154. /**
  36155. * Fires each time the attached mesh is dragged with the pointer
  36156. * * delta between last drag position and current drag position in world space
  36157. * * dragDistance along the drag axis
  36158. * * dragPlaneNormal normal of the current drag plane used during the drag
  36159. * * dragPlanePoint in world space where the drag intersects the drag plane
  36160. */
  36161. onDragObservable: Observable<{
  36162. delta: Vector3;
  36163. dragPlanePoint: Vector3;
  36164. dragPlaneNormal: Vector3;
  36165. dragDistance: number;
  36166. pointerId: number;
  36167. }>;
  36168. /**
  36169. * Fires each time a drag begins (eg. mouse down on mesh)
  36170. */
  36171. onDragStartObservable: Observable<{
  36172. dragPlanePoint: Vector3;
  36173. pointerId: number;
  36174. }>;
  36175. /**
  36176. * Fires each time a drag ends (eg. mouse release after drag)
  36177. */
  36178. onDragEndObservable: Observable<{
  36179. dragPlanePoint: Vector3;
  36180. pointerId: number;
  36181. }>;
  36182. /**
  36183. * If the attached mesh should be moved when dragged
  36184. */
  36185. moveAttached: boolean;
  36186. /**
  36187. * If the drag behavior will react to drag events (Default: true)
  36188. */
  36189. enabled: boolean;
  36190. /**
  36191. * If camera controls should be detached during the drag
  36192. */
  36193. detachCameraControls: boolean;
  36194. /**
  36195. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36196. */
  36197. useObjectOrienationForDragging: boolean;
  36198. private _options;
  36199. /**
  36200. * Creates a pointer drag behavior that can be attached to a mesh
  36201. * @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)
  36202. */
  36203. constructor(options?: {
  36204. dragAxis?: Vector3;
  36205. dragPlaneNormal?: Vector3;
  36206. });
  36207. /**
  36208. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36209. */
  36210. validateDrag: (targetPosition: Vector3) => boolean;
  36211. /**
  36212. * The name of the behavior
  36213. */
  36214. readonly name: string;
  36215. /**
  36216. * Initializes the behavior
  36217. */
  36218. init(): void;
  36219. private _tmpVector;
  36220. private _alternatePickedPoint;
  36221. private _worldDragAxis;
  36222. private _targetPosition;
  36223. private _attachedElement;
  36224. /**
  36225. * Attaches the drag behavior the passed in mesh
  36226. * @param ownerNode The mesh that will be dragged around once attached
  36227. */
  36228. attach(ownerNode: AbstractMesh): void;
  36229. /**
  36230. * Force relase the drag action by code.
  36231. */
  36232. releaseDrag(): void;
  36233. private _startDragRay;
  36234. private _lastPointerRay;
  36235. /**
  36236. * Simulates the start of a pointer drag event on the behavior
  36237. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36238. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36239. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36240. */
  36241. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36242. private _startDrag;
  36243. private _dragDelta;
  36244. private _moveDrag;
  36245. private _pickWithRayOnDragPlane;
  36246. private _pointA;
  36247. private _pointB;
  36248. private _pointC;
  36249. private _lineA;
  36250. private _lineB;
  36251. private _localAxis;
  36252. private _lookAt;
  36253. private _updateDragPlanePosition;
  36254. /**
  36255. * Detaches the behavior from the mesh
  36256. */
  36257. detach(): void;
  36258. }
  36259. }
  36260. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36261. import { Mesh } from "babylonjs/Meshes/mesh";
  36262. import { Behavior } from "babylonjs/Behaviors/behavior";
  36263. /**
  36264. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36265. */
  36266. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36267. private _dragBehaviorA;
  36268. private _dragBehaviorB;
  36269. private _startDistance;
  36270. private _initialScale;
  36271. private _targetScale;
  36272. private _ownerNode;
  36273. private _sceneRenderObserver;
  36274. /**
  36275. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36276. */
  36277. constructor();
  36278. /**
  36279. * The name of the behavior
  36280. */
  36281. readonly name: string;
  36282. /**
  36283. * Initializes the behavior
  36284. */
  36285. init(): void;
  36286. private _getCurrentDistance;
  36287. /**
  36288. * Attaches the scale behavior the passed in mesh
  36289. * @param ownerNode The mesh that will be scaled around once attached
  36290. */
  36291. attach(ownerNode: Mesh): void;
  36292. /**
  36293. * Detaches the behavior from the mesh
  36294. */
  36295. detach(): void;
  36296. }
  36297. }
  36298. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36299. import { Behavior } from "babylonjs/Behaviors/behavior";
  36300. import { Mesh } from "babylonjs/Meshes/mesh";
  36301. import { Observable } from "babylonjs/Misc/observable";
  36302. /**
  36303. * 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
  36304. */
  36305. export class SixDofDragBehavior implements Behavior<Mesh> {
  36306. private static _virtualScene;
  36307. private _ownerNode;
  36308. private _sceneRenderObserver;
  36309. private _scene;
  36310. private _targetPosition;
  36311. private _virtualOriginMesh;
  36312. private _virtualDragMesh;
  36313. private _pointerObserver;
  36314. private _moving;
  36315. private _startingOrientation;
  36316. /**
  36317. * 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)
  36318. */
  36319. private zDragFactor;
  36320. /**
  36321. * If the object should rotate to face the drag origin
  36322. */
  36323. rotateDraggedObject: boolean;
  36324. /**
  36325. * If the behavior is currently in a dragging state
  36326. */
  36327. dragging: boolean;
  36328. /**
  36329. * 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)
  36330. */
  36331. dragDeltaRatio: number;
  36332. /**
  36333. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36334. */
  36335. currentDraggingPointerID: number;
  36336. /**
  36337. * If camera controls should be detached during the drag
  36338. */
  36339. detachCameraControls: boolean;
  36340. /**
  36341. * Fires each time a drag starts
  36342. */
  36343. onDragStartObservable: Observable<{}>;
  36344. /**
  36345. * Fires each time a drag ends (eg. mouse release after drag)
  36346. */
  36347. onDragEndObservable: Observable<{}>;
  36348. /**
  36349. * 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
  36350. */
  36351. constructor();
  36352. /**
  36353. * The name of the behavior
  36354. */
  36355. readonly name: string;
  36356. /**
  36357. * Initializes the behavior
  36358. */
  36359. init(): void;
  36360. /**
  36361. * Attaches the scale behavior the passed in mesh
  36362. * @param ownerNode The mesh that will be scaled around once attached
  36363. */
  36364. attach(ownerNode: Mesh): void;
  36365. /**
  36366. * Detaches the behavior from the mesh
  36367. */
  36368. detach(): void;
  36369. }
  36370. }
  36371. declare module "babylonjs/Behaviors/Meshes/index" {
  36372. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36373. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36374. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36375. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36376. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36377. }
  36378. declare module "babylonjs/Behaviors/index" {
  36379. export * from "babylonjs/Behaviors/behavior";
  36380. export * from "babylonjs/Behaviors/Cameras/index";
  36381. export * from "babylonjs/Behaviors/Meshes/index";
  36382. }
  36383. declare module "babylonjs/Bones/boneIKController" {
  36384. import { Bone } from "babylonjs/Bones/bone";
  36385. import { Vector3 } from "babylonjs/Maths/math";
  36386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36387. import { Nullable } from "babylonjs/types";
  36388. /**
  36389. * Class used to apply inverse kinematics to bones
  36390. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36391. */
  36392. export class BoneIKController {
  36393. private static _tmpVecs;
  36394. private static _tmpQuat;
  36395. private static _tmpMats;
  36396. /**
  36397. * Gets or sets the target mesh
  36398. */
  36399. targetMesh: AbstractMesh;
  36400. /** Gets or sets the mesh used as pole */
  36401. poleTargetMesh: AbstractMesh;
  36402. /**
  36403. * Gets or sets the bone used as pole
  36404. */
  36405. poleTargetBone: Nullable<Bone>;
  36406. /**
  36407. * Gets or sets the target position
  36408. */
  36409. targetPosition: Vector3;
  36410. /**
  36411. * Gets or sets the pole target position
  36412. */
  36413. poleTargetPosition: Vector3;
  36414. /**
  36415. * Gets or sets the pole target local offset
  36416. */
  36417. poleTargetLocalOffset: Vector3;
  36418. /**
  36419. * Gets or sets the pole angle
  36420. */
  36421. poleAngle: number;
  36422. /**
  36423. * Gets or sets the mesh associated with the controller
  36424. */
  36425. mesh: AbstractMesh;
  36426. /**
  36427. * 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)
  36428. */
  36429. slerpAmount: number;
  36430. private _bone1Quat;
  36431. private _bone1Mat;
  36432. private _bone2Ang;
  36433. private _bone1;
  36434. private _bone2;
  36435. private _bone1Length;
  36436. private _bone2Length;
  36437. private _maxAngle;
  36438. private _maxReach;
  36439. private _rightHandedSystem;
  36440. private _bendAxis;
  36441. private _slerping;
  36442. private _adjustRoll;
  36443. /**
  36444. * Gets or sets maximum allowed angle
  36445. */
  36446. maxAngle: number;
  36447. /**
  36448. * Creates a new BoneIKController
  36449. * @param mesh defines the mesh to control
  36450. * @param bone defines the bone to control
  36451. * @param options defines options to set up the controller
  36452. */
  36453. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36454. targetMesh?: AbstractMesh;
  36455. poleTargetMesh?: AbstractMesh;
  36456. poleTargetBone?: Bone;
  36457. poleTargetLocalOffset?: Vector3;
  36458. poleAngle?: number;
  36459. bendAxis?: Vector3;
  36460. maxAngle?: number;
  36461. slerpAmount?: number;
  36462. });
  36463. private _setMaxAngle;
  36464. /**
  36465. * Force the controller to update the bones
  36466. */
  36467. update(): void;
  36468. }
  36469. }
  36470. declare module "babylonjs/Bones/boneLookController" {
  36471. import { Vector3, Space } from "babylonjs/Maths/math";
  36472. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36473. import { Bone } from "babylonjs/Bones/bone";
  36474. /**
  36475. * Class used to make a bone look toward a point in space
  36476. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36477. */
  36478. export class BoneLookController {
  36479. private static _tmpVecs;
  36480. private static _tmpQuat;
  36481. private static _tmpMats;
  36482. /**
  36483. * The target Vector3 that the bone will look at
  36484. */
  36485. target: Vector3;
  36486. /**
  36487. * The mesh that the bone is attached to
  36488. */
  36489. mesh: AbstractMesh;
  36490. /**
  36491. * The bone that will be looking to the target
  36492. */
  36493. bone: Bone;
  36494. /**
  36495. * The up axis of the coordinate system that is used when the bone is rotated
  36496. */
  36497. upAxis: Vector3;
  36498. /**
  36499. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36500. */
  36501. upAxisSpace: Space;
  36502. /**
  36503. * Used to make an adjustment to the yaw of the bone
  36504. */
  36505. adjustYaw: number;
  36506. /**
  36507. * Used to make an adjustment to the pitch of the bone
  36508. */
  36509. adjustPitch: number;
  36510. /**
  36511. * Used to make an adjustment to the roll of the bone
  36512. */
  36513. adjustRoll: number;
  36514. /**
  36515. * 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)
  36516. */
  36517. slerpAmount: number;
  36518. private _minYaw;
  36519. private _maxYaw;
  36520. private _minPitch;
  36521. private _maxPitch;
  36522. private _minYawSin;
  36523. private _minYawCos;
  36524. private _maxYawSin;
  36525. private _maxYawCos;
  36526. private _midYawConstraint;
  36527. private _minPitchTan;
  36528. private _maxPitchTan;
  36529. private _boneQuat;
  36530. private _slerping;
  36531. private _transformYawPitch;
  36532. private _transformYawPitchInv;
  36533. private _firstFrameSkipped;
  36534. private _yawRange;
  36535. private _fowardAxis;
  36536. /**
  36537. * Gets or sets the minimum yaw angle that the bone can look to
  36538. */
  36539. minYaw: number;
  36540. /**
  36541. * Gets or sets the maximum yaw angle that the bone can look to
  36542. */
  36543. maxYaw: number;
  36544. /**
  36545. * Gets or sets the minimum pitch angle that the bone can look to
  36546. */
  36547. minPitch: number;
  36548. /**
  36549. * Gets or sets the maximum pitch angle that the bone can look to
  36550. */
  36551. maxPitch: number;
  36552. /**
  36553. * Create a BoneLookController
  36554. * @param mesh the mesh that the bone belongs to
  36555. * @param bone the bone that will be looking to the target
  36556. * @param target the target Vector3 to look at
  36557. * @param options optional settings:
  36558. * * maxYaw: the maximum angle the bone will yaw to
  36559. * * minYaw: the minimum angle the bone will yaw to
  36560. * * maxPitch: the maximum angle the bone will pitch to
  36561. * * minPitch: the minimum angle the bone will yaw to
  36562. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36563. * * upAxis: the up axis of the coordinate system
  36564. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36565. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36566. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36567. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36568. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36569. * * adjustRoll: used to make an adjustment to the roll of the bone
  36570. **/
  36571. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36572. maxYaw?: number;
  36573. minYaw?: number;
  36574. maxPitch?: number;
  36575. minPitch?: number;
  36576. slerpAmount?: number;
  36577. upAxis?: Vector3;
  36578. upAxisSpace?: Space;
  36579. yawAxis?: Vector3;
  36580. pitchAxis?: Vector3;
  36581. adjustYaw?: number;
  36582. adjustPitch?: number;
  36583. adjustRoll?: number;
  36584. });
  36585. /**
  36586. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36587. */
  36588. update(): void;
  36589. private _getAngleDiff;
  36590. private _getAngleBetween;
  36591. private _isAngleBetween;
  36592. }
  36593. }
  36594. declare module "babylonjs/Bones/index" {
  36595. export * from "babylonjs/Bones/bone";
  36596. export * from "babylonjs/Bones/boneIKController";
  36597. export * from "babylonjs/Bones/boneLookController";
  36598. export * from "babylonjs/Bones/skeleton";
  36599. }
  36600. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  36601. import { Nullable } from "babylonjs/types";
  36602. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36603. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36604. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36605. /**
  36606. * Manage the gamepad inputs to control an arc rotate camera.
  36607. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36608. */
  36609. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36610. /**
  36611. * Defines the camera the input is attached to.
  36612. */
  36613. camera: ArcRotateCamera;
  36614. /**
  36615. * Defines the gamepad the input is gathering event from.
  36616. */
  36617. gamepad: Nullable<Gamepad>;
  36618. /**
  36619. * Defines the gamepad rotation sensiblity.
  36620. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36621. */
  36622. gamepadRotationSensibility: number;
  36623. /**
  36624. * Defines the gamepad move sensiblity.
  36625. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36626. */
  36627. gamepadMoveSensibility: number;
  36628. private _onGamepadConnectedObserver;
  36629. private _onGamepadDisconnectedObserver;
  36630. /**
  36631. * Attach the input controls to a specific dom element to get the input from.
  36632. * @param element Defines the element the controls should be listened from
  36633. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36634. */
  36635. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36636. /**
  36637. * Detach the current controls from the specified dom element.
  36638. * @param element Defines the element to stop listening the inputs from
  36639. */
  36640. detachControl(element: Nullable<HTMLElement>): void;
  36641. /**
  36642. * Update the current camera state depending on the inputs that have been used this frame.
  36643. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36644. */
  36645. checkInputs(): void;
  36646. /**
  36647. * Gets the class name of the current intput.
  36648. * @returns the class name
  36649. */
  36650. getClassName(): string;
  36651. /**
  36652. * Get the friendly name associated with the input class.
  36653. * @returns the input friendly name
  36654. */
  36655. getSimpleName(): string;
  36656. }
  36657. }
  36658. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  36659. import { Nullable } from "babylonjs/types";
  36660. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36661. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36662. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36663. interface ArcRotateCameraInputsManager {
  36664. /**
  36665. * Add orientation input support to the input manager.
  36666. * @returns the current input manager
  36667. */
  36668. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36669. }
  36670. }
  36671. /**
  36672. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36673. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36674. */
  36675. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36676. /**
  36677. * Defines the camera the input is attached to.
  36678. */
  36679. camera: ArcRotateCamera;
  36680. /**
  36681. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36682. */
  36683. alphaCorrection: number;
  36684. /**
  36685. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36686. */
  36687. gammaCorrection: number;
  36688. private _alpha;
  36689. private _gamma;
  36690. private _dirty;
  36691. private _deviceOrientationHandler;
  36692. /**
  36693. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36694. */
  36695. constructor();
  36696. /**
  36697. * Attach the input controls to a specific dom element to get the input from.
  36698. * @param element Defines the element the controls should be listened from
  36699. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36700. */
  36701. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36702. /** @hidden */
  36703. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36704. /**
  36705. * Update the current camera state depending on the inputs that have been used this frame.
  36706. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36707. */
  36708. checkInputs(): void;
  36709. /**
  36710. * Detach the current controls from the specified dom element.
  36711. * @param element Defines the element to stop listening the inputs from
  36712. */
  36713. detachControl(element: Nullable<HTMLElement>): void;
  36714. /**
  36715. * Gets the class name of the current intput.
  36716. * @returns the class name
  36717. */
  36718. getClassName(): string;
  36719. /**
  36720. * Get the friendly name associated with the input class.
  36721. * @returns the input friendly name
  36722. */
  36723. getSimpleName(): string;
  36724. }
  36725. }
  36726. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36727. import { Nullable } from "babylonjs/types";
  36728. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36729. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36730. /**
  36731. * Listen to mouse events to control the camera.
  36732. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36733. */
  36734. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36735. /**
  36736. * Defines the camera the input is attached to.
  36737. */
  36738. camera: FlyCamera;
  36739. /**
  36740. * Defines if touch is enabled. (Default is true.)
  36741. */
  36742. touchEnabled: boolean;
  36743. /**
  36744. * Defines the buttons associated with the input to handle camera rotation.
  36745. */
  36746. buttons: number[];
  36747. /**
  36748. * Assign buttons for Yaw control.
  36749. */
  36750. buttonsYaw: number[];
  36751. /**
  36752. * Assign buttons for Pitch control.
  36753. */
  36754. buttonsPitch: number[];
  36755. /**
  36756. * Assign buttons for Roll control.
  36757. */
  36758. buttonsRoll: number[];
  36759. /**
  36760. * Detect if any button is being pressed while mouse is moved.
  36761. * -1 = Mouse locked.
  36762. * 0 = Left button.
  36763. * 1 = Middle Button.
  36764. * 2 = Right Button.
  36765. */
  36766. activeButton: number;
  36767. /**
  36768. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36769. * Higher values reduce its sensitivity.
  36770. */
  36771. angularSensibility: number;
  36772. private _mousemoveCallback;
  36773. private _observer;
  36774. private _rollObserver;
  36775. private previousPosition;
  36776. private noPreventDefault;
  36777. private element;
  36778. /**
  36779. * Listen to mouse events to control the camera.
  36780. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36781. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36782. */
  36783. constructor(touchEnabled?: boolean);
  36784. /**
  36785. * Attach the mouse control to the HTML DOM element.
  36786. * @param element Defines the element that listens to the input events.
  36787. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36788. */
  36789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36790. /**
  36791. * Detach the current controls from the specified dom element.
  36792. * @param element Defines the element to stop listening the inputs from
  36793. */
  36794. detachControl(element: Nullable<HTMLElement>): void;
  36795. /**
  36796. * Gets the class name of the current input.
  36797. * @returns the class name.
  36798. */
  36799. getClassName(): string;
  36800. /**
  36801. * Get the friendly name associated with the input class.
  36802. * @returns the input's friendly name.
  36803. */
  36804. getSimpleName(): string;
  36805. private _pointerInput;
  36806. private _onMouseMove;
  36807. /**
  36808. * Rotate camera by mouse offset.
  36809. */
  36810. private rotateCamera;
  36811. }
  36812. }
  36813. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36814. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36815. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36816. /**
  36817. * Default Inputs manager for the FlyCamera.
  36818. * It groups all the default supported inputs for ease of use.
  36819. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36820. */
  36821. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36822. /**
  36823. * Instantiates a new FlyCameraInputsManager.
  36824. * @param camera Defines the camera the inputs belong to.
  36825. */
  36826. constructor(camera: FlyCamera);
  36827. /**
  36828. * Add keyboard input support to the input manager.
  36829. * @returns the new FlyCameraKeyboardMoveInput().
  36830. */
  36831. addKeyboard(): FlyCameraInputsManager;
  36832. /**
  36833. * Add mouse input support to the input manager.
  36834. * @param touchEnabled Enable touch screen support.
  36835. * @returns the new FlyCameraMouseInput().
  36836. */
  36837. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36838. }
  36839. }
  36840. declare module "babylonjs/Cameras/flyCamera" {
  36841. import { Scene } from "babylonjs/scene";
  36842. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36843. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36844. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36845. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36846. /**
  36847. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36848. * such as in a 3D Space Shooter or a Flight Simulator.
  36849. */
  36850. export class FlyCamera extends TargetCamera {
  36851. /**
  36852. * Define the collision ellipsoid of the camera.
  36853. * This is helpful for simulating a camera body, like a player's body.
  36854. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36855. */
  36856. ellipsoid: Vector3;
  36857. /**
  36858. * Define an offset for the position of the ellipsoid around the camera.
  36859. * This can be helpful if the camera is attached away from the player's body center,
  36860. * such as at its head.
  36861. */
  36862. ellipsoidOffset: Vector3;
  36863. /**
  36864. * Enable or disable collisions of the camera with the rest of the scene objects.
  36865. */
  36866. checkCollisions: boolean;
  36867. /**
  36868. * Enable or disable gravity on the camera.
  36869. */
  36870. applyGravity: boolean;
  36871. /**
  36872. * Define the current direction the camera is moving to.
  36873. */
  36874. cameraDirection: Vector3;
  36875. /**
  36876. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36877. * This overrides and empties cameraRotation.
  36878. */
  36879. rotationQuaternion: Quaternion;
  36880. /**
  36881. * Track Roll to maintain the wanted Rolling when looking around.
  36882. */
  36883. _trackRoll: number;
  36884. /**
  36885. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36886. */
  36887. rollCorrect: number;
  36888. /**
  36889. * Mimic a banked turn, Rolling the camera when Yawing.
  36890. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36891. */
  36892. bankedTurn: boolean;
  36893. /**
  36894. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36895. */
  36896. bankedTurnLimit: number;
  36897. /**
  36898. * Value of 0 disables the banked Roll.
  36899. * Value of 1 is equal to the Yaw angle in radians.
  36900. */
  36901. bankedTurnMultiplier: number;
  36902. /**
  36903. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36904. */
  36905. inputs: FlyCameraInputsManager;
  36906. /**
  36907. * Gets the input sensibility for mouse input.
  36908. * Higher values reduce sensitivity.
  36909. */
  36910. /**
  36911. * Sets the input sensibility for a mouse input.
  36912. * Higher values reduce sensitivity.
  36913. */
  36914. angularSensibility: number;
  36915. /**
  36916. * Get the keys for camera movement forward.
  36917. */
  36918. /**
  36919. * Set the keys for camera movement forward.
  36920. */
  36921. keysForward: number[];
  36922. /**
  36923. * Get the keys for camera movement backward.
  36924. */
  36925. keysBackward: number[];
  36926. /**
  36927. * Get the keys for camera movement up.
  36928. */
  36929. /**
  36930. * Set the keys for camera movement up.
  36931. */
  36932. keysUp: number[];
  36933. /**
  36934. * Get the keys for camera movement down.
  36935. */
  36936. /**
  36937. * Set the keys for camera movement down.
  36938. */
  36939. keysDown: number[];
  36940. /**
  36941. * Get the keys for camera movement left.
  36942. */
  36943. /**
  36944. * Set the keys for camera movement left.
  36945. */
  36946. keysLeft: number[];
  36947. /**
  36948. * Set the keys for camera movement right.
  36949. */
  36950. /**
  36951. * Set the keys for camera movement right.
  36952. */
  36953. keysRight: number[];
  36954. /**
  36955. * Event raised when the camera collides with a mesh in the scene.
  36956. */
  36957. onCollide: (collidedMesh: AbstractMesh) => void;
  36958. private _collider;
  36959. private _needMoveForGravity;
  36960. private _oldPosition;
  36961. private _diffPosition;
  36962. private _newPosition;
  36963. /** @hidden */
  36964. _localDirection: Vector3;
  36965. /** @hidden */
  36966. _transformedDirection: Vector3;
  36967. /**
  36968. * Instantiates a FlyCamera.
  36969. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36970. * such as in a 3D Space Shooter or a Flight Simulator.
  36971. * @param name Define the name of the camera in the scene.
  36972. * @param position Define the starting position of the camera in the scene.
  36973. * @param scene Define the scene the camera belongs to.
  36974. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36975. */
  36976. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36977. /**
  36978. * Attach a control to the HTML DOM element.
  36979. * @param element Defines the element that listens to the input events.
  36980. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36981. */
  36982. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36983. /**
  36984. * Detach a control from the HTML DOM element.
  36985. * The camera will stop reacting to that input.
  36986. * @param element Defines the element that listens to the input events.
  36987. */
  36988. detachControl(element: HTMLElement): void;
  36989. private _collisionMask;
  36990. /**
  36991. * Get the mask that the camera ignores in collision events.
  36992. */
  36993. /**
  36994. * Set the mask that the camera ignores in collision events.
  36995. */
  36996. collisionMask: number;
  36997. /** @hidden */
  36998. _collideWithWorld(displacement: Vector3): void;
  36999. /** @hidden */
  37000. private _onCollisionPositionChange;
  37001. /** @hidden */
  37002. _checkInputs(): void;
  37003. /** @hidden */
  37004. _decideIfNeedsToMove(): boolean;
  37005. /** @hidden */
  37006. _updatePosition(): void;
  37007. /**
  37008. * Restore the Roll to its target value at the rate specified.
  37009. * @param rate - Higher means slower restoring.
  37010. * @hidden
  37011. */
  37012. restoreRoll(rate: number): void;
  37013. /**
  37014. * Destroy the camera and release the current resources held by it.
  37015. */
  37016. dispose(): void;
  37017. /**
  37018. * Get the current object class name.
  37019. * @returns the class name.
  37020. */
  37021. getClassName(): string;
  37022. }
  37023. }
  37024. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37025. import { Nullable } from "babylonjs/types";
  37026. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37027. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37028. /**
  37029. * Listen to keyboard events to control the camera.
  37030. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37031. */
  37032. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37033. /**
  37034. * Defines the camera the input is attached to.
  37035. */
  37036. camera: FlyCamera;
  37037. /**
  37038. * The list of keyboard keys used to control the forward move of the camera.
  37039. */
  37040. keysForward: number[];
  37041. /**
  37042. * The list of keyboard keys used to control the backward move of the camera.
  37043. */
  37044. keysBackward: number[];
  37045. /**
  37046. * The list of keyboard keys used to control the forward move of the camera.
  37047. */
  37048. keysUp: number[];
  37049. /**
  37050. * The list of keyboard keys used to control the backward move of the camera.
  37051. */
  37052. keysDown: number[];
  37053. /**
  37054. * The list of keyboard keys used to control the right strafe move of the camera.
  37055. */
  37056. keysRight: number[];
  37057. /**
  37058. * The list of keyboard keys used to control the left strafe move of the camera.
  37059. */
  37060. keysLeft: number[];
  37061. private _keys;
  37062. private _onCanvasBlurObserver;
  37063. private _onKeyboardObserver;
  37064. private _engine;
  37065. private _scene;
  37066. /**
  37067. * Attach the input controls to a specific dom element to get the input from.
  37068. * @param element Defines the element the controls should be listened from
  37069. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37070. */
  37071. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37072. /**
  37073. * Detach the current controls from the specified dom element.
  37074. * @param element Defines the element to stop listening the inputs from
  37075. */
  37076. detachControl(element: Nullable<HTMLElement>): void;
  37077. /**
  37078. * Gets the class name of the current intput.
  37079. * @returns the class name
  37080. */
  37081. getClassName(): string;
  37082. /** @hidden */
  37083. _onLostFocus(e: FocusEvent): void;
  37084. /**
  37085. * Get the friendly name associated with the input class.
  37086. * @returns the input friendly name
  37087. */
  37088. getSimpleName(): string;
  37089. /**
  37090. * Update the current camera state depending on the inputs that have been used this frame.
  37091. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37092. */
  37093. checkInputs(): void;
  37094. }
  37095. }
  37096. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37097. import { Nullable } from "babylonjs/types";
  37098. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37099. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37100. /**
  37101. * Manage the mouse wheel inputs to control a follow camera.
  37102. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37103. */
  37104. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37105. /**
  37106. * Defines the camera the input is attached to.
  37107. */
  37108. camera: FollowCamera;
  37109. /**
  37110. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37111. */
  37112. axisControlRadius: boolean;
  37113. /**
  37114. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37115. */
  37116. axisControlHeight: boolean;
  37117. /**
  37118. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37119. */
  37120. axisControlRotation: boolean;
  37121. /**
  37122. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37123. * relation to mouseWheel events.
  37124. */
  37125. wheelPrecision: number;
  37126. /**
  37127. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37128. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37129. */
  37130. wheelDeltaPercentage: number;
  37131. private _wheel;
  37132. private _observer;
  37133. /**
  37134. * Attach the input controls to a specific dom element to get the input from.
  37135. * @param element Defines the element the controls should be listened from
  37136. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37137. */
  37138. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37139. /**
  37140. * Detach the current controls from the specified dom element.
  37141. * @param element Defines the element to stop listening the inputs from
  37142. */
  37143. detachControl(element: Nullable<HTMLElement>): void;
  37144. /**
  37145. * Gets the class name of the current intput.
  37146. * @returns the class name
  37147. */
  37148. getClassName(): string;
  37149. /**
  37150. * Get the friendly name associated with the input class.
  37151. * @returns the input friendly name
  37152. */
  37153. getSimpleName(): string;
  37154. }
  37155. }
  37156. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37157. import { Nullable } from "babylonjs/types";
  37158. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37159. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37160. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37161. /**
  37162. * Manage the pointers inputs to control an follow camera.
  37163. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37164. */
  37165. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37166. /**
  37167. * Defines the camera the input is attached to.
  37168. */
  37169. camera: FollowCamera;
  37170. /**
  37171. * Gets the class name of the current input.
  37172. * @returns the class name
  37173. */
  37174. getClassName(): string;
  37175. /**
  37176. * Defines the pointer angular sensibility along the X axis or how fast is
  37177. * the camera rotating.
  37178. * A negative number will reverse the axis direction.
  37179. */
  37180. angularSensibilityX: number;
  37181. /**
  37182. * Defines the pointer angular sensibility along the Y axis or how fast is
  37183. * the camera rotating.
  37184. * A negative number will reverse the axis direction.
  37185. */
  37186. angularSensibilityY: number;
  37187. /**
  37188. * Defines the pointer pinch precision or how fast is the camera zooming.
  37189. * A negative number will reverse the axis direction.
  37190. */
  37191. pinchPrecision: number;
  37192. /**
  37193. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37194. * from 0.
  37195. * It defines the percentage of current camera.radius to use as delta when
  37196. * pinch zoom is used.
  37197. */
  37198. pinchDeltaPercentage: number;
  37199. /**
  37200. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37201. */
  37202. axisXControlRadius: boolean;
  37203. /**
  37204. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37205. */
  37206. axisXControlHeight: boolean;
  37207. /**
  37208. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37209. */
  37210. axisXControlRotation: boolean;
  37211. /**
  37212. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37213. */
  37214. axisYControlRadius: boolean;
  37215. /**
  37216. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37217. */
  37218. axisYControlHeight: boolean;
  37219. /**
  37220. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37221. */
  37222. axisYControlRotation: boolean;
  37223. /**
  37224. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37225. */
  37226. axisPinchControlRadius: boolean;
  37227. /**
  37228. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37229. */
  37230. axisPinchControlHeight: boolean;
  37231. /**
  37232. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37233. */
  37234. axisPinchControlRotation: boolean;
  37235. /**
  37236. * Log error messages if basic misconfiguration has occurred.
  37237. */
  37238. warningEnable: boolean;
  37239. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37240. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37241. private _warningCounter;
  37242. private _warning;
  37243. }
  37244. }
  37245. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37246. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37247. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37248. /**
  37249. * Default Inputs manager for the FollowCamera.
  37250. * It groups all the default supported inputs for ease of use.
  37251. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37252. */
  37253. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37254. /**
  37255. * Instantiates a new FollowCameraInputsManager.
  37256. * @param camera Defines the camera the inputs belong to
  37257. */
  37258. constructor(camera: FollowCamera);
  37259. /**
  37260. * Add keyboard input support to the input manager.
  37261. * @returns the current input manager
  37262. */
  37263. addKeyboard(): FollowCameraInputsManager;
  37264. /**
  37265. * Add mouse wheel input support to the input manager.
  37266. * @returns the current input manager
  37267. */
  37268. addMouseWheel(): FollowCameraInputsManager;
  37269. /**
  37270. * Add pointers input support to the input manager.
  37271. * @returns the current input manager
  37272. */
  37273. addPointers(): FollowCameraInputsManager;
  37274. /**
  37275. * Add orientation input support to the input manager.
  37276. * @returns the current input manager
  37277. */
  37278. addVRDeviceOrientation(): FollowCameraInputsManager;
  37279. }
  37280. }
  37281. declare module "babylonjs/Cameras/followCamera" {
  37282. import { Nullable } from "babylonjs/types";
  37283. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37284. import { Scene } from "babylonjs/scene";
  37285. import { Vector3 } from "babylonjs/Maths/math";
  37286. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37287. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37288. /**
  37289. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37290. * an arc rotate version arcFollowCamera are available.
  37291. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37292. */
  37293. export class FollowCamera extends TargetCamera {
  37294. /**
  37295. * Distance the follow camera should follow an object at
  37296. */
  37297. radius: number;
  37298. /**
  37299. * Minimum allowed distance of the camera to the axis of rotation
  37300. * (The camera can not get closer).
  37301. * This can help limiting how the Camera is able to move in the scene.
  37302. */
  37303. lowerRadiusLimit: Nullable<number>;
  37304. /**
  37305. * Maximum allowed distance of the camera to the axis of rotation
  37306. * (The camera can not get further).
  37307. * This can help limiting how the Camera is able to move in the scene.
  37308. */
  37309. upperRadiusLimit: Nullable<number>;
  37310. /**
  37311. * Define a rotation offset between the camera and the object it follows
  37312. */
  37313. rotationOffset: number;
  37314. /**
  37315. * Minimum allowed angle to camera position relative to target object.
  37316. * This can help limiting how the Camera is able to move in the scene.
  37317. */
  37318. lowerRotationOffsetLimit: Nullable<number>;
  37319. /**
  37320. * Maximum allowed angle to camera position relative to target object.
  37321. * This can help limiting how the Camera is able to move in the scene.
  37322. */
  37323. upperRotationOffsetLimit: Nullable<number>;
  37324. /**
  37325. * Define a height offset between the camera and the object it follows.
  37326. * It can help following an object from the top (like a car chaing a plane)
  37327. */
  37328. heightOffset: number;
  37329. /**
  37330. * Minimum allowed height of camera position relative to target object.
  37331. * This can help limiting how the Camera is able to move in the scene.
  37332. */
  37333. lowerHeightOffsetLimit: Nullable<number>;
  37334. /**
  37335. * Maximum allowed height of camera position relative to target object.
  37336. * This can help limiting how the Camera is able to move in the scene.
  37337. */
  37338. upperHeightOffsetLimit: Nullable<number>;
  37339. /**
  37340. * Define how fast the camera can accelerate to follow it s target.
  37341. */
  37342. cameraAcceleration: number;
  37343. /**
  37344. * Define the speed limit of the camera following an object.
  37345. */
  37346. maxCameraSpeed: number;
  37347. /**
  37348. * Define the target of the camera.
  37349. */
  37350. lockedTarget: Nullable<AbstractMesh>;
  37351. /**
  37352. * Defines the input associated with the camera.
  37353. */
  37354. inputs: FollowCameraInputsManager;
  37355. /**
  37356. * Instantiates the follow camera.
  37357. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37358. * @param name Define the name of the camera in the scene
  37359. * @param position Define the position of the camera
  37360. * @param scene Define the scene the camera belong to
  37361. * @param lockedTarget Define the target of the camera
  37362. */
  37363. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37364. private _follow;
  37365. /**
  37366. * Attached controls to the current camera.
  37367. * @param element Defines the element the controls should be listened from
  37368. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37369. */
  37370. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37371. /**
  37372. * Detach the current controls from the camera.
  37373. * The camera will stop reacting to inputs.
  37374. * @param element Defines the element to stop listening the inputs from
  37375. */
  37376. detachControl(element: HTMLElement): void;
  37377. /** @hidden */
  37378. _checkInputs(): void;
  37379. private _checkLimits;
  37380. /**
  37381. * Gets the camera class name.
  37382. * @returns the class name
  37383. */
  37384. getClassName(): string;
  37385. }
  37386. /**
  37387. * Arc Rotate version of the follow camera.
  37388. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37389. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37390. */
  37391. export class ArcFollowCamera extends TargetCamera {
  37392. /** The longitudinal angle of the camera */
  37393. alpha: number;
  37394. /** The latitudinal angle of the camera */
  37395. beta: number;
  37396. /** The radius of the camera from its target */
  37397. radius: number;
  37398. /** Define the camera target (the messh it should follow) */
  37399. target: Nullable<AbstractMesh>;
  37400. private _cartesianCoordinates;
  37401. /**
  37402. * Instantiates a new ArcFollowCamera
  37403. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37404. * @param name Define the name of the camera
  37405. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37406. * @param beta Define the rotation angle of the camera around the elevation axis
  37407. * @param radius Define the radius of the camera from its target point
  37408. * @param target Define the target of the camera
  37409. * @param scene Define the scene the camera belongs to
  37410. */
  37411. constructor(name: string,
  37412. /** The longitudinal angle of the camera */
  37413. alpha: number,
  37414. /** The latitudinal angle of the camera */
  37415. beta: number,
  37416. /** The radius of the camera from its target */
  37417. radius: number,
  37418. /** Define the camera target (the messh it should follow) */
  37419. target: Nullable<AbstractMesh>, scene: Scene);
  37420. private _follow;
  37421. /** @hidden */
  37422. _checkInputs(): void;
  37423. /**
  37424. * Returns the class name of the object.
  37425. * It is mostly used internally for serialization purposes.
  37426. */
  37427. getClassName(): string;
  37428. }
  37429. }
  37430. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37431. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37432. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37433. import { Nullable } from "babylonjs/types";
  37434. /**
  37435. * Manage the keyboard inputs to control the movement of a follow camera.
  37436. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37437. */
  37438. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37439. /**
  37440. * Defines the camera the input is attached to.
  37441. */
  37442. camera: FollowCamera;
  37443. /**
  37444. * Defines the list of key codes associated with the up action (increase heightOffset)
  37445. */
  37446. keysHeightOffsetIncr: number[];
  37447. /**
  37448. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37449. */
  37450. keysHeightOffsetDecr: number[];
  37451. /**
  37452. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37453. */
  37454. keysHeightOffsetModifierAlt: boolean;
  37455. /**
  37456. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37457. */
  37458. keysHeightOffsetModifierCtrl: boolean;
  37459. /**
  37460. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37461. */
  37462. keysHeightOffsetModifierShift: boolean;
  37463. /**
  37464. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37465. */
  37466. keysRotationOffsetIncr: number[];
  37467. /**
  37468. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37469. */
  37470. keysRotationOffsetDecr: number[];
  37471. /**
  37472. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37473. */
  37474. keysRotationOffsetModifierAlt: boolean;
  37475. /**
  37476. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37477. */
  37478. keysRotationOffsetModifierCtrl: boolean;
  37479. /**
  37480. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37481. */
  37482. keysRotationOffsetModifierShift: boolean;
  37483. /**
  37484. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37485. */
  37486. keysRadiusIncr: number[];
  37487. /**
  37488. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37489. */
  37490. keysRadiusDecr: number[];
  37491. /**
  37492. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37493. */
  37494. keysRadiusModifierAlt: boolean;
  37495. /**
  37496. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37497. */
  37498. keysRadiusModifierCtrl: boolean;
  37499. /**
  37500. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37501. */
  37502. keysRadiusModifierShift: boolean;
  37503. /**
  37504. * Defines the rate of change of heightOffset.
  37505. */
  37506. heightSensibility: number;
  37507. /**
  37508. * Defines the rate of change of rotationOffset.
  37509. */
  37510. rotationSensibility: number;
  37511. /**
  37512. * Defines the rate of change of radius.
  37513. */
  37514. radiusSensibility: number;
  37515. private _keys;
  37516. private _ctrlPressed;
  37517. private _altPressed;
  37518. private _shiftPressed;
  37519. private _onCanvasBlurObserver;
  37520. private _onKeyboardObserver;
  37521. private _engine;
  37522. private _scene;
  37523. /**
  37524. * Attach the input controls to a specific dom element to get the input from.
  37525. * @param element Defines the element the controls should be listened from
  37526. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37527. */
  37528. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37529. /**
  37530. * Detach the current controls from the specified dom element.
  37531. * @param element Defines the element to stop listening the inputs from
  37532. */
  37533. detachControl(element: Nullable<HTMLElement>): void;
  37534. /**
  37535. * Update the current camera state depending on the inputs that have been used this frame.
  37536. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37537. */
  37538. checkInputs(): void;
  37539. /**
  37540. * Gets the class name of the current input.
  37541. * @returns the class name
  37542. */
  37543. getClassName(): string;
  37544. /**
  37545. * Get the friendly name associated with the input class.
  37546. * @returns the input friendly name
  37547. */
  37548. getSimpleName(): string;
  37549. /**
  37550. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37551. * allow modification of the heightOffset value.
  37552. */
  37553. private _modifierHeightOffset;
  37554. /**
  37555. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37556. * allow modification of the rotationOffset value.
  37557. */
  37558. private _modifierRotationOffset;
  37559. /**
  37560. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37561. * allow modification of the radius value.
  37562. */
  37563. private _modifierRadius;
  37564. }
  37565. }
  37566. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37567. import { Nullable } from "babylonjs/types";
  37568. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37569. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37570. module "babylonjs/Cameras/freeCameraInputsManager" {
  37571. interface FreeCameraInputsManager {
  37572. /**
  37573. * Add orientation input support to the input manager.
  37574. * @returns the current input manager
  37575. */
  37576. addDeviceOrientation(): FreeCameraInputsManager;
  37577. }
  37578. }
  37579. /**
  37580. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37581. * Screen rotation is taken into account.
  37582. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37583. */
  37584. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37585. private _camera;
  37586. private _screenOrientationAngle;
  37587. private _constantTranform;
  37588. private _screenQuaternion;
  37589. private _alpha;
  37590. private _beta;
  37591. private _gamma;
  37592. /**
  37593. * Instantiates a new input
  37594. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37595. */
  37596. constructor();
  37597. /**
  37598. * Define the camera controlled by the input.
  37599. */
  37600. camera: FreeCamera;
  37601. /**
  37602. * Attach the input controls to a specific dom element to get the input from.
  37603. * @param element Defines the element the controls should be listened from
  37604. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37605. */
  37606. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37607. private _orientationChanged;
  37608. private _deviceOrientation;
  37609. /**
  37610. * Detach the current controls from the specified dom element.
  37611. * @param element Defines the element to stop listening the inputs from
  37612. */
  37613. detachControl(element: Nullable<HTMLElement>): void;
  37614. /**
  37615. * Update the current camera state depending on the inputs that have been used this frame.
  37616. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37617. */
  37618. checkInputs(): void;
  37619. /**
  37620. * Gets the class name of the current intput.
  37621. * @returns the class name
  37622. */
  37623. getClassName(): string;
  37624. /**
  37625. * Get the friendly name associated with the input class.
  37626. * @returns the input friendly name
  37627. */
  37628. getSimpleName(): string;
  37629. }
  37630. }
  37631. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  37632. import { Nullable } from "babylonjs/types";
  37633. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37634. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37635. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37636. /**
  37637. * Manage the gamepad inputs to control a free camera.
  37638. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37639. */
  37640. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37641. /**
  37642. * Define the camera the input is attached to.
  37643. */
  37644. camera: FreeCamera;
  37645. /**
  37646. * Define the Gamepad controlling the input
  37647. */
  37648. gamepad: Nullable<Gamepad>;
  37649. /**
  37650. * Defines the gamepad rotation sensiblity.
  37651. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37652. */
  37653. gamepadAngularSensibility: number;
  37654. /**
  37655. * Defines the gamepad move sensiblity.
  37656. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37657. */
  37658. gamepadMoveSensibility: number;
  37659. private _onGamepadConnectedObserver;
  37660. private _onGamepadDisconnectedObserver;
  37661. private _cameraTransform;
  37662. private _deltaTransform;
  37663. private _vector3;
  37664. private _vector2;
  37665. /**
  37666. * Attach the input controls to a specific dom element to get the input from.
  37667. * @param element Defines the element the controls should be listened from
  37668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37669. */
  37670. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37671. /**
  37672. * Detach the current controls from the specified dom element.
  37673. * @param element Defines the element to stop listening the inputs from
  37674. */
  37675. detachControl(element: Nullable<HTMLElement>): void;
  37676. /**
  37677. * Update the current camera state depending on the inputs that have been used this frame.
  37678. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37679. */
  37680. checkInputs(): void;
  37681. /**
  37682. * Gets the class name of the current intput.
  37683. * @returns the class name
  37684. */
  37685. getClassName(): string;
  37686. /**
  37687. * Get the friendly name associated with the input class.
  37688. * @returns the input friendly name
  37689. */
  37690. getSimpleName(): string;
  37691. }
  37692. }
  37693. declare module "babylonjs/Misc/virtualJoystick" {
  37694. import { Nullable } from "babylonjs/types";
  37695. import { Vector3 } from "babylonjs/Maths/math";
  37696. /**
  37697. * Defines the potential axis of a Joystick
  37698. */
  37699. export enum JoystickAxis {
  37700. /** X axis */
  37701. X = 0,
  37702. /** Y axis */
  37703. Y = 1,
  37704. /** Z axis */
  37705. Z = 2
  37706. }
  37707. /**
  37708. * Class used to define virtual joystick (used in touch mode)
  37709. */
  37710. export class VirtualJoystick {
  37711. /**
  37712. * Gets or sets a boolean indicating that left and right values must be inverted
  37713. */
  37714. reverseLeftRight: boolean;
  37715. /**
  37716. * Gets or sets a boolean indicating that up and down values must be inverted
  37717. */
  37718. reverseUpDown: boolean;
  37719. /**
  37720. * Gets the offset value for the position (ie. the change of the position value)
  37721. */
  37722. deltaPosition: Vector3;
  37723. /**
  37724. * Gets a boolean indicating if the virtual joystick was pressed
  37725. */
  37726. pressed: boolean;
  37727. /**
  37728. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37729. */
  37730. static Canvas: Nullable<HTMLCanvasElement>;
  37731. private static _globalJoystickIndex;
  37732. private static vjCanvasContext;
  37733. private static vjCanvasWidth;
  37734. private static vjCanvasHeight;
  37735. private static halfWidth;
  37736. private _action;
  37737. private _axisTargetedByLeftAndRight;
  37738. private _axisTargetedByUpAndDown;
  37739. private _joystickSensibility;
  37740. private _inversedSensibility;
  37741. private _joystickPointerID;
  37742. private _joystickColor;
  37743. private _joystickPointerPos;
  37744. private _joystickPreviousPointerPos;
  37745. private _joystickPointerStartPos;
  37746. private _deltaJoystickVector;
  37747. private _leftJoystick;
  37748. private _touches;
  37749. private _onPointerDownHandlerRef;
  37750. private _onPointerMoveHandlerRef;
  37751. private _onPointerUpHandlerRef;
  37752. private _onResize;
  37753. /**
  37754. * Creates a new virtual joystick
  37755. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37756. */
  37757. constructor(leftJoystick?: boolean);
  37758. /**
  37759. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37760. * @param newJoystickSensibility defines the new sensibility
  37761. */
  37762. setJoystickSensibility(newJoystickSensibility: number): void;
  37763. private _onPointerDown;
  37764. private _onPointerMove;
  37765. private _onPointerUp;
  37766. /**
  37767. * Change the color of the virtual joystick
  37768. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37769. */
  37770. setJoystickColor(newColor: string): void;
  37771. /**
  37772. * Defines a callback to call when the joystick is touched
  37773. * @param action defines the callback
  37774. */
  37775. setActionOnTouch(action: () => any): void;
  37776. /**
  37777. * Defines which axis you'd like to control for left & right
  37778. * @param axis defines the axis to use
  37779. */
  37780. setAxisForLeftRight(axis: JoystickAxis): void;
  37781. /**
  37782. * Defines which axis you'd like to control for up & down
  37783. * @param axis defines the axis to use
  37784. */
  37785. setAxisForUpDown(axis: JoystickAxis): void;
  37786. private _drawVirtualJoystick;
  37787. /**
  37788. * Release internal HTML canvas
  37789. */
  37790. releaseCanvas(): void;
  37791. }
  37792. }
  37793. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  37794. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  37795. import { Nullable } from "babylonjs/types";
  37796. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37797. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37798. module "babylonjs/Cameras/freeCameraInputsManager" {
  37799. interface FreeCameraInputsManager {
  37800. /**
  37801. * Add virtual joystick input support to the input manager.
  37802. * @returns the current input manager
  37803. */
  37804. addVirtualJoystick(): FreeCameraInputsManager;
  37805. }
  37806. }
  37807. /**
  37808. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37809. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37810. */
  37811. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37812. /**
  37813. * Defines the camera the input is attached to.
  37814. */
  37815. camera: FreeCamera;
  37816. private _leftjoystick;
  37817. private _rightjoystick;
  37818. /**
  37819. * Gets the left stick of the virtual joystick.
  37820. * @returns The virtual Joystick
  37821. */
  37822. getLeftJoystick(): VirtualJoystick;
  37823. /**
  37824. * Gets the right stick of the virtual joystick.
  37825. * @returns The virtual Joystick
  37826. */
  37827. getRightJoystick(): VirtualJoystick;
  37828. /**
  37829. * Update the current camera state depending on the inputs that have been used this frame.
  37830. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37831. */
  37832. checkInputs(): void;
  37833. /**
  37834. * Attach the input controls to a specific dom element to get the input from.
  37835. * @param element Defines the element the controls should be listened from
  37836. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37837. */
  37838. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37839. /**
  37840. * Detach the current controls from the specified dom element.
  37841. * @param element Defines the element to stop listening the inputs from
  37842. */
  37843. detachControl(element: Nullable<HTMLElement>): void;
  37844. /**
  37845. * Gets the class name of the current intput.
  37846. * @returns the class name
  37847. */
  37848. getClassName(): string;
  37849. /**
  37850. * Get the friendly name associated with the input class.
  37851. * @returns the input friendly name
  37852. */
  37853. getSimpleName(): string;
  37854. }
  37855. }
  37856. declare module "babylonjs/Cameras/Inputs/index" {
  37857. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  37858. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  37859. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  37860. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  37861. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37862. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  37863. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  37864. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  37865. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  37866. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  37867. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37868. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  37869. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  37870. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  37871. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  37872. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37873. }
  37874. declare module "babylonjs/Cameras/touchCamera" {
  37875. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37876. import { Scene } from "babylonjs/scene";
  37877. import { Vector3 } from "babylonjs/Maths/math";
  37878. /**
  37879. * This represents a FPS type of camera controlled by touch.
  37880. * This is like a universal camera minus the Gamepad controls.
  37881. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37882. */
  37883. export class TouchCamera extends FreeCamera {
  37884. /**
  37885. * Defines the touch sensibility for rotation.
  37886. * The higher the faster.
  37887. */
  37888. touchAngularSensibility: number;
  37889. /**
  37890. * Defines the touch sensibility for move.
  37891. * The higher the faster.
  37892. */
  37893. touchMoveSensibility: number;
  37894. /**
  37895. * Instantiates a new touch camera.
  37896. * This represents a FPS type of camera controlled by touch.
  37897. * This is like a universal camera minus the Gamepad controls.
  37898. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37899. * @param name Define the name of the camera in the scene
  37900. * @param position Define the start position of the camera in the scene
  37901. * @param scene Define the scene the camera belongs to
  37902. */
  37903. constructor(name: string, position: Vector3, scene: Scene);
  37904. /**
  37905. * Gets the current object class name.
  37906. * @return the class name
  37907. */
  37908. getClassName(): string;
  37909. /** @hidden */
  37910. _setupInputs(): void;
  37911. }
  37912. }
  37913. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  37914. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37915. import { Scene } from "babylonjs/scene";
  37916. import { Vector3, Axis } from "babylonjs/Maths/math";
  37917. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  37918. /**
  37919. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37920. * being tilted forward or back and left or right.
  37921. */
  37922. export class DeviceOrientationCamera extends FreeCamera {
  37923. private _initialQuaternion;
  37924. private _quaternionCache;
  37925. /**
  37926. * Creates a new device orientation camera
  37927. * @param name The name of the camera
  37928. * @param position The start position camera
  37929. * @param scene The scene the camera belongs to
  37930. */
  37931. constructor(name: string, position: Vector3, scene: Scene);
  37932. /**
  37933. * Gets the current instance class name ("DeviceOrientationCamera").
  37934. * This helps avoiding instanceof at run time.
  37935. * @returns the class name
  37936. */
  37937. getClassName(): string;
  37938. /**
  37939. * @hidden
  37940. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37941. */
  37942. _checkInputs(): void;
  37943. /**
  37944. * Reset the camera to its default orientation on the specified axis only.
  37945. * @param axis The axis to reset
  37946. */
  37947. resetToCurrentRotation(axis?: Axis): void;
  37948. }
  37949. }
  37950. declare module "babylonjs/Cameras/universalCamera" {
  37951. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  37952. import { Scene } from "babylonjs/scene";
  37953. import { Vector3 } from "babylonjs/Maths/math";
  37954. /**
  37955. * 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,
  37956. * which still works and will still be found in many Playgrounds.
  37957. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37958. */
  37959. export class UniversalCamera extends TouchCamera {
  37960. /**
  37961. * Defines the gamepad rotation sensiblity.
  37962. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37963. */
  37964. gamepadAngularSensibility: number;
  37965. /**
  37966. * Defines the gamepad move sensiblity.
  37967. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37968. */
  37969. gamepadMoveSensibility: number;
  37970. /**
  37971. * 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,
  37972. * which still works and will still be found in many Playgrounds.
  37973. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37974. * @param name Define the name of the camera in the scene
  37975. * @param position Define the start position of the camera in the scene
  37976. * @param scene Define the scene the camera belongs to
  37977. */
  37978. constructor(name: string, position: Vector3, scene: Scene);
  37979. /**
  37980. * Gets the current object class name.
  37981. * @return the class name
  37982. */
  37983. getClassName(): string;
  37984. }
  37985. }
  37986. declare module "babylonjs/Cameras/gamepadCamera" {
  37987. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37988. import { Scene } from "babylonjs/scene";
  37989. import { Vector3 } from "babylonjs/Maths/math";
  37990. /**
  37991. * This represents a FPS type of camera. This is only here for back compat purpose.
  37992. * Please use the UniversalCamera instead as both are identical.
  37993. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37994. */
  37995. export class GamepadCamera extends UniversalCamera {
  37996. /**
  37997. * Instantiates a new Gamepad Camera
  37998. * This represents a FPS type of camera. This is only here for back compat purpose.
  37999. * Please use the UniversalCamera instead as both are identical.
  38000. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38001. * @param name Define the name of the camera in the scene
  38002. * @param position Define the start position of the camera in the scene
  38003. * @param scene Define the scene the camera belongs to
  38004. */
  38005. constructor(name: string, position: Vector3, scene: Scene);
  38006. /**
  38007. * Gets the current object class name.
  38008. * @return the class name
  38009. */
  38010. getClassName(): string;
  38011. }
  38012. }
  38013. declare module "babylonjs/Shaders/pass.fragment" {
  38014. /** @hidden */
  38015. export var passPixelShader: {
  38016. name: string;
  38017. shader: string;
  38018. };
  38019. }
  38020. declare module "babylonjs/Shaders/passCube.fragment" {
  38021. /** @hidden */
  38022. export var passCubePixelShader: {
  38023. name: string;
  38024. shader: string;
  38025. };
  38026. }
  38027. declare module "babylonjs/PostProcesses/passPostProcess" {
  38028. import { Nullable } from "babylonjs/types";
  38029. import { Camera } from "babylonjs/Cameras/camera";
  38030. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38031. import { Engine } from "babylonjs/Engines/engine";
  38032. import "babylonjs/Shaders/pass.fragment";
  38033. import "babylonjs/Shaders/passCube.fragment";
  38034. /**
  38035. * PassPostProcess which produces an output the same as it's input
  38036. */
  38037. export class PassPostProcess extends PostProcess {
  38038. /**
  38039. * Creates the PassPostProcess
  38040. * @param name The name of the effect.
  38041. * @param options The required width/height ratio to downsize to before computing the render pass.
  38042. * @param camera The camera to apply the render pass to.
  38043. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38044. * @param engine The engine which the post process will be applied. (default: current engine)
  38045. * @param reusable If the post process can be reused on the same frame. (default: false)
  38046. * @param textureType The type of texture to be used when performing the post processing.
  38047. * @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)
  38048. */
  38049. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38050. }
  38051. /**
  38052. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38053. */
  38054. export class PassCubePostProcess extends PostProcess {
  38055. private _face;
  38056. /**
  38057. * Gets or sets the cube face to display.
  38058. * * 0 is +X
  38059. * * 1 is -X
  38060. * * 2 is +Y
  38061. * * 3 is -Y
  38062. * * 4 is +Z
  38063. * * 5 is -Z
  38064. */
  38065. face: number;
  38066. /**
  38067. * Creates the PassCubePostProcess
  38068. * @param name The name of the effect.
  38069. * @param options The required width/height ratio to downsize to before computing the render pass.
  38070. * @param camera The camera to apply the render pass to.
  38071. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38072. * @param engine The engine which the post process will be applied. (default: current engine)
  38073. * @param reusable If the post process can be reused on the same frame. (default: false)
  38074. * @param textureType The type of texture to be used when performing the post processing.
  38075. * @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)
  38076. */
  38077. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38078. }
  38079. }
  38080. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38081. /** @hidden */
  38082. export var anaglyphPixelShader: {
  38083. name: string;
  38084. shader: string;
  38085. };
  38086. }
  38087. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38088. import { Engine } from "babylonjs/Engines/engine";
  38089. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38090. import { Camera } from "babylonjs/Cameras/camera";
  38091. import "babylonjs/Shaders/anaglyph.fragment";
  38092. /**
  38093. * Postprocess used to generate anaglyphic rendering
  38094. */
  38095. export class AnaglyphPostProcess extends PostProcess {
  38096. private _passedProcess;
  38097. /**
  38098. * Creates a new AnaglyphPostProcess
  38099. * @param name defines postprocess name
  38100. * @param options defines creation options or target ratio scale
  38101. * @param rigCameras defines cameras using this postprocess
  38102. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38103. * @param engine defines hosting engine
  38104. * @param reusable defines if the postprocess will be reused multiple times per frame
  38105. */
  38106. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38107. }
  38108. }
  38109. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38110. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38111. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38112. import { Scene } from "babylonjs/scene";
  38113. import { Vector3 } from "babylonjs/Maths/math";
  38114. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38115. /**
  38116. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38117. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38118. */
  38119. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38120. /**
  38121. * Creates a new AnaglyphArcRotateCamera
  38122. * @param name defines camera name
  38123. * @param alpha defines alpha angle (in radians)
  38124. * @param beta defines beta angle (in radians)
  38125. * @param radius defines radius
  38126. * @param target defines camera target
  38127. * @param interaxialDistance defines distance between each color axis
  38128. * @param scene defines the hosting scene
  38129. */
  38130. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38131. /**
  38132. * Gets camera class name
  38133. * @returns AnaglyphArcRotateCamera
  38134. */
  38135. getClassName(): string;
  38136. }
  38137. }
  38138. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38139. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38140. import { Scene } from "babylonjs/scene";
  38141. import { Vector3 } from "babylonjs/Maths/math";
  38142. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38143. /**
  38144. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38145. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38146. */
  38147. export class AnaglyphFreeCamera extends FreeCamera {
  38148. /**
  38149. * Creates a new AnaglyphFreeCamera
  38150. * @param name defines camera name
  38151. * @param position defines initial position
  38152. * @param interaxialDistance defines distance between each color axis
  38153. * @param scene defines the hosting scene
  38154. */
  38155. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38156. /**
  38157. * Gets camera class name
  38158. * @returns AnaglyphFreeCamera
  38159. */
  38160. getClassName(): string;
  38161. }
  38162. }
  38163. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38164. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38165. import { Scene } from "babylonjs/scene";
  38166. import { Vector3 } from "babylonjs/Maths/math";
  38167. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38168. /**
  38169. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38170. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38171. */
  38172. export class AnaglyphGamepadCamera extends GamepadCamera {
  38173. /**
  38174. * Creates a new AnaglyphGamepadCamera
  38175. * @param name defines camera name
  38176. * @param position defines initial position
  38177. * @param interaxialDistance defines distance between each color axis
  38178. * @param scene defines the hosting scene
  38179. */
  38180. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38181. /**
  38182. * Gets camera class name
  38183. * @returns AnaglyphGamepadCamera
  38184. */
  38185. getClassName(): string;
  38186. }
  38187. }
  38188. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38189. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38190. import { Scene } from "babylonjs/scene";
  38191. import { Vector3 } from "babylonjs/Maths/math";
  38192. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38193. /**
  38194. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38195. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38196. */
  38197. export class AnaglyphUniversalCamera extends UniversalCamera {
  38198. /**
  38199. * Creates a new AnaglyphUniversalCamera
  38200. * @param name defines camera name
  38201. * @param position defines initial position
  38202. * @param interaxialDistance defines distance between each color axis
  38203. * @param scene defines the hosting scene
  38204. */
  38205. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38206. /**
  38207. * Gets camera class name
  38208. * @returns AnaglyphUniversalCamera
  38209. */
  38210. getClassName(): string;
  38211. }
  38212. }
  38213. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38214. /** @hidden */
  38215. export var stereoscopicInterlacePixelShader: {
  38216. name: string;
  38217. shader: string;
  38218. };
  38219. }
  38220. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38221. import { Camera } from "babylonjs/Cameras/camera";
  38222. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38223. import { Engine } from "babylonjs/Engines/engine";
  38224. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38225. /**
  38226. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38227. */
  38228. export class StereoscopicInterlacePostProcess extends PostProcess {
  38229. private _stepSize;
  38230. private _passedProcess;
  38231. /**
  38232. * Initializes a StereoscopicInterlacePostProcess
  38233. * @param name The name of the effect.
  38234. * @param rigCameras The rig cameras to be appled to the post process
  38235. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38236. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38237. * @param engine The engine which the post process will be applied. (default: current engine)
  38238. * @param reusable If the post process can be reused on the same frame. (default: false)
  38239. */
  38240. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38241. }
  38242. }
  38243. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38244. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38245. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38246. import { Scene } from "babylonjs/scene";
  38247. import { Vector3 } from "babylonjs/Maths/math";
  38248. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38249. /**
  38250. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38251. * @see http://doc.babylonjs.com/features/cameras
  38252. */
  38253. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38254. /**
  38255. * Creates a new StereoscopicArcRotateCamera
  38256. * @param name defines camera name
  38257. * @param alpha defines alpha angle (in radians)
  38258. * @param beta defines beta angle (in radians)
  38259. * @param radius defines radius
  38260. * @param target defines camera target
  38261. * @param interaxialDistance defines distance between each color axis
  38262. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38263. * @param scene defines the hosting scene
  38264. */
  38265. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38266. /**
  38267. * Gets camera class name
  38268. * @returns StereoscopicArcRotateCamera
  38269. */
  38270. getClassName(): string;
  38271. }
  38272. }
  38273. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38274. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38275. import { Scene } from "babylonjs/scene";
  38276. import { Vector3 } from "babylonjs/Maths/math";
  38277. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38278. /**
  38279. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38280. * @see http://doc.babylonjs.com/features/cameras
  38281. */
  38282. export class StereoscopicFreeCamera extends FreeCamera {
  38283. /**
  38284. * Creates a new StereoscopicFreeCamera
  38285. * @param name defines camera name
  38286. * @param position defines initial position
  38287. * @param interaxialDistance defines distance between each color axis
  38288. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38289. * @param scene defines the hosting scene
  38290. */
  38291. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38292. /**
  38293. * Gets camera class name
  38294. * @returns StereoscopicFreeCamera
  38295. */
  38296. getClassName(): string;
  38297. }
  38298. }
  38299. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38300. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38301. import { Scene } from "babylonjs/scene";
  38302. import { Vector3 } from "babylonjs/Maths/math";
  38303. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38304. /**
  38305. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38306. * @see http://doc.babylonjs.com/features/cameras
  38307. */
  38308. export class StereoscopicGamepadCamera extends GamepadCamera {
  38309. /**
  38310. * Creates a new StereoscopicGamepadCamera
  38311. * @param name defines camera name
  38312. * @param position defines initial position
  38313. * @param interaxialDistance defines distance between each color axis
  38314. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38315. * @param scene defines the hosting scene
  38316. */
  38317. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38318. /**
  38319. * Gets camera class name
  38320. * @returns StereoscopicGamepadCamera
  38321. */
  38322. getClassName(): string;
  38323. }
  38324. }
  38325. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38326. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38327. import { Scene } from "babylonjs/scene";
  38328. import { Vector3 } from "babylonjs/Maths/math";
  38329. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38330. /**
  38331. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38332. * @see http://doc.babylonjs.com/features/cameras
  38333. */
  38334. export class StereoscopicUniversalCamera extends UniversalCamera {
  38335. /**
  38336. * Creates a new StereoscopicUniversalCamera
  38337. * @param name defines camera name
  38338. * @param position defines initial position
  38339. * @param interaxialDistance defines distance between each color axis
  38340. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38341. * @param scene defines the hosting scene
  38342. */
  38343. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38344. /**
  38345. * Gets camera class name
  38346. * @returns StereoscopicUniversalCamera
  38347. */
  38348. getClassName(): string;
  38349. }
  38350. }
  38351. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38352. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38353. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38354. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38355. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38356. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38357. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38358. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38359. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38360. }
  38361. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38362. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38363. import { Scene } from "babylonjs/scene";
  38364. import { Vector3 } from "babylonjs/Maths/math";
  38365. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38366. /**
  38367. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38368. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38369. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38370. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38371. */
  38372. export class VirtualJoysticksCamera extends FreeCamera {
  38373. /**
  38374. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38375. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38376. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38377. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38378. * @param name Define the name of the camera in the scene
  38379. * @param position Define the start position of the camera in the scene
  38380. * @param scene Define the scene the camera belongs to
  38381. */
  38382. constructor(name: string, position: Vector3, scene: Scene);
  38383. /**
  38384. * Gets the current object class name.
  38385. * @return the class name
  38386. */
  38387. getClassName(): string;
  38388. }
  38389. }
  38390. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38391. import { Matrix } from "babylonjs/Maths/math";
  38392. /**
  38393. * This represents all the required metrics to create a VR camera.
  38394. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38395. */
  38396. export class VRCameraMetrics {
  38397. /**
  38398. * Define the horizontal resolution off the screen.
  38399. */
  38400. hResolution: number;
  38401. /**
  38402. * Define the vertical resolution off the screen.
  38403. */
  38404. vResolution: number;
  38405. /**
  38406. * Define the horizontal screen size.
  38407. */
  38408. hScreenSize: number;
  38409. /**
  38410. * Define the vertical screen size.
  38411. */
  38412. vScreenSize: number;
  38413. /**
  38414. * Define the vertical screen center position.
  38415. */
  38416. vScreenCenter: number;
  38417. /**
  38418. * Define the distance of the eyes to the screen.
  38419. */
  38420. eyeToScreenDistance: number;
  38421. /**
  38422. * Define the distance between both lenses
  38423. */
  38424. lensSeparationDistance: number;
  38425. /**
  38426. * Define the distance between both viewer's eyes.
  38427. */
  38428. interpupillaryDistance: number;
  38429. /**
  38430. * Define the distortion factor of the VR postprocess.
  38431. * Please, touch with care.
  38432. */
  38433. distortionK: number[];
  38434. /**
  38435. * Define the chromatic aberration correction factors for the VR post process.
  38436. */
  38437. chromaAbCorrection: number[];
  38438. /**
  38439. * Define the scale factor of the post process.
  38440. * The smaller the better but the slower.
  38441. */
  38442. postProcessScaleFactor: number;
  38443. /**
  38444. * Define an offset for the lens center.
  38445. */
  38446. lensCenterOffset: number;
  38447. /**
  38448. * Define if the current vr camera should compensate the distortion of the lense or not.
  38449. */
  38450. compensateDistortion: boolean;
  38451. /**
  38452. * Gets the rendering aspect ratio based on the provided resolutions.
  38453. */
  38454. readonly aspectRatio: number;
  38455. /**
  38456. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38457. */
  38458. readonly aspectRatioFov: number;
  38459. /**
  38460. * @hidden
  38461. */
  38462. readonly leftHMatrix: Matrix;
  38463. /**
  38464. * @hidden
  38465. */
  38466. readonly rightHMatrix: Matrix;
  38467. /**
  38468. * @hidden
  38469. */
  38470. readonly leftPreViewMatrix: Matrix;
  38471. /**
  38472. * @hidden
  38473. */
  38474. readonly rightPreViewMatrix: Matrix;
  38475. /**
  38476. * Get the default VRMetrics based on the most generic setup.
  38477. * @returns the default vr metrics
  38478. */
  38479. static GetDefault(): VRCameraMetrics;
  38480. }
  38481. }
  38482. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38483. /** @hidden */
  38484. export var vrDistortionCorrectionPixelShader: {
  38485. name: string;
  38486. shader: string;
  38487. };
  38488. }
  38489. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38490. import { Camera } from "babylonjs/Cameras/camera";
  38491. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38492. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38493. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38494. /**
  38495. * VRDistortionCorrectionPostProcess used for mobile VR
  38496. */
  38497. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38498. private _isRightEye;
  38499. private _distortionFactors;
  38500. private _postProcessScaleFactor;
  38501. private _lensCenterOffset;
  38502. private _scaleIn;
  38503. private _scaleFactor;
  38504. private _lensCenter;
  38505. /**
  38506. * Initializes the VRDistortionCorrectionPostProcess
  38507. * @param name The name of the effect.
  38508. * @param camera The camera to apply the render pass to.
  38509. * @param isRightEye If this is for the right eye distortion
  38510. * @param vrMetrics All the required metrics for the VR camera
  38511. */
  38512. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38513. }
  38514. }
  38515. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38516. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38517. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38518. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38519. import { Scene } from "babylonjs/scene";
  38520. import { Vector3 } from "babylonjs/Maths/math";
  38521. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38522. import "babylonjs/Cameras/RigModes/vrRigMode";
  38523. /**
  38524. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38525. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38526. */
  38527. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38528. /**
  38529. * Creates a new VRDeviceOrientationArcRotateCamera
  38530. * @param name defines camera name
  38531. * @param alpha defines the camera rotation along the logitudinal axis
  38532. * @param beta defines the camera rotation along the latitudinal axis
  38533. * @param radius defines the camera distance from its target
  38534. * @param target defines the camera target
  38535. * @param scene defines the scene the camera belongs to
  38536. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38537. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38538. */
  38539. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38540. /**
  38541. * Gets camera class name
  38542. * @returns VRDeviceOrientationArcRotateCamera
  38543. */
  38544. getClassName(): string;
  38545. }
  38546. }
  38547. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38548. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38549. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38550. import { Scene } from "babylonjs/scene";
  38551. import { Vector3 } from "babylonjs/Maths/math";
  38552. import "babylonjs/Cameras/RigModes/vrRigMode";
  38553. /**
  38554. * Camera used to simulate VR rendering (based on FreeCamera)
  38555. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38556. */
  38557. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38558. /**
  38559. * Creates a new VRDeviceOrientationFreeCamera
  38560. * @param name defines camera name
  38561. * @param position defines the start position of the camera
  38562. * @param scene defines the scene the camera belongs to
  38563. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38564. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38565. */
  38566. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38567. /**
  38568. * Gets camera class name
  38569. * @returns VRDeviceOrientationFreeCamera
  38570. */
  38571. getClassName(): string;
  38572. }
  38573. }
  38574. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  38575. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  38576. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38577. import { Scene } from "babylonjs/scene";
  38578. import { Vector3 } from "babylonjs/Maths/math";
  38579. /**
  38580. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38581. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38582. */
  38583. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38584. /**
  38585. * Creates a new VRDeviceOrientationGamepadCamera
  38586. * @param name defines camera name
  38587. * @param position defines the start position of the camera
  38588. * @param scene defines the scene the camera belongs to
  38589. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38590. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38591. */
  38592. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38593. /**
  38594. * Gets camera class name
  38595. * @returns VRDeviceOrientationGamepadCamera
  38596. */
  38597. getClassName(): string;
  38598. }
  38599. }
  38600. declare module "babylonjs/Gamepads/xboxGamepad" {
  38601. import { Observable } from "babylonjs/Misc/observable";
  38602. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38603. /**
  38604. * Defines supported buttons for XBox360 compatible gamepads
  38605. */
  38606. export enum Xbox360Button {
  38607. /** A */
  38608. A = 0,
  38609. /** B */
  38610. B = 1,
  38611. /** X */
  38612. X = 2,
  38613. /** Y */
  38614. Y = 3,
  38615. /** Start */
  38616. Start = 4,
  38617. /** Back */
  38618. Back = 5,
  38619. /** Left button */
  38620. LB = 6,
  38621. /** Right button */
  38622. RB = 7,
  38623. /** Left stick */
  38624. LeftStick = 8,
  38625. /** Right stick */
  38626. RightStick = 9
  38627. }
  38628. /** Defines values for XBox360 DPad */
  38629. export enum Xbox360Dpad {
  38630. /** Up */
  38631. Up = 0,
  38632. /** Down */
  38633. Down = 1,
  38634. /** Left */
  38635. Left = 2,
  38636. /** Right */
  38637. Right = 3
  38638. }
  38639. /**
  38640. * Defines a XBox360 gamepad
  38641. */
  38642. export class Xbox360Pad extends Gamepad {
  38643. private _leftTrigger;
  38644. private _rightTrigger;
  38645. private _onlefttriggerchanged;
  38646. private _onrighttriggerchanged;
  38647. private _onbuttondown;
  38648. private _onbuttonup;
  38649. private _ondpaddown;
  38650. private _ondpadup;
  38651. /** Observable raised when a button is pressed */
  38652. onButtonDownObservable: Observable<Xbox360Button>;
  38653. /** Observable raised when a button is released */
  38654. onButtonUpObservable: Observable<Xbox360Button>;
  38655. /** Observable raised when a pad is pressed */
  38656. onPadDownObservable: Observable<Xbox360Dpad>;
  38657. /** Observable raised when a pad is released */
  38658. onPadUpObservable: Observable<Xbox360Dpad>;
  38659. private _buttonA;
  38660. private _buttonB;
  38661. private _buttonX;
  38662. private _buttonY;
  38663. private _buttonBack;
  38664. private _buttonStart;
  38665. private _buttonLB;
  38666. private _buttonRB;
  38667. private _buttonLeftStick;
  38668. private _buttonRightStick;
  38669. private _dPadUp;
  38670. private _dPadDown;
  38671. private _dPadLeft;
  38672. private _dPadRight;
  38673. private _isXboxOnePad;
  38674. /**
  38675. * Creates a new XBox360 gamepad object
  38676. * @param id defines the id of this gamepad
  38677. * @param index defines its index
  38678. * @param gamepad defines the internal HTML gamepad object
  38679. * @param xboxOne defines if it is a XBox One gamepad
  38680. */
  38681. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38682. /**
  38683. * Defines the callback to call when left trigger is pressed
  38684. * @param callback defines the callback to use
  38685. */
  38686. onlefttriggerchanged(callback: (value: number) => void): void;
  38687. /**
  38688. * Defines the callback to call when right trigger is pressed
  38689. * @param callback defines the callback to use
  38690. */
  38691. onrighttriggerchanged(callback: (value: number) => void): void;
  38692. /**
  38693. * Gets the left trigger value
  38694. */
  38695. /**
  38696. * Sets the left trigger value
  38697. */
  38698. leftTrigger: number;
  38699. /**
  38700. * Gets the right trigger value
  38701. */
  38702. /**
  38703. * Sets the right trigger value
  38704. */
  38705. rightTrigger: number;
  38706. /**
  38707. * Defines the callback to call when a button is pressed
  38708. * @param callback defines the callback to use
  38709. */
  38710. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38711. /**
  38712. * Defines the callback to call when a button is released
  38713. * @param callback defines the callback to use
  38714. */
  38715. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38716. /**
  38717. * Defines the callback to call when a pad is pressed
  38718. * @param callback defines the callback to use
  38719. */
  38720. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38721. /**
  38722. * Defines the callback to call when a pad is released
  38723. * @param callback defines the callback to use
  38724. */
  38725. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38726. private _setButtonValue;
  38727. private _setDPadValue;
  38728. /**
  38729. * Gets the value of the `A` button
  38730. */
  38731. /**
  38732. * Sets the value of the `A` button
  38733. */
  38734. buttonA: number;
  38735. /**
  38736. * Gets the value of the `B` button
  38737. */
  38738. /**
  38739. * Sets the value of the `B` button
  38740. */
  38741. buttonB: number;
  38742. /**
  38743. * Gets the value of the `X` button
  38744. */
  38745. /**
  38746. * Sets the value of the `X` button
  38747. */
  38748. buttonX: number;
  38749. /**
  38750. * Gets the value of the `Y` button
  38751. */
  38752. /**
  38753. * Sets the value of the `Y` button
  38754. */
  38755. buttonY: number;
  38756. /**
  38757. * Gets the value of the `Start` button
  38758. */
  38759. /**
  38760. * Sets the value of the `Start` button
  38761. */
  38762. buttonStart: number;
  38763. /**
  38764. * Gets the value of the `Back` button
  38765. */
  38766. /**
  38767. * Sets the value of the `Back` button
  38768. */
  38769. buttonBack: number;
  38770. /**
  38771. * Gets the value of the `Left` button
  38772. */
  38773. /**
  38774. * Sets the value of the `Left` button
  38775. */
  38776. buttonLB: number;
  38777. /**
  38778. * Gets the value of the `Right` button
  38779. */
  38780. /**
  38781. * Sets the value of the `Right` button
  38782. */
  38783. buttonRB: number;
  38784. /**
  38785. * Gets the value of the Left joystick
  38786. */
  38787. /**
  38788. * Sets the value of the Left joystick
  38789. */
  38790. buttonLeftStick: number;
  38791. /**
  38792. * Gets the value of the Right joystick
  38793. */
  38794. /**
  38795. * Sets the value of the Right joystick
  38796. */
  38797. buttonRightStick: number;
  38798. /**
  38799. * Gets the value of D-pad up
  38800. */
  38801. /**
  38802. * Sets the value of D-pad up
  38803. */
  38804. dPadUp: number;
  38805. /**
  38806. * Gets the value of D-pad down
  38807. */
  38808. /**
  38809. * Sets the value of D-pad down
  38810. */
  38811. dPadDown: number;
  38812. /**
  38813. * Gets the value of D-pad left
  38814. */
  38815. /**
  38816. * Sets the value of D-pad left
  38817. */
  38818. dPadLeft: number;
  38819. /**
  38820. * Gets the value of D-pad right
  38821. */
  38822. /**
  38823. * Sets the value of D-pad right
  38824. */
  38825. dPadRight: number;
  38826. /**
  38827. * Force the gamepad to synchronize with device values
  38828. */
  38829. update(): void;
  38830. /**
  38831. * Disposes the gamepad
  38832. */
  38833. dispose(): void;
  38834. }
  38835. }
  38836. declare module "babylonjs/Materials/pushMaterial" {
  38837. import { Nullable } from "babylonjs/types";
  38838. import { Scene } from "babylonjs/scene";
  38839. import { Matrix } from "babylonjs/Maths/math";
  38840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38841. import { Mesh } from "babylonjs/Meshes/mesh";
  38842. import { Material } from "babylonjs/Materials/material";
  38843. import { Effect } from "babylonjs/Materials/effect";
  38844. /**
  38845. * Base class of materials working in push mode in babylon JS
  38846. * @hidden
  38847. */
  38848. export class PushMaterial extends Material {
  38849. protected _activeEffect: Effect;
  38850. protected _normalMatrix: Matrix;
  38851. /**
  38852. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38853. * This means that the material can keep using a previous shader while a new one is being compiled.
  38854. * This is mostly used when shader parallel compilation is supported (true by default)
  38855. */
  38856. allowShaderHotSwapping: boolean;
  38857. constructor(name: string, scene: Scene);
  38858. getEffect(): Effect;
  38859. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38860. /**
  38861. * Binds the given world matrix to the active effect
  38862. *
  38863. * @param world the matrix to bind
  38864. */
  38865. bindOnlyWorldMatrix(world: Matrix): void;
  38866. /**
  38867. * Binds the given normal matrix to the active effect
  38868. *
  38869. * @param normalMatrix the matrix to bind
  38870. */
  38871. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38872. bind(world: Matrix, mesh?: Mesh): void;
  38873. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38874. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38875. }
  38876. }
  38877. declare module "babylonjs/Materials/materialFlags" {
  38878. /**
  38879. * This groups all the flags used to control the materials channel.
  38880. */
  38881. export class MaterialFlags {
  38882. private static _DiffuseTextureEnabled;
  38883. /**
  38884. * Are diffuse textures enabled in the application.
  38885. */
  38886. static DiffuseTextureEnabled: boolean;
  38887. private static _AmbientTextureEnabled;
  38888. /**
  38889. * Are ambient textures enabled in the application.
  38890. */
  38891. static AmbientTextureEnabled: boolean;
  38892. private static _OpacityTextureEnabled;
  38893. /**
  38894. * Are opacity textures enabled in the application.
  38895. */
  38896. static OpacityTextureEnabled: boolean;
  38897. private static _ReflectionTextureEnabled;
  38898. /**
  38899. * Are reflection textures enabled in the application.
  38900. */
  38901. static ReflectionTextureEnabled: boolean;
  38902. private static _EmissiveTextureEnabled;
  38903. /**
  38904. * Are emissive textures enabled in the application.
  38905. */
  38906. static EmissiveTextureEnabled: boolean;
  38907. private static _SpecularTextureEnabled;
  38908. /**
  38909. * Are specular textures enabled in the application.
  38910. */
  38911. static SpecularTextureEnabled: boolean;
  38912. private static _BumpTextureEnabled;
  38913. /**
  38914. * Are bump textures enabled in the application.
  38915. */
  38916. static BumpTextureEnabled: boolean;
  38917. private static _LightmapTextureEnabled;
  38918. /**
  38919. * Are lightmap textures enabled in the application.
  38920. */
  38921. static LightmapTextureEnabled: boolean;
  38922. private static _RefractionTextureEnabled;
  38923. /**
  38924. * Are refraction textures enabled in the application.
  38925. */
  38926. static RefractionTextureEnabled: boolean;
  38927. private static _ColorGradingTextureEnabled;
  38928. /**
  38929. * Are color grading textures enabled in the application.
  38930. */
  38931. static ColorGradingTextureEnabled: boolean;
  38932. private static _FresnelEnabled;
  38933. /**
  38934. * Are fresnels enabled in the application.
  38935. */
  38936. static FresnelEnabled: boolean;
  38937. private static _ClearCoatTextureEnabled;
  38938. /**
  38939. * Are clear coat textures enabled in the application.
  38940. */
  38941. static ClearCoatTextureEnabled: boolean;
  38942. private static _ClearCoatBumpTextureEnabled;
  38943. /**
  38944. * Are clear coat bump textures enabled in the application.
  38945. */
  38946. static ClearCoatBumpTextureEnabled: boolean;
  38947. private static _ClearCoatTintTextureEnabled;
  38948. /**
  38949. * Are clear coat tint textures enabled in the application.
  38950. */
  38951. static ClearCoatTintTextureEnabled: boolean;
  38952. private static _SheenTextureEnabled;
  38953. /**
  38954. * Are sheen textures enabled in the application.
  38955. */
  38956. static SheenTextureEnabled: boolean;
  38957. private static _AnisotropicTextureEnabled;
  38958. /**
  38959. * Are anisotropic textures enabled in the application.
  38960. */
  38961. static AnisotropicTextureEnabled: boolean;
  38962. }
  38963. }
  38964. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  38965. /** @hidden */
  38966. export var defaultFragmentDeclaration: {
  38967. name: string;
  38968. shader: string;
  38969. };
  38970. }
  38971. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  38972. /** @hidden */
  38973. export var defaultUboDeclaration: {
  38974. name: string;
  38975. shader: string;
  38976. };
  38977. }
  38978. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  38979. /** @hidden */
  38980. export var lightFragmentDeclaration: {
  38981. name: string;
  38982. shader: string;
  38983. };
  38984. }
  38985. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  38986. /** @hidden */
  38987. export var lightUboDeclaration: {
  38988. name: string;
  38989. shader: string;
  38990. };
  38991. }
  38992. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  38993. /** @hidden */
  38994. export var lightsFragmentFunctions: {
  38995. name: string;
  38996. shader: string;
  38997. };
  38998. }
  38999. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39000. /** @hidden */
  39001. export var shadowsFragmentFunctions: {
  39002. name: string;
  39003. shader: string;
  39004. };
  39005. }
  39006. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39007. /** @hidden */
  39008. export var fresnelFunction: {
  39009. name: string;
  39010. shader: string;
  39011. };
  39012. }
  39013. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39014. /** @hidden */
  39015. export var reflectionFunction: {
  39016. name: string;
  39017. shader: string;
  39018. };
  39019. }
  39020. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39021. /** @hidden */
  39022. export var bumpFragmentFunctions: {
  39023. name: string;
  39024. shader: string;
  39025. };
  39026. }
  39027. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39028. /** @hidden */
  39029. export var logDepthDeclaration: {
  39030. name: string;
  39031. shader: string;
  39032. };
  39033. }
  39034. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39035. /** @hidden */
  39036. export var bumpFragment: {
  39037. name: string;
  39038. shader: string;
  39039. };
  39040. }
  39041. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39042. /** @hidden */
  39043. export var depthPrePass: {
  39044. name: string;
  39045. shader: string;
  39046. };
  39047. }
  39048. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39049. /** @hidden */
  39050. export var lightFragment: {
  39051. name: string;
  39052. shader: string;
  39053. };
  39054. }
  39055. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39056. /** @hidden */
  39057. export var logDepthFragment: {
  39058. name: string;
  39059. shader: string;
  39060. };
  39061. }
  39062. declare module "babylonjs/Shaders/default.fragment" {
  39063. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39064. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39065. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39066. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39067. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39068. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39069. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39070. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39071. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39072. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39073. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39074. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39075. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39076. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39077. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39078. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39079. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39080. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39081. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39082. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39083. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39084. /** @hidden */
  39085. export var defaultPixelShader: {
  39086. name: string;
  39087. shader: string;
  39088. };
  39089. }
  39090. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39091. /** @hidden */
  39092. export var defaultVertexDeclaration: {
  39093. name: string;
  39094. shader: string;
  39095. };
  39096. }
  39097. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39098. /** @hidden */
  39099. export var bumpVertexDeclaration: {
  39100. name: string;
  39101. shader: string;
  39102. };
  39103. }
  39104. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39105. /** @hidden */
  39106. export var bumpVertex: {
  39107. name: string;
  39108. shader: string;
  39109. };
  39110. }
  39111. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39112. /** @hidden */
  39113. export var fogVertex: {
  39114. name: string;
  39115. shader: string;
  39116. };
  39117. }
  39118. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39119. /** @hidden */
  39120. export var shadowsVertex: {
  39121. name: string;
  39122. shader: string;
  39123. };
  39124. }
  39125. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39126. /** @hidden */
  39127. export var pointCloudVertex: {
  39128. name: string;
  39129. shader: string;
  39130. };
  39131. }
  39132. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39133. /** @hidden */
  39134. export var logDepthVertex: {
  39135. name: string;
  39136. shader: string;
  39137. };
  39138. }
  39139. declare module "babylonjs/Shaders/default.vertex" {
  39140. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39141. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39142. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39143. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39144. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39145. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39146. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39147. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39148. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39149. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39150. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39151. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39152. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39153. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39154. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39155. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39156. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39157. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39158. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39159. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39160. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39161. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39162. /** @hidden */
  39163. export var defaultVertexShader: {
  39164. name: string;
  39165. shader: string;
  39166. };
  39167. }
  39168. declare module "babylonjs/Materials/standardMaterial" {
  39169. import { SmartArray } from "babylonjs/Misc/smartArray";
  39170. import { IAnimatable } from "babylonjs/Misc/tools";
  39171. import { Nullable } from "babylonjs/types";
  39172. import { Scene } from "babylonjs/scene";
  39173. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39174. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39175. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39176. import { Mesh } from "babylonjs/Meshes/mesh";
  39177. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39178. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39179. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39180. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39181. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39182. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39183. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39184. import "babylonjs/Shaders/default.fragment";
  39185. import "babylonjs/Shaders/default.vertex";
  39186. /** @hidden */
  39187. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39188. MAINUV1: boolean;
  39189. MAINUV2: boolean;
  39190. DIFFUSE: boolean;
  39191. DIFFUSEDIRECTUV: number;
  39192. AMBIENT: boolean;
  39193. AMBIENTDIRECTUV: number;
  39194. OPACITY: boolean;
  39195. OPACITYDIRECTUV: number;
  39196. OPACITYRGB: boolean;
  39197. REFLECTION: boolean;
  39198. EMISSIVE: boolean;
  39199. EMISSIVEDIRECTUV: number;
  39200. SPECULAR: boolean;
  39201. SPECULARDIRECTUV: number;
  39202. BUMP: boolean;
  39203. BUMPDIRECTUV: number;
  39204. PARALLAX: boolean;
  39205. PARALLAXOCCLUSION: boolean;
  39206. SPECULAROVERALPHA: boolean;
  39207. CLIPPLANE: boolean;
  39208. CLIPPLANE2: boolean;
  39209. CLIPPLANE3: boolean;
  39210. CLIPPLANE4: boolean;
  39211. ALPHATEST: boolean;
  39212. DEPTHPREPASS: boolean;
  39213. ALPHAFROMDIFFUSE: boolean;
  39214. POINTSIZE: boolean;
  39215. FOG: boolean;
  39216. SPECULARTERM: boolean;
  39217. DIFFUSEFRESNEL: boolean;
  39218. OPACITYFRESNEL: boolean;
  39219. REFLECTIONFRESNEL: boolean;
  39220. REFRACTIONFRESNEL: boolean;
  39221. EMISSIVEFRESNEL: boolean;
  39222. FRESNEL: boolean;
  39223. NORMAL: boolean;
  39224. UV1: boolean;
  39225. UV2: boolean;
  39226. VERTEXCOLOR: boolean;
  39227. VERTEXALPHA: boolean;
  39228. NUM_BONE_INFLUENCERS: number;
  39229. BonesPerMesh: number;
  39230. BONETEXTURE: boolean;
  39231. INSTANCES: boolean;
  39232. GLOSSINESS: boolean;
  39233. ROUGHNESS: boolean;
  39234. EMISSIVEASILLUMINATION: boolean;
  39235. LINKEMISSIVEWITHDIFFUSE: boolean;
  39236. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39237. LIGHTMAP: boolean;
  39238. LIGHTMAPDIRECTUV: number;
  39239. OBJECTSPACE_NORMALMAP: boolean;
  39240. USELIGHTMAPASSHADOWMAP: boolean;
  39241. REFLECTIONMAP_3D: boolean;
  39242. REFLECTIONMAP_SPHERICAL: boolean;
  39243. REFLECTIONMAP_PLANAR: boolean;
  39244. REFLECTIONMAP_CUBIC: boolean;
  39245. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39246. REFLECTIONMAP_PROJECTION: boolean;
  39247. REFLECTIONMAP_SKYBOX: boolean;
  39248. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39249. REFLECTIONMAP_EXPLICIT: boolean;
  39250. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39251. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39252. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39253. INVERTCUBICMAP: boolean;
  39254. LOGARITHMICDEPTH: boolean;
  39255. REFRACTION: boolean;
  39256. REFRACTIONMAP_3D: boolean;
  39257. REFLECTIONOVERALPHA: boolean;
  39258. TWOSIDEDLIGHTING: boolean;
  39259. SHADOWFLOAT: boolean;
  39260. MORPHTARGETS: boolean;
  39261. MORPHTARGETS_NORMAL: boolean;
  39262. MORPHTARGETS_TANGENT: boolean;
  39263. NUM_MORPH_INFLUENCERS: number;
  39264. NONUNIFORMSCALING: boolean;
  39265. PREMULTIPLYALPHA: boolean;
  39266. IMAGEPROCESSING: boolean;
  39267. VIGNETTE: boolean;
  39268. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39269. VIGNETTEBLENDMODEOPAQUE: boolean;
  39270. TONEMAPPING: boolean;
  39271. TONEMAPPING_ACES: boolean;
  39272. CONTRAST: boolean;
  39273. COLORCURVES: boolean;
  39274. COLORGRADING: boolean;
  39275. COLORGRADING3D: boolean;
  39276. SAMPLER3DGREENDEPTH: boolean;
  39277. SAMPLER3DBGRMAP: boolean;
  39278. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39279. /**
  39280. * If the reflection texture on this material is in linear color space
  39281. * @hidden
  39282. */
  39283. IS_REFLECTION_LINEAR: boolean;
  39284. /**
  39285. * If the refraction texture on this material is in linear color space
  39286. * @hidden
  39287. */
  39288. IS_REFRACTION_LINEAR: boolean;
  39289. EXPOSURE: boolean;
  39290. constructor();
  39291. setReflectionMode(modeToEnable: string): void;
  39292. }
  39293. /**
  39294. * This is the default material used in Babylon. It is the best trade off between quality
  39295. * and performances.
  39296. * @see http://doc.babylonjs.com/babylon101/materials
  39297. */
  39298. export class StandardMaterial extends PushMaterial {
  39299. private _diffuseTexture;
  39300. /**
  39301. * The basic texture of the material as viewed under a light.
  39302. */
  39303. diffuseTexture: Nullable<BaseTexture>;
  39304. private _ambientTexture;
  39305. /**
  39306. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39307. */
  39308. ambientTexture: Nullable<BaseTexture>;
  39309. private _opacityTexture;
  39310. /**
  39311. * Define the transparency of the material from a texture.
  39312. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39313. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39314. */
  39315. opacityTexture: Nullable<BaseTexture>;
  39316. private _reflectionTexture;
  39317. /**
  39318. * Define the texture used to display the reflection.
  39319. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39320. */
  39321. reflectionTexture: Nullable<BaseTexture>;
  39322. private _emissiveTexture;
  39323. /**
  39324. * Define texture of the material as if self lit.
  39325. * This will be mixed in the final result even in the absence of light.
  39326. */
  39327. emissiveTexture: Nullable<BaseTexture>;
  39328. private _specularTexture;
  39329. /**
  39330. * Define how the color and intensity of the highlight given by the light in the material.
  39331. */
  39332. specularTexture: Nullable<BaseTexture>;
  39333. private _bumpTexture;
  39334. /**
  39335. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39336. * 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.
  39337. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39338. */
  39339. bumpTexture: Nullable<BaseTexture>;
  39340. private _lightmapTexture;
  39341. /**
  39342. * Complex lighting can be computationally expensive to compute at runtime.
  39343. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39344. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39345. */
  39346. lightmapTexture: Nullable<BaseTexture>;
  39347. private _refractionTexture;
  39348. /**
  39349. * Define the texture used to display the refraction.
  39350. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39351. */
  39352. refractionTexture: Nullable<BaseTexture>;
  39353. /**
  39354. * The color of the material lit by the environmental background lighting.
  39355. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39356. */
  39357. ambientColor: Color3;
  39358. /**
  39359. * The basic color of the material as viewed under a light.
  39360. */
  39361. diffuseColor: Color3;
  39362. /**
  39363. * Define how the color and intensity of the highlight given by the light in the material.
  39364. */
  39365. specularColor: Color3;
  39366. /**
  39367. * Define the color of the material as if self lit.
  39368. * This will be mixed in the final result even in the absence of light.
  39369. */
  39370. emissiveColor: Color3;
  39371. /**
  39372. * Defines how sharp are the highlights in the material.
  39373. * The bigger the value the sharper giving a more glossy feeling to the result.
  39374. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39375. */
  39376. specularPower: number;
  39377. private _useAlphaFromDiffuseTexture;
  39378. /**
  39379. * Does the transparency come from the diffuse texture alpha channel.
  39380. */
  39381. useAlphaFromDiffuseTexture: boolean;
  39382. private _useEmissiveAsIllumination;
  39383. /**
  39384. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39385. */
  39386. useEmissiveAsIllumination: boolean;
  39387. private _linkEmissiveWithDiffuse;
  39388. /**
  39389. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39390. * the emissive level when the final color is close to one.
  39391. */
  39392. linkEmissiveWithDiffuse: boolean;
  39393. private _useSpecularOverAlpha;
  39394. /**
  39395. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39396. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39397. */
  39398. useSpecularOverAlpha: boolean;
  39399. private _useReflectionOverAlpha;
  39400. /**
  39401. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39402. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39403. */
  39404. useReflectionOverAlpha: boolean;
  39405. private _disableLighting;
  39406. /**
  39407. * Does lights from the scene impacts this material.
  39408. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39409. */
  39410. disableLighting: boolean;
  39411. private _useObjectSpaceNormalMap;
  39412. /**
  39413. * Allows using an object space normal map (instead of tangent space).
  39414. */
  39415. useObjectSpaceNormalMap: boolean;
  39416. private _useParallax;
  39417. /**
  39418. * Is parallax enabled or not.
  39419. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39420. */
  39421. useParallax: boolean;
  39422. private _useParallaxOcclusion;
  39423. /**
  39424. * Is parallax occlusion enabled or not.
  39425. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39426. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39427. */
  39428. useParallaxOcclusion: boolean;
  39429. /**
  39430. * 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.
  39431. */
  39432. parallaxScaleBias: number;
  39433. private _roughness;
  39434. /**
  39435. * Helps to define how blurry the reflections should appears in the material.
  39436. */
  39437. roughness: number;
  39438. /**
  39439. * In case of refraction, define the value of the indice of refraction.
  39440. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39441. */
  39442. indexOfRefraction: number;
  39443. /**
  39444. * Invert the refraction texture alongside the y axis.
  39445. * It can be useful with procedural textures or probe for instance.
  39446. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39447. */
  39448. invertRefractionY: boolean;
  39449. /**
  39450. * Defines the alpha limits in alpha test mode.
  39451. */
  39452. alphaCutOff: number;
  39453. private _useLightmapAsShadowmap;
  39454. /**
  39455. * In case of light mapping, define whether the map contains light or shadow informations.
  39456. */
  39457. useLightmapAsShadowmap: boolean;
  39458. private _diffuseFresnelParameters;
  39459. /**
  39460. * Define the diffuse fresnel parameters of the material.
  39461. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39462. */
  39463. diffuseFresnelParameters: FresnelParameters;
  39464. private _opacityFresnelParameters;
  39465. /**
  39466. * Define the opacity fresnel parameters of the material.
  39467. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39468. */
  39469. opacityFresnelParameters: FresnelParameters;
  39470. private _reflectionFresnelParameters;
  39471. /**
  39472. * Define the reflection fresnel parameters of the material.
  39473. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39474. */
  39475. reflectionFresnelParameters: FresnelParameters;
  39476. private _refractionFresnelParameters;
  39477. /**
  39478. * Define the refraction fresnel parameters of the material.
  39479. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39480. */
  39481. refractionFresnelParameters: FresnelParameters;
  39482. private _emissiveFresnelParameters;
  39483. /**
  39484. * Define the emissive fresnel parameters of the material.
  39485. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39486. */
  39487. emissiveFresnelParameters: FresnelParameters;
  39488. private _useReflectionFresnelFromSpecular;
  39489. /**
  39490. * If true automatically deducts the fresnels values from the material specularity.
  39491. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39492. */
  39493. useReflectionFresnelFromSpecular: boolean;
  39494. private _useGlossinessFromSpecularMapAlpha;
  39495. /**
  39496. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39497. */
  39498. useGlossinessFromSpecularMapAlpha: boolean;
  39499. private _maxSimultaneousLights;
  39500. /**
  39501. * Defines the maximum number of lights that can be used in the material
  39502. */
  39503. maxSimultaneousLights: number;
  39504. private _invertNormalMapX;
  39505. /**
  39506. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39507. */
  39508. invertNormalMapX: boolean;
  39509. private _invertNormalMapY;
  39510. /**
  39511. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39512. */
  39513. invertNormalMapY: boolean;
  39514. private _twoSidedLighting;
  39515. /**
  39516. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39517. */
  39518. twoSidedLighting: boolean;
  39519. /**
  39520. * Default configuration related to image processing available in the standard Material.
  39521. */
  39522. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39523. /**
  39524. * Gets the image processing configuration used either in this material.
  39525. */
  39526. /**
  39527. * Sets the Default image processing configuration used either in the this material.
  39528. *
  39529. * If sets to null, the scene one is in use.
  39530. */
  39531. imageProcessingConfiguration: ImageProcessingConfiguration;
  39532. /**
  39533. * Keep track of the image processing observer to allow dispose and replace.
  39534. */
  39535. private _imageProcessingObserver;
  39536. /**
  39537. * Attaches a new image processing configuration to the Standard Material.
  39538. * @param configuration
  39539. */
  39540. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39541. /**
  39542. * Gets wether the color curves effect is enabled.
  39543. */
  39544. /**
  39545. * Sets wether the color curves effect is enabled.
  39546. */
  39547. cameraColorCurvesEnabled: boolean;
  39548. /**
  39549. * Gets wether the color grading effect is enabled.
  39550. */
  39551. /**
  39552. * Gets wether the color grading effect is enabled.
  39553. */
  39554. cameraColorGradingEnabled: boolean;
  39555. /**
  39556. * Gets wether tonemapping is enabled or not.
  39557. */
  39558. /**
  39559. * Sets wether tonemapping is enabled or not
  39560. */
  39561. cameraToneMappingEnabled: boolean;
  39562. /**
  39563. * The camera exposure used on this material.
  39564. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39565. * This corresponds to a photographic exposure.
  39566. */
  39567. /**
  39568. * The camera exposure used on this material.
  39569. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39570. * This corresponds to a photographic exposure.
  39571. */
  39572. cameraExposure: number;
  39573. /**
  39574. * Gets The camera contrast used on this material.
  39575. */
  39576. /**
  39577. * Sets The camera contrast used on this material.
  39578. */
  39579. cameraContrast: number;
  39580. /**
  39581. * Gets the Color Grading 2D Lookup Texture.
  39582. */
  39583. /**
  39584. * Sets the Color Grading 2D Lookup Texture.
  39585. */
  39586. cameraColorGradingTexture: Nullable<BaseTexture>;
  39587. /**
  39588. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39589. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39590. * 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;
  39591. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39592. */
  39593. /**
  39594. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39595. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39596. * 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;
  39597. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39598. */
  39599. cameraColorCurves: Nullable<ColorCurves>;
  39600. /**
  39601. * Custom callback helping to override the default shader used in the material.
  39602. */
  39603. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39604. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39605. protected _worldViewProjectionMatrix: Matrix;
  39606. protected _globalAmbientColor: Color3;
  39607. protected _useLogarithmicDepth: boolean;
  39608. /**
  39609. * Instantiates a new standard material.
  39610. * This is the default material used in Babylon. It is the best trade off between quality
  39611. * and performances.
  39612. * @see http://doc.babylonjs.com/babylon101/materials
  39613. * @param name Define the name of the material in the scene
  39614. * @param scene Define the scene the material belong to
  39615. */
  39616. constructor(name: string, scene: Scene);
  39617. /**
  39618. * Gets a boolean indicating that current material needs to register RTT
  39619. */
  39620. readonly hasRenderTargetTextures: boolean;
  39621. /**
  39622. * Gets the current class name of the material e.g. "StandardMaterial"
  39623. * Mainly use in serialization.
  39624. * @returns the class name
  39625. */
  39626. getClassName(): string;
  39627. /**
  39628. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39629. * You can try switching to logarithmic depth.
  39630. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39631. */
  39632. useLogarithmicDepth: boolean;
  39633. /**
  39634. * Specifies if the material will require alpha blending
  39635. * @returns a boolean specifying if alpha blending is needed
  39636. */
  39637. needAlphaBlending(): boolean;
  39638. /**
  39639. * Specifies if this material should be rendered in alpha test mode
  39640. * @returns a boolean specifying if an alpha test is needed.
  39641. */
  39642. needAlphaTesting(): boolean;
  39643. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39644. /**
  39645. * Get the texture used for alpha test purpose.
  39646. * @returns the diffuse texture in case of the standard material.
  39647. */
  39648. getAlphaTestTexture(): Nullable<BaseTexture>;
  39649. /**
  39650. * Get if the submesh is ready to be used and all its information available.
  39651. * Child classes can use it to update shaders
  39652. * @param mesh defines the mesh to check
  39653. * @param subMesh defines which submesh to check
  39654. * @param useInstances specifies that instances should be used
  39655. * @returns a boolean indicating that the submesh is ready or not
  39656. */
  39657. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39658. /**
  39659. * Builds the material UBO layouts.
  39660. * Used internally during the effect preparation.
  39661. */
  39662. buildUniformLayout(): void;
  39663. /**
  39664. * Unbinds the material from the mesh
  39665. */
  39666. unbind(): void;
  39667. /**
  39668. * Binds the submesh to this material by preparing the effect and shader to draw
  39669. * @param world defines the world transformation matrix
  39670. * @param mesh defines the mesh containing the submesh
  39671. * @param subMesh defines the submesh to bind the material to
  39672. */
  39673. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39674. /**
  39675. * Get the list of animatables in the material.
  39676. * @returns the list of animatables object used in the material
  39677. */
  39678. getAnimatables(): IAnimatable[];
  39679. /**
  39680. * Gets the active textures from the material
  39681. * @returns an array of textures
  39682. */
  39683. getActiveTextures(): BaseTexture[];
  39684. /**
  39685. * Specifies if the material uses a texture
  39686. * @param texture defines the texture to check against the material
  39687. * @returns a boolean specifying if the material uses the texture
  39688. */
  39689. hasTexture(texture: BaseTexture): boolean;
  39690. /**
  39691. * Disposes the material
  39692. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39693. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39694. */
  39695. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39696. /**
  39697. * Makes a duplicate of the material, and gives it a new name
  39698. * @param name defines the new name for the duplicated material
  39699. * @returns the cloned material
  39700. */
  39701. clone(name: string): StandardMaterial;
  39702. /**
  39703. * Serializes this material in a JSON representation
  39704. * @returns the serialized material object
  39705. */
  39706. serialize(): any;
  39707. /**
  39708. * Creates a standard material from parsed material data
  39709. * @param source defines the JSON representation of the material
  39710. * @param scene defines the hosting scene
  39711. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39712. * @returns a new standard material
  39713. */
  39714. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39715. /**
  39716. * Are diffuse textures enabled in the application.
  39717. */
  39718. static DiffuseTextureEnabled: boolean;
  39719. /**
  39720. * Are ambient textures enabled in the application.
  39721. */
  39722. static AmbientTextureEnabled: boolean;
  39723. /**
  39724. * Are opacity textures enabled in the application.
  39725. */
  39726. static OpacityTextureEnabled: boolean;
  39727. /**
  39728. * Are reflection textures enabled in the application.
  39729. */
  39730. static ReflectionTextureEnabled: boolean;
  39731. /**
  39732. * Are emissive textures enabled in the application.
  39733. */
  39734. static EmissiveTextureEnabled: boolean;
  39735. /**
  39736. * Are specular textures enabled in the application.
  39737. */
  39738. static SpecularTextureEnabled: boolean;
  39739. /**
  39740. * Are bump textures enabled in the application.
  39741. */
  39742. static BumpTextureEnabled: boolean;
  39743. /**
  39744. * Are lightmap textures enabled in the application.
  39745. */
  39746. static LightmapTextureEnabled: boolean;
  39747. /**
  39748. * Are refraction textures enabled in the application.
  39749. */
  39750. static RefractionTextureEnabled: boolean;
  39751. /**
  39752. * Are color grading textures enabled in the application.
  39753. */
  39754. static ColorGradingTextureEnabled: boolean;
  39755. /**
  39756. * Are fresnels enabled in the application.
  39757. */
  39758. static FresnelEnabled: boolean;
  39759. }
  39760. }
  39761. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  39762. import { Scene } from "babylonjs/scene";
  39763. import { Texture } from "babylonjs/Materials/Textures/texture";
  39764. /**
  39765. * A class extending Texture allowing drawing on a texture
  39766. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39767. */
  39768. export class DynamicTexture extends Texture {
  39769. private _generateMipMaps;
  39770. private _canvas;
  39771. private _context;
  39772. private _engine;
  39773. /**
  39774. * Creates a DynamicTexture
  39775. * @param name defines the name of the texture
  39776. * @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
  39777. * @param scene defines the scene where you want the texture
  39778. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39779. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39780. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39781. */
  39782. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39783. /**
  39784. * Get the current class name of the texture useful for serialization or dynamic coding.
  39785. * @returns "DynamicTexture"
  39786. */
  39787. getClassName(): string;
  39788. /**
  39789. * Gets the current state of canRescale
  39790. */
  39791. readonly canRescale: boolean;
  39792. private _recreate;
  39793. /**
  39794. * Scales the texture
  39795. * @param ratio the scale factor to apply to both width and height
  39796. */
  39797. scale(ratio: number): void;
  39798. /**
  39799. * Resizes the texture
  39800. * @param width the new width
  39801. * @param height the new height
  39802. */
  39803. scaleTo(width: number, height: number): void;
  39804. /**
  39805. * Gets the context of the canvas used by the texture
  39806. * @returns the canvas context of the dynamic texture
  39807. */
  39808. getContext(): CanvasRenderingContext2D;
  39809. /**
  39810. * Clears the texture
  39811. */
  39812. clear(): void;
  39813. /**
  39814. * Updates the texture
  39815. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39816. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39817. */
  39818. update(invertY?: boolean, premulAlpha?: boolean): void;
  39819. /**
  39820. * Draws text onto the texture
  39821. * @param text defines the text to be drawn
  39822. * @param x defines the placement of the text from the left
  39823. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39824. * @param font defines the font to be used with font-style, font-size, font-name
  39825. * @param color defines the color used for the text
  39826. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39827. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39828. * @param update defines whether texture is immediately update (default is true)
  39829. */
  39830. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39831. /**
  39832. * Clones the texture
  39833. * @returns the clone of the texture.
  39834. */
  39835. clone(): DynamicTexture;
  39836. /**
  39837. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39838. * @returns a serialized dynamic texture object
  39839. */
  39840. serialize(): any;
  39841. /** @hidden */
  39842. _rebuild(): void;
  39843. }
  39844. }
  39845. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39846. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39847. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39848. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39849. /** @hidden */
  39850. export var imageProcessingPixelShader: {
  39851. name: string;
  39852. shader: string;
  39853. };
  39854. }
  39855. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39856. import { Nullable } from "babylonjs/types";
  39857. import { Color4 } from "babylonjs/Maths/math";
  39858. import { Camera } from "babylonjs/Cameras/camera";
  39859. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39860. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39861. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39862. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39863. import { Engine } from "babylonjs/Engines/engine";
  39864. import "babylonjs/Shaders/imageProcessing.fragment";
  39865. import "babylonjs/Shaders/postprocess.vertex";
  39866. /**
  39867. * ImageProcessingPostProcess
  39868. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39869. */
  39870. export class ImageProcessingPostProcess extends PostProcess {
  39871. /**
  39872. * Default configuration related to image processing available in the PBR Material.
  39873. */
  39874. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39875. /**
  39876. * Gets the image processing configuration used either in this material.
  39877. */
  39878. /**
  39879. * Sets the Default image processing configuration used either in the this material.
  39880. *
  39881. * If sets to null, the scene one is in use.
  39882. */
  39883. imageProcessingConfiguration: ImageProcessingConfiguration;
  39884. /**
  39885. * Keep track of the image processing observer to allow dispose and replace.
  39886. */
  39887. private _imageProcessingObserver;
  39888. /**
  39889. * Attaches a new image processing configuration to the PBR Material.
  39890. * @param configuration
  39891. */
  39892. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39893. /**
  39894. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39895. */
  39896. /**
  39897. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39898. */
  39899. colorCurves: Nullable<ColorCurves>;
  39900. /**
  39901. * Gets wether the color curves effect is enabled.
  39902. */
  39903. /**
  39904. * Sets wether the color curves effect is enabled.
  39905. */
  39906. colorCurvesEnabled: boolean;
  39907. /**
  39908. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39909. */
  39910. /**
  39911. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39912. */
  39913. colorGradingTexture: Nullable<BaseTexture>;
  39914. /**
  39915. * Gets wether the color grading effect is enabled.
  39916. */
  39917. /**
  39918. * Gets wether the color grading effect is enabled.
  39919. */
  39920. colorGradingEnabled: boolean;
  39921. /**
  39922. * Gets exposure used in the effect.
  39923. */
  39924. /**
  39925. * Sets exposure used in the effect.
  39926. */
  39927. exposure: number;
  39928. /**
  39929. * Gets wether tonemapping is enabled or not.
  39930. */
  39931. /**
  39932. * Sets wether tonemapping is enabled or not
  39933. */
  39934. toneMappingEnabled: boolean;
  39935. /**
  39936. * Gets the type of tone mapping effect.
  39937. */
  39938. /**
  39939. * Sets the type of tone mapping effect.
  39940. */
  39941. toneMappingType: number;
  39942. /**
  39943. * Gets contrast used in the effect.
  39944. */
  39945. /**
  39946. * Sets contrast used in the effect.
  39947. */
  39948. contrast: number;
  39949. /**
  39950. * Gets Vignette stretch size.
  39951. */
  39952. /**
  39953. * Sets Vignette stretch size.
  39954. */
  39955. vignetteStretch: number;
  39956. /**
  39957. * Gets Vignette centre X Offset.
  39958. */
  39959. /**
  39960. * Sets Vignette centre X Offset.
  39961. */
  39962. vignetteCentreX: number;
  39963. /**
  39964. * Gets Vignette centre Y Offset.
  39965. */
  39966. /**
  39967. * Sets Vignette centre Y Offset.
  39968. */
  39969. vignetteCentreY: number;
  39970. /**
  39971. * Gets Vignette weight or intensity of the vignette effect.
  39972. */
  39973. /**
  39974. * Sets Vignette weight or intensity of the vignette effect.
  39975. */
  39976. vignetteWeight: number;
  39977. /**
  39978. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39979. * if vignetteEnabled is set to true.
  39980. */
  39981. /**
  39982. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39983. * if vignetteEnabled is set to true.
  39984. */
  39985. vignetteColor: Color4;
  39986. /**
  39987. * Gets Camera field of view used by the Vignette effect.
  39988. */
  39989. /**
  39990. * Sets Camera field of view used by the Vignette effect.
  39991. */
  39992. vignetteCameraFov: number;
  39993. /**
  39994. * Gets the vignette blend mode allowing different kind of effect.
  39995. */
  39996. /**
  39997. * Sets the vignette blend mode allowing different kind of effect.
  39998. */
  39999. vignetteBlendMode: number;
  40000. /**
  40001. * Gets wether the vignette effect is enabled.
  40002. */
  40003. /**
  40004. * Sets wether the vignette effect is enabled.
  40005. */
  40006. vignetteEnabled: boolean;
  40007. private _fromLinearSpace;
  40008. /**
  40009. * Gets wether the input of the processing is in Gamma or Linear Space.
  40010. */
  40011. /**
  40012. * Sets wether the input of the processing is in Gamma or Linear Space.
  40013. */
  40014. fromLinearSpace: boolean;
  40015. /**
  40016. * Defines cache preventing GC.
  40017. */
  40018. private _defines;
  40019. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40020. /**
  40021. * "ImageProcessingPostProcess"
  40022. * @returns "ImageProcessingPostProcess"
  40023. */
  40024. getClassName(): string;
  40025. protected _updateParameters(): void;
  40026. dispose(camera?: Camera): void;
  40027. }
  40028. }
  40029. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40030. import { Scene } from "babylonjs/scene";
  40031. import { Color3 } from "babylonjs/Maths/math";
  40032. import { Mesh } from "babylonjs/Meshes/mesh";
  40033. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40034. /**
  40035. * Class containing static functions to help procedurally build meshes
  40036. */
  40037. export class GroundBuilder {
  40038. /**
  40039. * Creates a ground mesh
  40040. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40041. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40043. * @param name defines the name of the mesh
  40044. * @param options defines the options used to create the mesh
  40045. * @param scene defines the hosting scene
  40046. * @returns the ground mesh
  40047. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40048. */
  40049. static CreateGround(name: string, options: {
  40050. width?: number;
  40051. height?: number;
  40052. subdivisions?: number;
  40053. subdivisionsX?: number;
  40054. subdivisionsY?: number;
  40055. updatable?: boolean;
  40056. }, scene: any): Mesh;
  40057. /**
  40058. * Creates a tiled ground mesh
  40059. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40060. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40061. * * 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
  40062. * * 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
  40063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40064. * @param name defines the name of the mesh
  40065. * @param options defines the options used to create the mesh
  40066. * @param scene defines the hosting scene
  40067. * @returns the tiled ground mesh
  40068. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40069. */
  40070. static CreateTiledGround(name: string, options: {
  40071. xmin: number;
  40072. zmin: number;
  40073. xmax: number;
  40074. zmax: number;
  40075. subdivisions?: {
  40076. w: number;
  40077. h: number;
  40078. };
  40079. precision?: {
  40080. w: number;
  40081. h: number;
  40082. };
  40083. updatable?: boolean;
  40084. }, scene: Scene): Mesh;
  40085. /**
  40086. * Creates a ground mesh from a height map
  40087. * * The parameter `url` sets the URL of the height map image resource.
  40088. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40089. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40090. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40091. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40092. * * 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.
  40093. * * 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).
  40094. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40096. * @param name defines the name of the mesh
  40097. * @param url defines the url to the height map
  40098. * @param options defines the options used to create the mesh
  40099. * @param scene defines the hosting scene
  40100. * @returns the ground mesh
  40101. * @see https://doc.babylonjs.com/babylon101/height_map
  40102. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40103. */
  40104. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40105. width?: number;
  40106. height?: number;
  40107. subdivisions?: number;
  40108. minHeight?: number;
  40109. maxHeight?: number;
  40110. colorFilter?: Color3;
  40111. alphaFilter?: number;
  40112. updatable?: boolean;
  40113. onReady?: (mesh: GroundMesh) => void;
  40114. }, scene: Scene): GroundMesh;
  40115. }
  40116. }
  40117. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40118. import { Vector4 } from "babylonjs/Maths/math";
  40119. import { Mesh } from "babylonjs/Meshes/mesh";
  40120. /**
  40121. * Class containing static functions to help procedurally build meshes
  40122. */
  40123. export class TorusBuilder {
  40124. /**
  40125. * Creates a torus mesh
  40126. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40127. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40128. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40129. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40130. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40132. * @param name defines the name of the mesh
  40133. * @param options defines the options used to create the mesh
  40134. * @param scene defines the hosting scene
  40135. * @returns the torus mesh
  40136. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40137. */
  40138. static CreateTorus(name: string, options: {
  40139. diameter?: number;
  40140. thickness?: number;
  40141. tessellation?: number;
  40142. updatable?: boolean;
  40143. sideOrientation?: number;
  40144. frontUVs?: Vector4;
  40145. backUVs?: Vector4;
  40146. }, scene: any): Mesh;
  40147. }
  40148. }
  40149. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40150. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40151. import { Mesh } from "babylonjs/Meshes/mesh";
  40152. /**
  40153. * Class containing static functions to help procedurally build meshes
  40154. */
  40155. export class CylinderBuilder {
  40156. /**
  40157. * Creates a cylinder or a cone mesh
  40158. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40159. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40160. * * 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.
  40161. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40162. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40163. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40164. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40165. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40166. * * 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).
  40167. * * 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
  40168. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40169. * * 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
  40170. * * 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.
  40171. * * If `enclose` is false, a ring surface is one element.
  40172. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40173. * * 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
  40174. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40175. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40177. * @param name defines the name of the mesh
  40178. * @param options defines the options used to create the mesh
  40179. * @param scene defines the hosting scene
  40180. * @returns the cylinder mesh
  40181. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40182. */
  40183. static CreateCylinder(name: string, options: {
  40184. height?: number;
  40185. diameterTop?: number;
  40186. diameterBottom?: number;
  40187. diameter?: number;
  40188. tessellation?: number;
  40189. subdivisions?: number;
  40190. arc?: number;
  40191. faceColors?: Color4[];
  40192. faceUV?: Vector4[];
  40193. updatable?: boolean;
  40194. hasRings?: boolean;
  40195. enclose?: boolean;
  40196. sideOrientation?: number;
  40197. frontUVs?: Vector4;
  40198. backUVs?: Vector4;
  40199. }, scene: any): Mesh;
  40200. }
  40201. }
  40202. declare module "babylonjs/Gamepads/gamepadManager" {
  40203. import { Observable } from "babylonjs/Misc/observable";
  40204. import { Nullable } from "babylonjs/types";
  40205. import { Scene } from "babylonjs/scene";
  40206. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40207. /**
  40208. * Manager for handling gamepads
  40209. */
  40210. export class GamepadManager {
  40211. private _scene?;
  40212. private _babylonGamepads;
  40213. private _oneGamepadConnected;
  40214. /** @hidden */
  40215. _isMonitoring: boolean;
  40216. private _gamepadEventSupported;
  40217. private _gamepadSupport;
  40218. /**
  40219. * observable to be triggered when the gamepad controller has been connected
  40220. */
  40221. onGamepadConnectedObservable: Observable<Gamepad>;
  40222. /**
  40223. * observable to be triggered when the gamepad controller has been disconnected
  40224. */
  40225. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40226. private _onGamepadConnectedEvent;
  40227. private _onGamepadDisconnectedEvent;
  40228. /**
  40229. * Initializes the gamepad manager
  40230. * @param _scene BabylonJS scene
  40231. */
  40232. constructor(_scene?: Scene | undefined);
  40233. /**
  40234. * The gamepads in the game pad manager
  40235. */
  40236. readonly gamepads: Gamepad[];
  40237. /**
  40238. * Get the gamepad controllers based on type
  40239. * @param type The type of gamepad controller
  40240. * @returns Nullable gamepad
  40241. */
  40242. getGamepadByType(type?: number): Nullable<Gamepad>;
  40243. /**
  40244. * Disposes the gamepad manager
  40245. */
  40246. dispose(): void;
  40247. private _addNewGamepad;
  40248. private _startMonitoringGamepads;
  40249. private _stopMonitoringGamepads;
  40250. /** @hidden */
  40251. _checkGamepadsStatus(): void;
  40252. private _updateGamepadObjects;
  40253. }
  40254. }
  40255. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40256. import { Nullable } from "babylonjs/types";
  40257. import { Scene } from "babylonjs/scene";
  40258. import { ISceneComponent } from "babylonjs/sceneComponent";
  40259. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40260. module "babylonjs/scene" {
  40261. interface Scene {
  40262. /** @hidden */
  40263. _gamepadManager: Nullable<GamepadManager>;
  40264. /**
  40265. * Gets the gamepad manager associated with the scene
  40266. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40267. */
  40268. gamepadManager: GamepadManager;
  40269. }
  40270. }
  40271. module "babylonjs/Cameras/freeCameraInputsManager" {
  40272. /**
  40273. * Interface representing a free camera inputs manager
  40274. */
  40275. interface FreeCameraInputsManager {
  40276. /**
  40277. * Adds gamepad input support to the FreeCameraInputsManager.
  40278. * @returns the FreeCameraInputsManager
  40279. */
  40280. addGamepad(): FreeCameraInputsManager;
  40281. }
  40282. }
  40283. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40284. /**
  40285. * Interface representing an arc rotate camera inputs manager
  40286. */
  40287. interface ArcRotateCameraInputsManager {
  40288. /**
  40289. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40290. * @returns the camera inputs manager
  40291. */
  40292. addGamepad(): ArcRotateCameraInputsManager;
  40293. }
  40294. }
  40295. /**
  40296. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40297. */
  40298. export class GamepadSystemSceneComponent implements ISceneComponent {
  40299. /**
  40300. * The component name helpfull to identify the component in the list of scene components.
  40301. */
  40302. readonly name: string;
  40303. /**
  40304. * The scene the component belongs to.
  40305. */
  40306. scene: Scene;
  40307. /**
  40308. * Creates a new instance of the component for the given scene
  40309. * @param scene Defines the scene to register the component in
  40310. */
  40311. constructor(scene: Scene);
  40312. /**
  40313. * Registers the component in a given scene
  40314. */
  40315. register(): void;
  40316. /**
  40317. * Rebuilds the elements related to this component in case of
  40318. * context lost for instance.
  40319. */
  40320. rebuild(): void;
  40321. /**
  40322. * Disposes the component and the associated ressources
  40323. */
  40324. dispose(): void;
  40325. private _beforeCameraUpdate;
  40326. }
  40327. }
  40328. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40329. import { Observable } from "babylonjs/Misc/observable";
  40330. import { Nullable } from "babylonjs/types";
  40331. import { Camera } from "babylonjs/Cameras/camera";
  40332. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40333. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40334. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40335. import { Scene } from "babylonjs/scene";
  40336. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40337. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40339. import { Mesh } from "babylonjs/Meshes/mesh";
  40340. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40341. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40342. import "babylonjs/Meshes/Builders/groundBuilder";
  40343. import "babylonjs/Meshes/Builders/torusBuilder";
  40344. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40345. import "babylonjs/Gamepads/gamepadSceneComponent";
  40346. import "babylonjs/Animations/animatable";
  40347. /**
  40348. * Options to modify the vr teleportation behavior.
  40349. */
  40350. export interface VRTeleportationOptions {
  40351. /**
  40352. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40353. */
  40354. floorMeshName?: string;
  40355. /**
  40356. * A list of meshes to be used as the teleportation floor. (default: empty)
  40357. */
  40358. floorMeshes?: Mesh[];
  40359. }
  40360. /**
  40361. * Options to modify the vr experience helper's behavior.
  40362. */
  40363. export interface VRExperienceHelperOptions extends WebVROptions {
  40364. /**
  40365. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40366. */
  40367. createDeviceOrientationCamera?: boolean;
  40368. /**
  40369. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40370. */
  40371. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40372. /**
  40373. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40374. */
  40375. laserToggle?: boolean;
  40376. /**
  40377. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40378. */
  40379. floorMeshes?: Mesh[];
  40380. /**
  40381. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40382. */
  40383. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40384. }
  40385. /**
  40386. * Event containing information after VR has been entered
  40387. */
  40388. export class OnAfterEnteringVRObservableEvent {
  40389. /**
  40390. * If entering vr was successful
  40391. */
  40392. success: boolean;
  40393. }
  40394. /**
  40395. * Helps to quickly add VR support to an existing scene.
  40396. * See http://doc.babylonjs.com/how_to/webvr_helper
  40397. */
  40398. export class VRExperienceHelper {
  40399. /** Options to modify the vr experience helper's behavior. */
  40400. webVROptions: VRExperienceHelperOptions;
  40401. private _scene;
  40402. private _position;
  40403. private _btnVR;
  40404. private _btnVRDisplayed;
  40405. private _webVRsupported;
  40406. private _webVRready;
  40407. private _webVRrequesting;
  40408. private _webVRpresenting;
  40409. private _hasEnteredVR;
  40410. private _fullscreenVRpresenting;
  40411. private _canvas;
  40412. private _webVRCamera;
  40413. private _vrDeviceOrientationCamera;
  40414. private _deviceOrientationCamera;
  40415. private _existingCamera;
  40416. private _onKeyDown;
  40417. private _onVrDisplayPresentChange;
  40418. private _onVRDisplayChanged;
  40419. private _onVRRequestPresentStart;
  40420. private _onVRRequestPresentComplete;
  40421. /**
  40422. * Observable raised right before entering VR.
  40423. */
  40424. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40425. /**
  40426. * Observable raised when entering VR has completed.
  40427. */
  40428. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40429. /**
  40430. * Observable raised when exiting VR.
  40431. */
  40432. onExitingVRObservable: Observable<VRExperienceHelper>;
  40433. /**
  40434. * Observable raised when controller mesh is loaded.
  40435. */
  40436. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40437. /** Return this.onEnteringVRObservable
  40438. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40439. */
  40440. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40441. /** Return this.onExitingVRObservable
  40442. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40443. */
  40444. readonly onExitingVR: Observable<VRExperienceHelper>;
  40445. /** Return this.onControllerMeshLoadedObservable
  40446. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40447. */
  40448. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40449. private _rayLength;
  40450. private _useCustomVRButton;
  40451. private _teleportationRequested;
  40452. private _teleportActive;
  40453. private _floorMeshName;
  40454. private _floorMeshesCollection;
  40455. private _rotationAllowed;
  40456. private _teleportBackwardsVector;
  40457. private _teleportationTarget;
  40458. private _isDefaultTeleportationTarget;
  40459. private _postProcessMove;
  40460. private _teleportationFillColor;
  40461. private _teleportationBorderColor;
  40462. private _rotationAngle;
  40463. private _haloCenter;
  40464. private _cameraGazer;
  40465. private _padSensibilityUp;
  40466. private _padSensibilityDown;
  40467. private _leftController;
  40468. private _rightController;
  40469. /**
  40470. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40471. */
  40472. onNewMeshSelected: Observable<AbstractMesh>;
  40473. /**
  40474. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40475. */
  40476. onNewMeshPicked: Observable<PickingInfo>;
  40477. private _circleEase;
  40478. /**
  40479. * Observable raised before camera teleportation
  40480. */
  40481. onBeforeCameraTeleport: Observable<Vector3>;
  40482. /**
  40483. * Observable raised after camera teleportation
  40484. */
  40485. onAfterCameraTeleport: Observable<Vector3>;
  40486. /**
  40487. * Observable raised when current selected mesh gets unselected
  40488. */
  40489. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40490. private _raySelectionPredicate;
  40491. /**
  40492. * To be optionaly changed by user to define custom ray selection
  40493. */
  40494. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40495. /**
  40496. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40497. */
  40498. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40499. /**
  40500. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40501. */
  40502. teleportationEnabled: boolean;
  40503. private _defaultHeight;
  40504. private _teleportationInitialized;
  40505. private _interactionsEnabled;
  40506. private _interactionsRequested;
  40507. private _displayGaze;
  40508. private _displayLaserPointer;
  40509. /**
  40510. * The mesh used to display where the user is going to teleport.
  40511. */
  40512. /**
  40513. * Sets the mesh to be used to display where the user is going to teleport.
  40514. */
  40515. teleportationTarget: Mesh;
  40516. /**
  40517. * 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
  40518. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40519. * See http://doc.babylonjs.com/resources/baking_transformations
  40520. */
  40521. gazeTrackerMesh: Mesh;
  40522. /**
  40523. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40524. */
  40525. updateGazeTrackerScale: boolean;
  40526. /**
  40527. * If the gaze trackers color should be updated when selecting meshes
  40528. */
  40529. updateGazeTrackerColor: boolean;
  40530. /**
  40531. * The gaze tracking mesh corresponding to the left controller
  40532. */
  40533. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40534. /**
  40535. * The gaze tracking mesh corresponding to the right controller
  40536. */
  40537. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40538. /**
  40539. * If the ray of the gaze should be displayed.
  40540. */
  40541. /**
  40542. * Sets if the ray of the gaze should be displayed.
  40543. */
  40544. displayGaze: boolean;
  40545. /**
  40546. * If the ray of the LaserPointer should be displayed.
  40547. */
  40548. /**
  40549. * Sets if the ray of the LaserPointer should be displayed.
  40550. */
  40551. displayLaserPointer: boolean;
  40552. /**
  40553. * The deviceOrientationCamera used as the camera when not in VR.
  40554. */
  40555. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40556. /**
  40557. * Based on the current WebVR support, returns the current VR camera used.
  40558. */
  40559. readonly currentVRCamera: Nullable<Camera>;
  40560. /**
  40561. * The webVRCamera which is used when in VR.
  40562. */
  40563. readonly webVRCamera: WebVRFreeCamera;
  40564. /**
  40565. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40566. */
  40567. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40568. private readonly _teleportationRequestInitiated;
  40569. /**
  40570. * Defines wether or not Pointer lock should be requested when switching to
  40571. * full screen.
  40572. */
  40573. requestPointerLockOnFullScreen: boolean;
  40574. /**
  40575. * Instantiates a VRExperienceHelper.
  40576. * Helps to quickly add VR support to an existing scene.
  40577. * @param scene The scene the VRExperienceHelper belongs to.
  40578. * @param webVROptions Options to modify the vr experience helper's behavior.
  40579. */
  40580. constructor(scene: Scene,
  40581. /** Options to modify the vr experience helper's behavior. */
  40582. webVROptions?: VRExperienceHelperOptions);
  40583. private _onDefaultMeshLoaded;
  40584. private _onResize;
  40585. private _onFullscreenChange;
  40586. /**
  40587. * Gets a value indicating if we are currently in VR mode.
  40588. */
  40589. readonly isInVRMode: boolean;
  40590. private onVrDisplayPresentChange;
  40591. private onVRDisplayChanged;
  40592. private moveButtonToBottomRight;
  40593. private displayVRButton;
  40594. private updateButtonVisibility;
  40595. private _cachedAngularSensibility;
  40596. /**
  40597. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40598. * Otherwise, will use the fullscreen API.
  40599. */
  40600. enterVR(): void;
  40601. /**
  40602. * Attempt to exit VR, or fullscreen.
  40603. */
  40604. exitVR(): void;
  40605. /**
  40606. * The position of the vr experience helper.
  40607. */
  40608. /**
  40609. * Sets the position of the vr experience helper.
  40610. */
  40611. position: Vector3;
  40612. /**
  40613. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40614. */
  40615. enableInteractions(): void;
  40616. private readonly _noControllerIsActive;
  40617. private beforeRender;
  40618. private _isTeleportationFloor;
  40619. /**
  40620. * Adds a floor mesh to be used for teleportation.
  40621. * @param floorMesh the mesh to be used for teleportation.
  40622. */
  40623. addFloorMesh(floorMesh: Mesh): void;
  40624. /**
  40625. * Removes a floor mesh from being used for teleportation.
  40626. * @param floorMesh the mesh to be removed.
  40627. */
  40628. removeFloorMesh(floorMesh: Mesh): void;
  40629. /**
  40630. * Enables interactions and teleportation using the VR controllers and gaze.
  40631. * @param vrTeleportationOptions options to modify teleportation behavior.
  40632. */
  40633. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40634. private _onNewGamepadConnected;
  40635. private _tryEnableInteractionOnController;
  40636. private _onNewGamepadDisconnected;
  40637. private _enableInteractionOnController;
  40638. private _checkTeleportWithRay;
  40639. private _checkRotate;
  40640. private _checkTeleportBackwards;
  40641. private _enableTeleportationOnController;
  40642. private _createTeleportationCircles;
  40643. private _displayTeleportationTarget;
  40644. private _hideTeleportationTarget;
  40645. private _rotateCamera;
  40646. private _moveTeleportationSelectorTo;
  40647. private _workingVector;
  40648. private _workingQuaternion;
  40649. private _workingMatrix;
  40650. /**
  40651. * Teleports the users feet to the desired location
  40652. * @param location The location where the user's feet should be placed
  40653. */
  40654. teleportCamera(location: Vector3): void;
  40655. private _convertNormalToDirectionOfRay;
  40656. private _castRayAndSelectObject;
  40657. private _notifySelectedMeshUnselected;
  40658. /**
  40659. * Sets the color of the laser ray from the vr controllers.
  40660. * @param color new color for the ray.
  40661. */
  40662. changeLaserColor(color: Color3): void;
  40663. /**
  40664. * Sets the color of the ray from the vr headsets gaze.
  40665. * @param color new color for the ray.
  40666. */
  40667. changeGazeColor(color: Color3): void;
  40668. /**
  40669. * Exits VR and disposes of the vr experience helper
  40670. */
  40671. dispose(): void;
  40672. /**
  40673. * Gets the name of the VRExperienceHelper class
  40674. * @returns "VRExperienceHelper"
  40675. */
  40676. getClassName(): string;
  40677. }
  40678. }
  40679. declare module "babylonjs/Cameras/VR/index" {
  40680. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  40681. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  40682. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40683. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  40684. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  40685. export * from "babylonjs/Cameras/VR/webVRCamera";
  40686. }
  40687. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  40688. import { Observable } from "babylonjs/Misc/observable";
  40689. import { Nullable } from "babylonjs/types";
  40690. import { IDisposable, Scene } from "babylonjs/scene";
  40691. import { Vector3 } from "babylonjs/Maths/math";
  40692. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40693. import { Ray } from "babylonjs/Culling/ray";
  40694. /**
  40695. * Manages an XRSession
  40696. * @see https://doc.babylonjs.com/how_to/webxr
  40697. */
  40698. export class WebXRSessionManager implements IDisposable {
  40699. private scene;
  40700. /**
  40701. * Fires every time a new xrFrame arrives which can be used to update the camera
  40702. */
  40703. onXRFrameObservable: Observable<any>;
  40704. /**
  40705. * Fires when the xr session is ended either by the device or manually done
  40706. */
  40707. onXRSessionEnded: Observable<any>;
  40708. /** @hidden */
  40709. _xrSession: XRSession;
  40710. /** @hidden */
  40711. _frameOfReference: XRFrameOfReference;
  40712. /** @hidden */
  40713. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40714. /** @hidden */
  40715. _currentXRFrame: Nullable<XRFrame>;
  40716. private _xrNavigator;
  40717. private _xrDevice;
  40718. private _tmpMatrix;
  40719. /**
  40720. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40721. * @param scene The scene which the session should be created for
  40722. */
  40723. constructor(scene: Scene);
  40724. /**
  40725. * Initializes the manager
  40726. * After initialization enterXR can be called to start an XR session
  40727. * @returns Promise which resolves after it is initialized
  40728. */
  40729. initializeAsync(): Promise<void>;
  40730. /**
  40731. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40732. * @param sessionCreationOptions xr options to create the session with
  40733. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40734. * @returns Promise which resolves after it enters XR
  40735. */
  40736. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40737. /**
  40738. * Stops the xrSession and restores the renderloop
  40739. * @returns Promise which resolves after it exits XR
  40740. */
  40741. exitXRAsync(): Promise<void>;
  40742. /**
  40743. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40744. * @param ray ray to cast into the environment
  40745. * @returns Promise which resolves with a collision point in the environment if it exists
  40746. */
  40747. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40748. /**
  40749. * Checks if a session would be supported for the creation options specified
  40750. * @param options creation options to check if they are supported
  40751. * @returns true if supported
  40752. */
  40753. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40754. /**
  40755. * @hidden
  40756. * Converts the render layer of xrSession to a render target
  40757. * @param session session to create render target for
  40758. * @param scene scene the new render target should be created for
  40759. */
  40760. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40761. /**
  40762. * Disposes of the session manager
  40763. */
  40764. dispose(): void;
  40765. }
  40766. }
  40767. declare module "babylonjs/Cameras/XR/webXRCamera" {
  40768. import { Scene } from "babylonjs/scene";
  40769. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40770. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40771. /**
  40772. * WebXR Camera which holds the views for the xrSession
  40773. * @see https://doc.babylonjs.com/how_to/webxr
  40774. */
  40775. export class WebXRCamera extends FreeCamera {
  40776. private static _TmpMatrix;
  40777. /**
  40778. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40779. * @param name the name of the camera
  40780. * @param scene the scene to add the camera to
  40781. */
  40782. constructor(name: string, scene: Scene);
  40783. private _updateNumberOfRigCameras;
  40784. /** @hidden */
  40785. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40786. /**
  40787. * Updates the cameras position from the current pose information of the XR session
  40788. * @param xrSessionManager the session containing pose information
  40789. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40790. */
  40791. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40792. }
  40793. }
  40794. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  40795. import { Nullable } from "babylonjs/types";
  40796. import { Observable } from "babylonjs/Misc/observable";
  40797. import { IDisposable, Scene } from "babylonjs/scene";
  40798. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  40799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40800. import { Ray } from "babylonjs/Culling/ray";
  40801. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  40802. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  40803. /**
  40804. * States of the webXR experience
  40805. */
  40806. export enum WebXRState {
  40807. /**
  40808. * Transitioning to being in XR mode
  40809. */
  40810. ENTERING_XR = 0,
  40811. /**
  40812. * Transitioning to non XR mode
  40813. */
  40814. EXITING_XR = 1,
  40815. /**
  40816. * In XR mode and presenting
  40817. */
  40818. IN_XR = 2,
  40819. /**
  40820. * Not entered XR mode
  40821. */
  40822. NOT_IN_XR = 3
  40823. }
  40824. /**
  40825. * Helper class used to enable XR
  40826. * @see https://doc.babylonjs.com/how_to/webxr
  40827. */
  40828. export class WebXRExperienceHelper implements IDisposable {
  40829. private scene;
  40830. /**
  40831. * 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
  40832. */
  40833. container: AbstractMesh;
  40834. /**
  40835. * Camera used to render xr content
  40836. */
  40837. camera: WebXRCamera;
  40838. /**
  40839. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40840. */
  40841. state: WebXRState;
  40842. private _setState;
  40843. private static _TmpVector;
  40844. /**
  40845. * Fires when the state of the experience helper has changed
  40846. */
  40847. onStateChangedObservable: Observable<WebXRState>;
  40848. /** @hidden */
  40849. _sessionManager: WebXRSessionManager;
  40850. private _nonVRCamera;
  40851. private _originalSceneAutoClear;
  40852. private _supported;
  40853. /**
  40854. * Creates the experience helper
  40855. * @param scene the scene to attach the experience helper to
  40856. * @returns a promise for the experience helper
  40857. */
  40858. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40859. /**
  40860. * Creates a WebXRExperienceHelper
  40861. * @param scene The scene the helper should be created in
  40862. */
  40863. private constructor();
  40864. /**
  40865. * Exits XR mode and returns the scene to its original state
  40866. * @returns promise that resolves after xr mode has exited
  40867. */
  40868. exitXRAsync(): Promise<void>;
  40869. /**
  40870. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40871. * @param sessionCreationOptions options for the XR session
  40872. * @param frameOfReference frame of reference of the XR session
  40873. * @returns promise that resolves after xr mode has entered
  40874. */
  40875. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40876. /**
  40877. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40878. * @param ray ray to cast into the environment
  40879. * @returns Promise which resolves with a collision point in the environment if it exists
  40880. */
  40881. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40882. /**
  40883. * Updates the global position of the camera by moving the camera's container
  40884. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40885. * @param position The desired global position of the camera
  40886. */
  40887. setPositionOfCameraUsingContainer(position: Vector3): void;
  40888. /**
  40889. * Rotates the xr camera by rotating the camera's container around the camera's position
  40890. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40891. * @param rotation the desired quaternion rotation to apply to the camera
  40892. */
  40893. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40894. /**
  40895. * Checks if the creation options are supported by the xr session
  40896. * @param options creation options
  40897. * @returns true if supported
  40898. */
  40899. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40900. /**
  40901. * Disposes of the experience helper
  40902. */
  40903. dispose(): void;
  40904. }
  40905. }
  40906. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  40907. import { Nullable } from "babylonjs/types";
  40908. import { Observable } from "babylonjs/Misc/observable";
  40909. import { IDisposable, Scene } from "babylonjs/scene";
  40910. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40911. /**
  40912. * Button which can be used to enter a different mode of XR
  40913. */
  40914. export class WebXREnterExitUIButton {
  40915. /** button element */
  40916. element: HTMLElement;
  40917. /** XR initialization options for the button */
  40918. initializationOptions: XRSessionCreationOptions;
  40919. /**
  40920. * Creates a WebXREnterExitUIButton
  40921. * @param element button element
  40922. * @param initializationOptions XR initialization options for the button
  40923. */
  40924. constructor(
  40925. /** button element */
  40926. element: HTMLElement,
  40927. /** XR initialization options for the button */
  40928. initializationOptions: XRSessionCreationOptions);
  40929. /**
  40930. * Overwritable function which can be used to update the button's visuals when the state changes
  40931. * @param activeButton the current active button in the UI
  40932. */
  40933. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40934. }
  40935. /**
  40936. * Options to create the webXR UI
  40937. */
  40938. export class WebXREnterExitUIOptions {
  40939. /**
  40940. * Context to enter xr with
  40941. */
  40942. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40943. /**
  40944. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40945. */
  40946. customButtons?: Array<WebXREnterExitUIButton>;
  40947. }
  40948. /**
  40949. * UI to allow the user to enter/exit XR mode
  40950. */
  40951. export class WebXREnterExitUI implements IDisposable {
  40952. private scene;
  40953. private _overlay;
  40954. private _buttons;
  40955. private _activeButton;
  40956. /**
  40957. * Fired every time the active button is changed.
  40958. *
  40959. * When xr is entered via a button that launches xr that button will be the callback parameter
  40960. *
  40961. * When exiting xr the callback parameter will be null)
  40962. */
  40963. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40964. /**
  40965. * Creates UI to allow the user to enter/exit XR mode
  40966. * @param scene the scene to add the ui to
  40967. * @param helper the xr experience helper to enter/exit xr with
  40968. * @param options options to configure the UI
  40969. * @returns the created ui
  40970. */
  40971. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40972. private constructor();
  40973. private _updateButtons;
  40974. /**
  40975. * Disposes of the object
  40976. */
  40977. dispose(): void;
  40978. }
  40979. }
  40980. declare module "babylonjs/Cameras/XR/webXRInput" {
  40981. import { IDisposable, Scene } from "babylonjs/scene";
  40982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40983. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40984. /**
  40985. * Represents an XR input
  40986. */
  40987. export class WebXRController {
  40988. /**
  40989. * 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
  40990. */
  40991. grip?: AbstractMesh;
  40992. /**
  40993. * Pointer which can be used to select objects or attach a visible laser to
  40994. */
  40995. pointer: AbstractMesh;
  40996. /**
  40997. * Creates the controller
  40998. * @see https://doc.babylonjs.com/how_to/webxr
  40999. * @param scene the scene which the controller should be associated to
  41000. */
  41001. constructor(scene: Scene);
  41002. /**
  41003. * Disposes of the object
  41004. */
  41005. dispose(): void;
  41006. }
  41007. /**
  41008. * XR input used to track XR inputs such as controllers/rays
  41009. */
  41010. export class WebXRInput implements IDisposable {
  41011. private helper;
  41012. /**
  41013. * XR controllers being tracked
  41014. */
  41015. controllers: Array<WebXRController>;
  41016. private _tmpMatrix;
  41017. private _frameObserver;
  41018. /**
  41019. * Initializes the WebXRInput
  41020. * @param helper experience helper which the input should be created for
  41021. */
  41022. constructor(helper: WebXRExperienceHelper);
  41023. /**
  41024. * Disposes of the object
  41025. */
  41026. dispose(): void;
  41027. }
  41028. }
  41029. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41030. import { Nullable } from "babylonjs/types";
  41031. import { IDisposable } from "babylonjs/scene";
  41032. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41033. /**
  41034. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41035. */
  41036. export class WebXRManagedOutputCanvas implements IDisposable {
  41037. private _canvas;
  41038. /**
  41039. * xrpresent context of the canvas which can be used to display/mirror xr content
  41040. */
  41041. canvasContext: Nullable<WebGLRenderingContext>;
  41042. /**
  41043. * Initializes the canvas to be added/removed upon entering/exiting xr
  41044. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41045. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41046. */
  41047. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41048. /**
  41049. * Disposes of the object
  41050. */
  41051. dispose(): void;
  41052. private _setManagedOutputCanvas;
  41053. private _addCanvas;
  41054. private _removeCanvas;
  41055. }
  41056. }
  41057. declare module "babylonjs/Cameras/XR/index" {
  41058. export * from "babylonjs/Cameras/XR/webXRCamera";
  41059. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41060. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41061. export * from "babylonjs/Cameras/XR/webXRInput";
  41062. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41063. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41064. }
  41065. declare module "babylonjs/Cameras/RigModes/index" {
  41066. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41067. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41068. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41069. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41070. }
  41071. declare module "babylonjs/Cameras/index" {
  41072. export * from "babylonjs/Cameras/Inputs/index";
  41073. export * from "babylonjs/Cameras/cameraInputsManager";
  41074. export * from "babylonjs/Cameras/camera";
  41075. export * from "babylonjs/Cameras/targetCamera";
  41076. export * from "babylonjs/Cameras/freeCamera";
  41077. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41078. export * from "babylonjs/Cameras/touchCamera";
  41079. export * from "babylonjs/Cameras/arcRotateCamera";
  41080. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41081. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41082. export * from "babylonjs/Cameras/flyCamera";
  41083. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41084. export * from "babylonjs/Cameras/followCamera";
  41085. export * from "babylonjs/Cameras/gamepadCamera";
  41086. export * from "babylonjs/Cameras/Stereoscopic/index";
  41087. export * from "babylonjs/Cameras/universalCamera";
  41088. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41089. export * from "babylonjs/Cameras/VR/index";
  41090. export * from "babylonjs/Cameras/XR/index";
  41091. export * from "babylonjs/Cameras/RigModes/index";
  41092. }
  41093. declare module "babylonjs/Collisions/index" {
  41094. export * from "babylonjs/Collisions/collider";
  41095. export * from "babylonjs/Collisions/collisionCoordinator";
  41096. export * from "babylonjs/Collisions/pickingInfo";
  41097. export * from "babylonjs/Collisions/intersectionInfo";
  41098. }
  41099. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41100. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41101. import { Vector3, Plane } from "babylonjs/Maths/math";
  41102. import { Ray } from "babylonjs/Culling/ray";
  41103. /**
  41104. * Contains an array of blocks representing the octree
  41105. */
  41106. export interface IOctreeContainer<T> {
  41107. /**
  41108. * Blocks within the octree
  41109. */
  41110. blocks: Array<OctreeBlock<T>>;
  41111. }
  41112. /**
  41113. * Class used to store a cell in an octree
  41114. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41115. */
  41116. export class OctreeBlock<T> {
  41117. /**
  41118. * Gets the content of the current block
  41119. */
  41120. entries: T[];
  41121. /**
  41122. * Gets the list of block children
  41123. */
  41124. blocks: Array<OctreeBlock<T>>;
  41125. private _depth;
  41126. private _maxDepth;
  41127. private _capacity;
  41128. private _minPoint;
  41129. private _maxPoint;
  41130. private _boundingVectors;
  41131. private _creationFunc;
  41132. /**
  41133. * Creates a new block
  41134. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41135. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41136. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41137. * @param depth defines the current depth of this block in the octree
  41138. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41139. * @param creationFunc defines a callback to call when an element is added to the block
  41140. */
  41141. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41142. /**
  41143. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41144. */
  41145. readonly capacity: number;
  41146. /**
  41147. * Gets the minimum vector (in world space) of the block's bounding box
  41148. */
  41149. readonly minPoint: Vector3;
  41150. /**
  41151. * Gets the maximum vector (in world space) of the block's bounding box
  41152. */
  41153. readonly maxPoint: Vector3;
  41154. /**
  41155. * Add a new element to this block
  41156. * @param entry defines the element to add
  41157. */
  41158. addEntry(entry: T): void;
  41159. /**
  41160. * Remove an element from this block
  41161. * @param entry defines the element to remove
  41162. */
  41163. removeEntry(entry: T): void;
  41164. /**
  41165. * Add an array of elements to this block
  41166. * @param entries defines the array of elements to add
  41167. */
  41168. addEntries(entries: T[]): void;
  41169. /**
  41170. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41171. * @param frustumPlanes defines the frustum planes to test
  41172. * @param selection defines the array to store current content if selection is positive
  41173. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41174. */
  41175. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41176. /**
  41177. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41178. * @param sphereCenter defines the bounding sphere center
  41179. * @param sphereRadius defines the bounding sphere radius
  41180. * @param selection defines the array to store current content if selection is positive
  41181. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41182. */
  41183. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41184. /**
  41185. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41186. * @param ray defines the ray to test with
  41187. * @param selection defines the array to store current content if selection is positive
  41188. */
  41189. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41190. /**
  41191. * Subdivide the content into child blocks (this block will then be empty)
  41192. */
  41193. createInnerBlocks(): void;
  41194. /**
  41195. * @hidden
  41196. */
  41197. 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;
  41198. }
  41199. }
  41200. declare module "babylonjs/Culling/Octrees/octree" {
  41201. import { SmartArray } from "babylonjs/Misc/smartArray";
  41202. import { Vector3, Plane } from "babylonjs/Maths/math";
  41203. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41205. import { Ray } from "babylonjs/Culling/ray";
  41206. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41207. /**
  41208. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41209. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41210. */
  41211. export class Octree<T> {
  41212. /** 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.) */
  41213. maxDepth: number;
  41214. /**
  41215. * Blocks within the octree containing objects
  41216. */
  41217. blocks: Array<OctreeBlock<T>>;
  41218. /**
  41219. * Content stored in the octree
  41220. */
  41221. dynamicContent: T[];
  41222. private _maxBlockCapacity;
  41223. private _selectionContent;
  41224. private _creationFunc;
  41225. /**
  41226. * Creates a octree
  41227. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41228. * @param creationFunc function to be used to instatiate the octree
  41229. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41230. * @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.)
  41231. */
  41232. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41233. /** 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.) */
  41234. maxDepth?: number);
  41235. /**
  41236. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41237. * @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);
  41238. * @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);
  41239. * @param entries meshes to be added to the octree blocks
  41240. */
  41241. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41242. /**
  41243. * Adds a mesh to the octree
  41244. * @param entry Mesh to add to the octree
  41245. */
  41246. addMesh(entry: T): void;
  41247. /**
  41248. * Remove an element from the octree
  41249. * @param entry defines the element to remove
  41250. */
  41251. removeMesh(entry: T): void;
  41252. /**
  41253. * Selects an array of meshes within the frustum
  41254. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41255. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41256. * @returns array of meshes within the frustum
  41257. */
  41258. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41259. /**
  41260. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41261. * @param sphereCenter defines the bounding sphere center
  41262. * @param sphereRadius defines the bounding sphere radius
  41263. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41264. * @returns an array of objects that intersect the sphere
  41265. */
  41266. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41267. /**
  41268. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41269. * @param ray defines the ray to test with
  41270. * @returns array of intersected objects
  41271. */
  41272. intersectsRay(ray: Ray): SmartArray<T>;
  41273. /**
  41274. * Adds a mesh into the octree block if it intersects the block
  41275. */
  41276. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41277. /**
  41278. * Adds a submesh into the octree block if it intersects the block
  41279. */
  41280. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41281. }
  41282. }
  41283. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41284. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41285. import { Scene } from "babylonjs/scene";
  41286. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41287. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41288. import { Ray } from "babylonjs/Culling/ray";
  41289. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41290. import { Collider } from "babylonjs/Collisions/collider";
  41291. module "babylonjs/scene" {
  41292. interface Scene {
  41293. /**
  41294. * @hidden
  41295. * Backing Filed
  41296. */
  41297. _selectionOctree: Octree<AbstractMesh>;
  41298. /**
  41299. * Gets the octree used to boost mesh selection (picking)
  41300. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41301. */
  41302. selectionOctree: Octree<AbstractMesh>;
  41303. /**
  41304. * Creates or updates the octree used to boost selection (picking)
  41305. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41306. * @param maxCapacity defines the maximum capacity per leaf
  41307. * @param maxDepth defines the maximum depth of the octree
  41308. * @returns an octree of AbstractMesh
  41309. */
  41310. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41311. }
  41312. }
  41313. module "babylonjs/Meshes/abstractMesh" {
  41314. interface AbstractMesh {
  41315. /**
  41316. * @hidden
  41317. * Backing Field
  41318. */
  41319. _submeshesOctree: Octree<SubMesh>;
  41320. /**
  41321. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41322. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41323. * @param maxCapacity defines the maximum size of each block (64 by default)
  41324. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41325. * @returns the new octree
  41326. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41327. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41328. */
  41329. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41330. }
  41331. }
  41332. /**
  41333. * Defines the octree scene component responsible to manage any octrees
  41334. * in a given scene.
  41335. */
  41336. export class OctreeSceneComponent {
  41337. /**
  41338. * The component name helpfull to identify the component in the list of scene components.
  41339. */
  41340. readonly name: string;
  41341. /**
  41342. * The scene the component belongs to.
  41343. */
  41344. scene: Scene;
  41345. /**
  41346. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41347. */
  41348. readonly checksIsEnabled: boolean;
  41349. /**
  41350. * Creates a new instance of the component for the given scene
  41351. * @param scene Defines the scene to register the component in
  41352. */
  41353. constructor(scene: Scene);
  41354. /**
  41355. * Registers the component in a given scene
  41356. */
  41357. register(): void;
  41358. /**
  41359. * Return the list of active meshes
  41360. * @returns the list of active meshes
  41361. */
  41362. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41363. /**
  41364. * Return the list of active sub meshes
  41365. * @param mesh The mesh to get the candidates sub meshes from
  41366. * @returns the list of active sub meshes
  41367. */
  41368. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41369. private _tempRay;
  41370. /**
  41371. * Return the list of sub meshes intersecting with a given local ray
  41372. * @param mesh defines the mesh to find the submesh for
  41373. * @param localRay defines the ray in local space
  41374. * @returns the list of intersecting sub meshes
  41375. */
  41376. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41377. /**
  41378. * Return the list of sub meshes colliding with a collider
  41379. * @param mesh defines the mesh to find the submesh for
  41380. * @param collider defines the collider to evaluate the collision against
  41381. * @returns the list of colliding sub meshes
  41382. */
  41383. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41384. /**
  41385. * Rebuilds the elements related to this component in case of
  41386. * context lost for instance.
  41387. */
  41388. rebuild(): void;
  41389. /**
  41390. * Disposes the component and the associated ressources.
  41391. */
  41392. dispose(): void;
  41393. }
  41394. }
  41395. declare module "babylonjs/Culling/Octrees/index" {
  41396. export * from "babylonjs/Culling/Octrees/octree";
  41397. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41398. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41399. }
  41400. declare module "babylonjs/Culling/index" {
  41401. export * from "babylonjs/Culling/boundingBox";
  41402. export * from "babylonjs/Culling/boundingInfo";
  41403. export * from "babylonjs/Culling/boundingSphere";
  41404. export * from "babylonjs/Culling/Octrees/index";
  41405. export * from "babylonjs/Culling/ray";
  41406. }
  41407. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  41408. import { Vector3, Color4 } from "babylonjs/Maths/math";
  41409. import { Nullable } from "babylonjs/types";
  41410. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41411. import { Scene } from "babylonjs/scene";
  41412. /**
  41413. * Class containing static functions to help procedurally build meshes
  41414. */
  41415. export class LinesBuilder {
  41416. /**
  41417. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41418. * * 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
  41419. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41420. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41421. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41422. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41423. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41424. * * 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
  41425. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41427. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41428. * @param name defines the name of the new line system
  41429. * @param options defines the options used to create the line system
  41430. * @param scene defines the hosting scene
  41431. * @returns a new line system mesh
  41432. */
  41433. static CreateLineSystem(name: string, options: {
  41434. lines: Vector3[][];
  41435. updatable?: boolean;
  41436. instance?: Nullable<LinesMesh>;
  41437. colors?: Nullable<Color4[][]>;
  41438. useVertexAlpha?: boolean;
  41439. }, scene: Nullable<Scene>): LinesMesh;
  41440. /**
  41441. * Creates a line mesh
  41442. * 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
  41443. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41444. * * The parameter `points` is an array successive Vector3
  41445. * * 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
  41446. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41447. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41448. * * When updating an instance, remember that only point positions can change, not the number of points
  41449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41450. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41451. * @param name defines the name of the new line system
  41452. * @param options defines the options used to create the line system
  41453. * @param scene defines the hosting scene
  41454. * @returns a new line mesh
  41455. */
  41456. static CreateLines(name: string, options: {
  41457. points: Vector3[];
  41458. updatable?: boolean;
  41459. instance?: Nullable<LinesMesh>;
  41460. colors?: Color4[];
  41461. useVertexAlpha?: boolean;
  41462. }, scene?: Nullable<Scene>): LinesMesh;
  41463. /**
  41464. * Creates a dashed line mesh
  41465. * * 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
  41466. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41467. * * The parameter `points` is an array successive Vector3
  41468. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41469. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41470. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41471. * * 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
  41472. * * When updating an instance, remember that only point positions can change, not the number of points
  41473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41474. * @param name defines the name of the mesh
  41475. * @param options defines the options used to create the mesh
  41476. * @param scene defines the hosting scene
  41477. * @returns the dashed line mesh
  41478. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41479. */
  41480. static CreateDashedLines(name: string, options: {
  41481. points: Vector3[];
  41482. dashSize?: number;
  41483. gapSize?: number;
  41484. dashNb?: number;
  41485. updatable?: boolean;
  41486. instance?: LinesMesh;
  41487. }, scene?: Nullable<Scene>): LinesMesh;
  41488. }
  41489. }
  41490. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41491. import { IDisposable, Scene } from "babylonjs/scene";
  41492. import { Nullable } from "babylonjs/types";
  41493. import { Observable } from "babylonjs/Misc/observable";
  41494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41495. /**
  41496. * Renders a layer on top of an existing scene
  41497. */
  41498. export class UtilityLayerRenderer implements IDisposable {
  41499. /** the original scene that will be rendered on top of */
  41500. originalScene: Scene;
  41501. private _pointerCaptures;
  41502. private _lastPointerEvents;
  41503. private static _DefaultUtilityLayer;
  41504. private static _DefaultKeepDepthUtilityLayer;
  41505. /**
  41506. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41507. */
  41508. pickUtilitySceneFirst: boolean;
  41509. /**
  41510. * 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)
  41511. */
  41512. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41513. /**
  41514. * 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)
  41515. */
  41516. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41517. /**
  41518. * The scene that is rendered on top of the original scene
  41519. */
  41520. utilityLayerScene: Scene;
  41521. /**
  41522. * If the utility layer should automatically be rendered on top of existing scene
  41523. */
  41524. shouldRender: boolean;
  41525. /**
  41526. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41527. */
  41528. onlyCheckPointerDownEvents: boolean;
  41529. /**
  41530. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41531. */
  41532. processAllEvents: boolean;
  41533. /**
  41534. * Observable raised when the pointer move from the utility layer scene to the main scene
  41535. */
  41536. onPointerOutObservable: Observable<number>;
  41537. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41538. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41539. private _afterRenderObserver;
  41540. private _sceneDisposeObserver;
  41541. private _originalPointerObserver;
  41542. /**
  41543. * Instantiates a UtilityLayerRenderer
  41544. * @param originalScene the original scene that will be rendered on top of
  41545. * @param handleEvents boolean indicating if the utility layer should handle events
  41546. */
  41547. constructor(
  41548. /** the original scene that will be rendered on top of */
  41549. originalScene: Scene, handleEvents?: boolean);
  41550. private _notifyObservers;
  41551. /**
  41552. * Renders the utility layers scene on top of the original scene
  41553. */
  41554. render(): void;
  41555. /**
  41556. * Disposes of the renderer
  41557. */
  41558. dispose(): void;
  41559. private _updateCamera;
  41560. }
  41561. }
  41562. declare module "babylonjs/Gizmos/gizmo" {
  41563. import { Nullable } from "babylonjs/types";
  41564. import { IDisposable } from "babylonjs/scene";
  41565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41566. import { Mesh } from "babylonjs/Meshes/mesh";
  41567. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41568. /**
  41569. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41570. */
  41571. export class Gizmo implements IDisposable {
  41572. /** The utility layer the gizmo will be added to */
  41573. gizmoLayer: UtilityLayerRenderer;
  41574. /**
  41575. * The root mesh of the gizmo
  41576. */
  41577. _rootMesh: Mesh;
  41578. private _attachedMesh;
  41579. /**
  41580. * Ratio for the scale of the gizmo (Default: 1)
  41581. */
  41582. scaleRatio: number;
  41583. private _tmpMatrix;
  41584. /**
  41585. * If a custom mesh has been set (Default: false)
  41586. */
  41587. protected _customMeshSet: boolean;
  41588. /**
  41589. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41590. * * When set, interactions will be enabled
  41591. */
  41592. attachedMesh: Nullable<AbstractMesh>;
  41593. /**
  41594. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41595. * @param mesh The mesh to replace the default mesh of the gizmo
  41596. */
  41597. setCustomMesh(mesh: Mesh): void;
  41598. /**
  41599. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41600. */
  41601. updateGizmoRotationToMatchAttachedMesh: boolean;
  41602. /**
  41603. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41604. */
  41605. updateGizmoPositionToMatchAttachedMesh: boolean;
  41606. /**
  41607. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41608. */
  41609. protected _updateScale: boolean;
  41610. protected _interactionsEnabled: boolean;
  41611. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41612. private _beforeRenderObserver;
  41613. /**
  41614. * Creates a gizmo
  41615. * @param gizmoLayer The utility layer the gizmo will be added to
  41616. */
  41617. constructor(
  41618. /** The utility layer the gizmo will be added to */
  41619. gizmoLayer?: UtilityLayerRenderer);
  41620. private _tempVector;
  41621. /**
  41622. * @hidden
  41623. * Updates the gizmo to match the attached mesh's position/rotation
  41624. */
  41625. protected _update(): void;
  41626. /**
  41627. * Disposes of the gizmo
  41628. */
  41629. dispose(): void;
  41630. }
  41631. }
  41632. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41633. import { Observable } from "babylonjs/Misc/observable";
  41634. import { Nullable } from "babylonjs/types";
  41635. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41636. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41638. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41639. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  41640. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41641. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  41642. import { Scene } from "babylonjs/scene";
  41643. /**
  41644. * Single axis drag gizmo
  41645. */
  41646. export class AxisDragGizmo extends Gizmo {
  41647. /**
  41648. * Drag behavior responsible for the gizmos dragging interactions
  41649. */
  41650. dragBehavior: PointerDragBehavior;
  41651. private _pointerObserver;
  41652. /**
  41653. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41654. */
  41655. snapDistance: number;
  41656. /**
  41657. * Event that fires each time the gizmo snaps to a new location.
  41658. * * snapDistance is the the change in distance
  41659. */
  41660. onSnapObservable: Observable<{
  41661. snapDistance: number;
  41662. }>;
  41663. /** @hidden */
  41664. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  41665. /** @hidden */
  41666. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41667. /**
  41668. * Creates an AxisDragGizmo
  41669. * @param gizmoLayer The utility layer the gizmo will be added to
  41670. * @param dragAxis The axis which the gizmo will be able to drag on
  41671. * @param color The color of the gizmo
  41672. */
  41673. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41674. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41675. /**
  41676. * Disposes of the gizmo
  41677. */
  41678. dispose(): void;
  41679. }
  41680. }
  41681. declare module "babylonjs/Debug/axesViewer" {
  41682. import { Vector3 } from "babylonjs/Maths/math";
  41683. import { Nullable } from "babylonjs/types";
  41684. import { Scene } from "babylonjs/scene";
  41685. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41686. /**
  41687. * The Axes viewer will show 3 axes in a specific point in space
  41688. */
  41689. export class AxesViewer {
  41690. private _xAxis;
  41691. private _yAxis;
  41692. private _zAxis;
  41693. private _scaleLinesFactor;
  41694. private _instanced;
  41695. /**
  41696. * Gets the hosting scene
  41697. */
  41698. scene: Scene;
  41699. /**
  41700. * Gets or sets a number used to scale line length
  41701. */
  41702. scaleLines: number;
  41703. /** Gets the node hierarchy used to render x-axis */
  41704. readonly xAxis: TransformNode;
  41705. /** Gets the node hierarchy used to render y-axis */
  41706. readonly yAxis: TransformNode;
  41707. /** Gets the node hierarchy used to render z-axis */
  41708. readonly zAxis: TransformNode;
  41709. /**
  41710. * Creates a new AxesViewer
  41711. * @param scene defines the hosting scene
  41712. * @param scaleLines defines a number used to scale line length (1 by default)
  41713. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  41714. * @param xAxis defines the node hierarchy used to render the x-axis
  41715. * @param yAxis defines the node hierarchy used to render the y-axis
  41716. * @param zAxis defines the node hierarchy used to render the z-axis
  41717. */
  41718. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  41719. /**
  41720. * Force the viewer to update
  41721. * @param position defines the position of the viewer
  41722. * @param xaxis defines the x axis of the viewer
  41723. * @param yaxis defines the y axis of the viewer
  41724. * @param zaxis defines the z axis of the viewer
  41725. */
  41726. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  41727. /**
  41728. * Creates an instance of this axes viewer.
  41729. * @returns a new axes viewer with instanced meshes
  41730. */
  41731. createInstance(): AxesViewer;
  41732. /** Releases resources */
  41733. dispose(): void;
  41734. private static _SetRenderingGroupId;
  41735. }
  41736. }
  41737. declare module "babylonjs/Debug/boneAxesViewer" {
  41738. import { Nullable } from "babylonjs/types";
  41739. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  41740. import { Vector3 } from "babylonjs/Maths/math";
  41741. import { Mesh } from "babylonjs/Meshes/mesh";
  41742. import { Bone } from "babylonjs/Bones/bone";
  41743. import { Scene } from "babylonjs/scene";
  41744. /**
  41745. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  41746. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  41747. */
  41748. export class BoneAxesViewer extends AxesViewer {
  41749. /**
  41750. * Gets or sets the target mesh where to display the axes viewer
  41751. */
  41752. mesh: Nullable<Mesh>;
  41753. /**
  41754. * Gets or sets the target bone where to display the axes viewer
  41755. */
  41756. bone: Nullable<Bone>;
  41757. /** Gets current position */
  41758. pos: Vector3;
  41759. /** Gets direction of X axis */
  41760. xaxis: Vector3;
  41761. /** Gets direction of Y axis */
  41762. yaxis: Vector3;
  41763. /** Gets direction of Z axis */
  41764. zaxis: Vector3;
  41765. /**
  41766. * Creates a new BoneAxesViewer
  41767. * @param scene defines the hosting scene
  41768. * @param bone defines the target bone
  41769. * @param mesh defines the target mesh
  41770. * @param scaleLines defines a scaling factor for line length (1 by default)
  41771. */
  41772. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  41773. /**
  41774. * Force the viewer to update
  41775. */
  41776. update(): void;
  41777. /** Releases resources */
  41778. dispose(): void;
  41779. }
  41780. }
  41781. declare module "babylonjs/Debug/debugLayer" {
  41782. import { Observable } from "babylonjs/Misc/observable";
  41783. import { Scene } from "babylonjs/scene";
  41784. /**
  41785. * Interface used to define scene explorer extensibility option
  41786. */
  41787. export interface IExplorerExtensibilityOption {
  41788. /**
  41789. * Define the option label
  41790. */
  41791. label: string;
  41792. /**
  41793. * Defines the action to execute on click
  41794. */
  41795. action: (entity: any) => void;
  41796. }
  41797. /**
  41798. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  41799. */
  41800. export interface IExplorerExtensibilityGroup {
  41801. /**
  41802. * Defines a predicate to test if a given type mut be extended
  41803. */
  41804. predicate: (entity: any) => boolean;
  41805. /**
  41806. * Gets the list of options added to a type
  41807. */
  41808. entries: IExplorerExtensibilityOption[];
  41809. }
  41810. /**
  41811. * Interface used to define the options to use to create the Inspector
  41812. */
  41813. export interface IInspectorOptions {
  41814. /**
  41815. * Display in overlay mode (default: false)
  41816. */
  41817. overlay?: boolean;
  41818. /**
  41819. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  41820. */
  41821. globalRoot?: HTMLElement;
  41822. /**
  41823. * Display the Scene explorer
  41824. */
  41825. showExplorer?: boolean;
  41826. /**
  41827. * Display the property inspector
  41828. */
  41829. showInspector?: boolean;
  41830. /**
  41831. * Display in embed mode (both panes on the right)
  41832. */
  41833. embedMode?: boolean;
  41834. /**
  41835. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  41836. */
  41837. handleResize?: boolean;
  41838. /**
  41839. * Allow the panes to popup (default: true)
  41840. */
  41841. enablePopup?: boolean;
  41842. /**
  41843. * Allow the panes to be closed by users (default: true)
  41844. */
  41845. enableClose?: boolean;
  41846. /**
  41847. * Optional list of extensibility entries
  41848. */
  41849. explorerExtensibility?: IExplorerExtensibilityGroup[];
  41850. /**
  41851. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  41852. */
  41853. inspectorURL?: string;
  41854. }
  41855. module "babylonjs/scene" {
  41856. interface Scene {
  41857. /**
  41858. * @hidden
  41859. * Backing field
  41860. */
  41861. _debugLayer: DebugLayer;
  41862. /**
  41863. * Gets the debug layer (aka Inspector) associated with the scene
  41864. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41865. */
  41866. debugLayer: DebugLayer;
  41867. }
  41868. }
  41869. /**
  41870. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41871. * what is happening in your scene
  41872. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41873. */
  41874. export class DebugLayer {
  41875. /**
  41876. * Define the url to get the inspector script from.
  41877. * By default it uses the babylonjs CDN.
  41878. * @ignoreNaming
  41879. */
  41880. static InspectorURL: string;
  41881. private _scene;
  41882. private BJSINSPECTOR;
  41883. /**
  41884. * Observable triggered when a property is changed through the inspector.
  41885. */
  41886. onPropertyChangedObservable: Observable<{
  41887. object: any;
  41888. property: string;
  41889. value: any;
  41890. initialValue: any;
  41891. }>;
  41892. /**
  41893. * Instantiates a new debug layer.
  41894. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41895. * what is happening in your scene
  41896. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41897. * @param scene Defines the scene to inspect
  41898. */
  41899. constructor(scene: Scene);
  41900. /** Creates the inspector window. */
  41901. private _createInspector;
  41902. /**
  41903. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41904. * @param entity defines the entity to select
  41905. * @param lineContainerTitle defines the specific block to highlight
  41906. */
  41907. select(entity: any, lineContainerTitle?: string): void;
  41908. /** Get the inspector from bundle or global */
  41909. private _getGlobalInspector;
  41910. /**
  41911. * Get if the inspector is visible or not.
  41912. * @returns true if visible otherwise, false
  41913. */
  41914. isVisible(): boolean;
  41915. /**
  41916. * Hide the inspector and close its window.
  41917. */
  41918. hide(): void;
  41919. /**
  41920. * Launch the debugLayer.
  41921. * @param config Define the configuration of the inspector
  41922. * @return a promise fulfilled when the debug layer is visible
  41923. */
  41924. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41925. }
  41926. }
  41927. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  41928. import { Nullable } from "babylonjs/types";
  41929. import { Scene } from "babylonjs/scene";
  41930. import { Vector4, Color4 } from "babylonjs/Maths/math";
  41931. import { Mesh } from "babylonjs/Meshes/mesh";
  41932. /**
  41933. * Class containing static functions to help procedurally build meshes
  41934. */
  41935. export class BoxBuilder {
  41936. /**
  41937. * Creates a box mesh
  41938. * * The parameter `size` sets the size (float) of each box side (default 1)
  41939. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41940. * * 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)
  41941. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41942. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41943. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41945. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41946. * @param name defines the name of the mesh
  41947. * @param options defines the options used to create the mesh
  41948. * @param scene defines the hosting scene
  41949. * @returns the box mesh
  41950. */
  41951. static CreateBox(name: string, options: {
  41952. size?: number;
  41953. width?: number;
  41954. height?: number;
  41955. depth?: number;
  41956. faceUV?: Vector4[];
  41957. faceColors?: Color4[];
  41958. sideOrientation?: number;
  41959. frontUVs?: Vector4;
  41960. backUVs?: Vector4;
  41961. updatable?: boolean;
  41962. }, scene?: Nullable<Scene>): Mesh;
  41963. }
  41964. }
  41965. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  41966. import { Vector4 } from "babylonjs/Maths/math";
  41967. import { Mesh } from "babylonjs/Meshes/mesh";
  41968. /**
  41969. * Class containing static functions to help procedurally build meshes
  41970. */
  41971. export class SphereBuilder {
  41972. /**
  41973. * Creates a sphere mesh
  41974. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41975. * * 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`)
  41976. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41977. * * 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
  41978. * * 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)
  41979. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41980. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41982. * @param name defines the name of the mesh
  41983. * @param options defines the options used to create the mesh
  41984. * @param scene defines the hosting scene
  41985. * @returns the sphere mesh
  41986. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41987. */
  41988. static CreateSphere(name: string, options: {
  41989. segments?: number;
  41990. diameter?: number;
  41991. diameterX?: number;
  41992. diameterY?: number;
  41993. diameterZ?: number;
  41994. arc?: number;
  41995. slice?: number;
  41996. sideOrientation?: number;
  41997. frontUVs?: Vector4;
  41998. backUVs?: Vector4;
  41999. updatable?: boolean;
  42000. }, scene: any): Mesh;
  42001. }
  42002. }
  42003. declare module "babylonjs/Debug/physicsViewer" {
  42004. import { Nullable } from "babylonjs/types";
  42005. import { Scene } from "babylonjs/scene";
  42006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42007. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42008. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42009. /**
  42010. * Used to show the physics impostor around the specific mesh
  42011. */
  42012. export class PhysicsViewer {
  42013. /** @hidden */
  42014. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42015. /** @hidden */
  42016. protected _meshes: Array<Nullable<AbstractMesh>>;
  42017. /** @hidden */
  42018. protected _scene: Nullable<Scene>;
  42019. /** @hidden */
  42020. protected _numMeshes: number;
  42021. /** @hidden */
  42022. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42023. private _renderFunction;
  42024. private _utilityLayer;
  42025. private _debugBoxMesh;
  42026. private _debugSphereMesh;
  42027. private _debugMaterial;
  42028. /**
  42029. * Creates a new PhysicsViewer
  42030. * @param scene defines the hosting scene
  42031. */
  42032. constructor(scene: Scene);
  42033. /** @hidden */
  42034. protected _updateDebugMeshes(): void;
  42035. /**
  42036. * Renders a specified physic impostor
  42037. * @param impostor defines the impostor to render
  42038. * @returns the new debug mesh used to render the impostor
  42039. */
  42040. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  42041. /**
  42042. * Hides a specified physic impostor
  42043. * @param impostor defines the impostor to hide
  42044. */
  42045. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42046. private _getDebugMaterial;
  42047. private _getDebugBoxMesh;
  42048. private _getDebugSphereMesh;
  42049. private _getDebugMesh;
  42050. /** Releases all resources */
  42051. dispose(): void;
  42052. }
  42053. }
  42054. declare module "babylonjs/Debug/rayHelper" {
  42055. import { Nullable } from "babylonjs/types";
  42056. import { Ray } from "babylonjs/Culling/ray";
  42057. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42058. import { Scene } from "babylonjs/scene";
  42059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42060. import "babylonjs/Meshes/Builders/linesBuilder";
  42061. /**
  42062. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42063. * in order to better appreciate the issue one might have.
  42064. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42065. */
  42066. export class RayHelper {
  42067. /**
  42068. * Defines the ray we are currently tryin to visualize.
  42069. */
  42070. ray: Nullable<Ray>;
  42071. private _renderPoints;
  42072. private _renderLine;
  42073. private _renderFunction;
  42074. private _scene;
  42075. private _updateToMeshFunction;
  42076. private _attachedToMesh;
  42077. private _meshSpaceDirection;
  42078. private _meshSpaceOrigin;
  42079. /**
  42080. * Helper function to create a colored helper in a scene in one line.
  42081. * @param ray Defines the ray we are currently tryin to visualize
  42082. * @param scene Defines the scene the ray is used in
  42083. * @param color Defines the color we want to see the ray in
  42084. * @returns The newly created ray helper.
  42085. */
  42086. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42087. /**
  42088. * Instantiate a new ray helper.
  42089. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42090. * in order to better appreciate the issue one might have.
  42091. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42092. * @param ray Defines the ray we are currently tryin to visualize
  42093. */
  42094. constructor(ray: Ray);
  42095. /**
  42096. * Shows the ray we are willing to debug.
  42097. * @param scene Defines the scene the ray needs to be rendered in
  42098. * @param color Defines the color the ray needs to be rendered in
  42099. */
  42100. show(scene: Scene, color?: Color3): void;
  42101. /**
  42102. * Hides the ray we are debugging.
  42103. */
  42104. hide(): void;
  42105. private _render;
  42106. /**
  42107. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42108. * @param mesh Defines the mesh we want the helper attached to
  42109. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42110. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42111. * @param length Defines the length of the ray
  42112. */
  42113. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42114. /**
  42115. * Detach the ray helper from the mesh it has previously been attached to.
  42116. */
  42117. detachFromMesh(): void;
  42118. private _updateToMesh;
  42119. /**
  42120. * Dispose the helper and release its associated resources.
  42121. */
  42122. dispose(): void;
  42123. }
  42124. }
  42125. declare module "babylonjs/Debug/skeletonViewer" {
  42126. import { Color3 } from "babylonjs/Maths/math";
  42127. import { Scene } from "babylonjs/scene";
  42128. import { Nullable } from "babylonjs/types";
  42129. import { Skeleton } from "babylonjs/Bones/skeleton";
  42130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42131. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42132. /**
  42133. * Class used to render a debug view of a given skeleton
  42134. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42135. */
  42136. export class SkeletonViewer {
  42137. /** defines the skeleton to render */
  42138. skeleton: Skeleton;
  42139. /** defines the mesh attached to the skeleton */
  42140. mesh: AbstractMesh;
  42141. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42142. autoUpdateBonesMatrices: boolean;
  42143. /** defines the rendering group id to use with the viewer */
  42144. renderingGroupId: number;
  42145. /** Gets or sets the color used to render the skeleton */
  42146. color: Color3;
  42147. private _scene;
  42148. private _debugLines;
  42149. private _debugMesh;
  42150. private _isEnabled;
  42151. private _renderFunction;
  42152. private _utilityLayer;
  42153. /**
  42154. * Returns the mesh used to render the bones
  42155. */
  42156. readonly debugMesh: Nullable<LinesMesh>;
  42157. /**
  42158. * Creates a new SkeletonViewer
  42159. * @param skeleton defines the skeleton to render
  42160. * @param mesh defines the mesh attached to the skeleton
  42161. * @param scene defines the hosting scene
  42162. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42163. * @param renderingGroupId defines the rendering group id to use with the viewer
  42164. */
  42165. constructor(
  42166. /** defines the skeleton to render */
  42167. skeleton: Skeleton,
  42168. /** defines the mesh attached to the skeleton */
  42169. mesh: AbstractMesh, scene: Scene,
  42170. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42171. autoUpdateBonesMatrices?: boolean,
  42172. /** defines the rendering group id to use with the viewer */
  42173. renderingGroupId?: number);
  42174. /** Gets or sets a boolean indicating if the viewer is enabled */
  42175. isEnabled: boolean;
  42176. private _getBonePosition;
  42177. private _getLinesForBonesWithLength;
  42178. private _getLinesForBonesNoLength;
  42179. /** Update the viewer to sync with current skeleton state */
  42180. update(): void;
  42181. /** Release associated resources */
  42182. dispose(): void;
  42183. }
  42184. }
  42185. declare module "babylonjs/Debug/index" {
  42186. export * from "babylonjs/Debug/axesViewer";
  42187. export * from "babylonjs/Debug/boneAxesViewer";
  42188. export * from "babylonjs/Debug/debugLayer";
  42189. export * from "babylonjs/Debug/physicsViewer";
  42190. export * from "babylonjs/Debug/rayHelper";
  42191. export * from "babylonjs/Debug/skeletonViewer";
  42192. }
  42193. declare module "babylonjs/Engines/nullEngine" {
  42194. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42195. import { Scene } from "babylonjs/scene";
  42196. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42197. import { Engine } from "babylonjs/Engines/engine";
  42198. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42199. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42200. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42201. import { Effect } from "babylonjs/Materials/effect";
  42202. /**
  42203. * Options to create the null engine
  42204. */
  42205. export class NullEngineOptions {
  42206. /**
  42207. * Render width (Default: 512)
  42208. */
  42209. renderWidth: number;
  42210. /**
  42211. * Render height (Default: 256)
  42212. */
  42213. renderHeight: number;
  42214. /**
  42215. * Texture size (Default: 512)
  42216. */
  42217. textureSize: number;
  42218. /**
  42219. * If delta time between frames should be constant
  42220. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42221. */
  42222. deterministicLockstep: boolean;
  42223. /**
  42224. * Maximum about of steps between frames (Default: 4)
  42225. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42226. */
  42227. lockstepMaxSteps: number;
  42228. }
  42229. /**
  42230. * The null engine class provides support for headless version of babylon.js.
  42231. * This can be used in server side scenario or for testing purposes
  42232. */
  42233. export class NullEngine extends Engine {
  42234. private _options;
  42235. /**
  42236. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42237. */
  42238. isDeterministicLockStep(): boolean;
  42239. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42240. getLockstepMaxSteps(): number;
  42241. /**
  42242. * Sets hardware scaling, used to save performance if needed
  42243. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42244. */
  42245. getHardwareScalingLevel(): number;
  42246. constructor(options?: NullEngineOptions);
  42247. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42248. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  42249. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42250. getRenderWidth(useScreen?: boolean): number;
  42251. getRenderHeight(useScreen?: boolean): number;
  42252. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42253. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42254. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  42255. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  42256. bindSamplers(effect: Effect): void;
  42257. enableEffect(effect: Effect): void;
  42258. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42259. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42260. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42261. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42262. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42263. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42264. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42265. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42266. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42267. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42268. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42269. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42270. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42271. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42272. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42273. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42274. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42275. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42276. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42277. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42278. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42279. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42280. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42281. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42282. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42283. bindBuffers(vertexBuffers: {
  42284. [key: string]: VertexBuffer;
  42285. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  42286. wipeCaches(bruteForce?: boolean): void;
  42287. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42288. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42289. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42290. /** @hidden */
  42291. _createTexture(): WebGLTexture;
  42292. /** @hidden */
  42293. _releaseTexture(texture: InternalTexture): void;
  42294. 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;
  42295. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42296. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42297. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42298. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42299. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42300. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42301. areAllEffectsReady(): boolean;
  42302. /**
  42303. * @hidden
  42304. * Get the current error code of the webGL context
  42305. * @returns the error code
  42306. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42307. */
  42308. getError(): number;
  42309. /** @hidden */
  42310. _getUnpackAlignement(): number;
  42311. /** @hidden */
  42312. _unpackFlipY(value: boolean): void;
  42313. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42314. /**
  42315. * Updates a dynamic vertex buffer.
  42316. * @param vertexBuffer the vertex buffer to update
  42317. * @param data the data used to update the vertex buffer
  42318. * @param byteOffset the byte offset of the data (optional)
  42319. * @param byteLength the byte length of the data (optional)
  42320. */
  42321. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42322. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42323. /** @hidden */
  42324. _bindTexture(channel: number, texture: InternalTexture): void;
  42325. /** @hidden */
  42326. _releaseBuffer(buffer: WebGLBuffer): boolean;
  42327. releaseEffects(): void;
  42328. displayLoadingUI(): void;
  42329. hideLoadingUI(): void;
  42330. /** @hidden */
  42331. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42332. /** @hidden */
  42333. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42334. /** @hidden */
  42335. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42336. /** @hidden */
  42337. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42338. }
  42339. }
  42340. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42341. import { Nullable, int } from "babylonjs/types";
  42342. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42343. /** @hidden */
  42344. export class _OcclusionDataStorage {
  42345. /** @hidden */
  42346. occlusionInternalRetryCounter: number;
  42347. /** @hidden */
  42348. isOcclusionQueryInProgress: boolean;
  42349. /** @hidden */
  42350. isOccluded: boolean;
  42351. /** @hidden */
  42352. occlusionRetryCount: number;
  42353. /** @hidden */
  42354. occlusionType: number;
  42355. /** @hidden */
  42356. occlusionQueryAlgorithmType: number;
  42357. }
  42358. module "babylonjs/Engines/engine" {
  42359. interface Engine {
  42360. /**
  42361. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42362. * @return the new query
  42363. */
  42364. createQuery(): WebGLQuery;
  42365. /**
  42366. * Delete and release a webGL query
  42367. * @param query defines the query to delete
  42368. * @return the current engine
  42369. */
  42370. deleteQuery(query: WebGLQuery): Engine;
  42371. /**
  42372. * Check if a given query has resolved and got its value
  42373. * @param query defines the query to check
  42374. * @returns true if the query got its value
  42375. */
  42376. isQueryResultAvailable(query: WebGLQuery): boolean;
  42377. /**
  42378. * Gets the value of a given query
  42379. * @param query defines the query to check
  42380. * @returns the value of the query
  42381. */
  42382. getQueryResult(query: WebGLQuery): number;
  42383. /**
  42384. * Initiates an occlusion query
  42385. * @param algorithmType defines the algorithm to use
  42386. * @param query defines the query to use
  42387. * @returns the current engine
  42388. * @see http://doc.babylonjs.com/features/occlusionquery
  42389. */
  42390. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42391. /**
  42392. * Ends an occlusion query
  42393. * @see http://doc.babylonjs.com/features/occlusionquery
  42394. * @param algorithmType defines the algorithm to use
  42395. * @returns the current engine
  42396. */
  42397. endOcclusionQuery(algorithmType: number): Engine;
  42398. /**
  42399. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42400. * Please note that only one query can be issued at a time
  42401. * @returns a time token used to track the time span
  42402. */
  42403. startTimeQuery(): Nullable<_TimeToken>;
  42404. /**
  42405. * Ends a time query
  42406. * @param token defines the token used to measure the time span
  42407. * @returns the time spent (in ns)
  42408. */
  42409. endTimeQuery(token: _TimeToken): int;
  42410. /** @hidden */
  42411. _currentNonTimestampToken: Nullable<_TimeToken>;
  42412. /** @hidden */
  42413. _createTimeQuery(): WebGLQuery;
  42414. /** @hidden */
  42415. _deleteTimeQuery(query: WebGLQuery): void;
  42416. /** @hidden */
  42417. _getGlAlgorithmType(algorithmType: number): number;
  42418. /** @hidden */
  42419. _getTimeQueryResult(query: WebGLQuery): any;
  42420. /** @hidden */
  42421. _getTimeQueryAvailability(query: WebGLQuery): any;
  42422. }
  42423. }
  42424. module "babylonjs/Meshes/abstractMesh" {
  42425. interface AbstractMesh {
  42426. /**
  42427. * Backing filed
  42428. * @hidden
  42429. */
  42430. __occlusionDataStorage: _OcclusionDataStorage;
  42431. /**
  42432. * Access property
  42433. * @hidden
  42434. */
  42435. _occlusionDataStorage: _OcclusionDataStorage;
  42436. /**
  42437. * 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.
  42438. * The default value is -1 which means don't break the query and wait till the result
  42439. * @see http://doc.babylonjs.com/features/occlusionquery
  42440. */
  42441. occlusionRetryCount: number;
  42442. /**
  42443. * 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:
  42444. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42445. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42446. * * 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.
  42447. * @see http://doc.babylonjs.com/features/occlusionquery
  42448. */
  42449. occlusionType: number;
  42450. /**
  42451. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42452. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42453. * * 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.
  42454. * @see http://doc.babylonjs.com/features/occlusionquery
  42455. */
  42456. occlusionQueryAlgorithmType: number;
  42457. /**
  42458. * 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
  42459. * @see http://doc.babylonjs.com/features/occlusionquery
  42460. */
  42461. isOccluded: boolean;
  42462. /**
  42463. * Flag to check the progress status of the query
  42464. * @see http://doc.babylonjs.com/features/occlusionquery
  42465. */
  42466. isOcclusionQueryInProgress: boolean;
  42467. }
  42468. }
  42469. }
  42470. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42471. import { Nullable } from "babylonjs/types";
  42472. /** @hidden */
  42473. export var _forceTransformFeedbackToBundle: boolean;
  42474. module "babylonjs/Engines/engine" {
  42475. interface Engine {
  42476. /**
  42477. * Creates a webGL transform feedback object
  42478. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42479. * @returns the webGL transform feedback object
  42480. */
  42481. createTransformFeedback(): WebGLTransformFeedback;
  42482. /**
  42483. * Delete a webGL transform feedback object
  42484. * @param value defines the webGL transform feedback object to delete
  42485. */
  42486. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42487. /**
  42488. * Bind a webGL transform feedback object to the webgl context
  42489. * @param value defines the webGL transform feedback object to bind
  42490. */
  42491. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42492. /**
  42493. * Begins a transform feedback operation
  42494. * @param usePoints defines if points or triangles must be used
  42495. */
  42496. beginTransformFeedback(usePoints: boolean): void;
  42497. /**
  42498. * Ends a transform feedback operation
  42499. */
  42500. endTransformFeedback(): void;
  42501. /**
  42502. * Specify the varyings to use with transform feedback
  42503. * @param program defines the associated webGL program
  42504. * @param value defines the list of strings representing the varying names
  42505. */
  42506. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42507. /**
  42508. * Bind a webGL buffer for a transform feedback operation
  42509. * @param value defines the webGL buffer to bind
  42510. */
  42511. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42512. }
  42513. }
  42514. }
  42515. declare module "babylonjs/Engines/Extensions/index" {
  42516. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42517. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42518. }
  42519. declare module "babylonjs/Engines/index" {
  42520. export * from "babylonjs/Engines/constants";
  42521. export * from "babylonjs/Engines/engine";
  42522. export * from "babylonjs/Engines/engineStore";
  42523. export * from "babylonjs/Engines/nullEngine";
  42524. export * from "babylonjs/Engines/Extensions/index";
  42525. }
  42526. declare module "babylonjs/Events/clipboardEvents" {
  42527. /**
  42528. * Gather the list of clipboard event types as constants.
  42529. */
  42530. export class ClipboardEventTypes {
  42531. /**
  42532. * The clipboard event is fired when a copy command is active (pressed).
  42533. */
  42534. static readonly COPY: number;
  42535. /**
  42536. * The clipboard event is fired when a cut command is active (pressed).
  42537. */
  42538. static readonly CUT: number;
  42539. /**
  42540. * The clipboard event is fired when a paste command is active (pressed).
  42541. */
  42542. static readonly PASTE: number;
  42543. }
  42544. /**
  42545. * This class is used to store clipboard related info for the onClipboardObservable event.
  42546. */
  42547. export class ClipboardInfo {
  42548. /**
  42549. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42550. */
  42551. type: number;
  42552. /**
  42553. * Defines the related dom event
  42554. */
  42555. event: ClipboardEvent;
  42556. /**
  42557. *Creates an instance of ClipboardInfo.
  42558. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  42559. * @param event Defines the related dom event
  42560. */
  42561. constructor(
  42562. /**
  42563. * Defines the type of event (BABYLON.ClipboardEventTypes)
  42564. */
  42565. type: number,
  42566. /**
  42567. * Defines the related dom event
  42568. */
  42569. event: ClipboardEvent);
  42570. /**
  42571. * Get the clipboard event's type from the keycode.
  42572. * @param keyCode Defines the keyCode for the current keyboard event.
  42573. * @return {number}
  42574. */
  42575. static GetTypeFromCharacter(keyCode: number): number;
  42576. }
  42577. }
  42578. declare module "babylonjs/Events/index" {
  42579. export * from "babylonjs/Events/keyboardEvents";
  42580. export * from "babylonjs/Events/pointerEvents";
  42581. export * from "babylonjs/Events/clipboardEvents";
  42582. }
  42583. declare module "babylonjs/Loading/sceneLoader" {
  42584. import { Observable } from "babylonjs/Misc/observable";
  42585. import { Nullable } from "babylonjs/types";
  42586. import { Scene } from "babylonjs/scene";
  42587. import { Engine } from "babylonjs/Engines/engine";
  42588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42589. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42590. import { AssetContainer } from "babylonjs/assetContainer";
  42591. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42592. import { Skeleton } from "babylonjs/Bones/skeleton";
  42593. /**
  42594. * Class used to represent data loading progression
  42595. */
  42596. export class SceneLoaderProgressEvent {
  42597. /** defines if data length to load can be evaluated */
  42598. readonly lengthComputable: boolean;
  42599. /** defines the loaded data length */
  42600. readonly loaded: number;
  42601. /** defines the data length to load */
  42602. readonly total: number;
  42603. /**
  42604. * Create a new progress event
  42605. * @param lengthComputable defines if data length to load can be evaluated
  42606. * @param loaded defines the loaded data length
  42607. * @param total defines the data length to load
  42608. */
  42609. constructor(
  42610. /** defines if data length to load can be evaluated */
  42611. lengthComputable: boolean,
  42612. /** defines the loaded data length */
  42613. loaded: number,
  42614. /** defines the data length to load */
  42615. total: number);
  42616. /**
  42617. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42618. * @param event defines the source event
  42619. * @returns a new SceneLoaderProgressEvent
  42620. */
  42621. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42622. }
  42623. /**
  42624. * Interface used by SceneLoader plugins to define supported file extensions
  42625. */
  42626. export interface ISceneLoaderPluginExtensions {
  42627. /**
  42628. * Defines the list of supported extensions
  42629. */
  42630. [extension: string]: {
  42631. isBinary: boolean;
  42632. };
  42633. }
  42634. /**
  42635. * Interface used by SceneLoader plugin factory
  42636. */
  42637. export interface ISceneLoaderPluginFactory {
  42638. /**
  42639. * Defines the name of the factory
  42640. */
  42641. name: string;
  42642. /**
  42643. * Function called to create a new plugin
  42644. * @return the new plugin
  42645. */
  42646. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42647. /**
  42648. * Boolean indicating if the plugin can direct load specific data
  42649. */
  42650. canDirectLoad?: (data: string) => boolean;
  42651. }
  42652. /**
  42653. * Interface used to define a SceneLoader plugin
  42654. */
  42655. export interface ISceneLoaderPlugin {
  42656. /**
  42657. * The friendly name of this plugin.
  42658. */
  42659. name: string;
  42660. /**
  42661. * The file extensions supported by this plugin.
  42662. */
  42663. extensions: string | ISceneLoaderPluginExtensions;
  42664. /**
  42665. * Import meshes into a scene.
  42666. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42667. * @param scene The scene to import into
  42668. * @param data The data to import
  42669. * @param rootUrl The root url for scene and resources
  42670. * @param meshes The meshes array to import into
  42671. * @param particleSystems The particle systems array to import into
  42672. * @param skeletons The skeletons array to import into
  42673. * @param onError The callback when import fails
  42674. * @returns True if successful or false otherwise
  42675. */
  42676. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42677. /**
  42678. * Load into a scene.
  42679. * @param scene The scene to load into
  42680. * @param data The data to import
  42681. * @param rootUrl The root url for scene and resources
  42682. * @param onError The callback when import fails
  42683. * @returns true if successful or false otherwise
  42684. */
  42685. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42686. /**
  42687. * The callback that returns true if the data can be directly loaded.
  42688. */
  42689. canDirectLoad?: (data: string) => boolean;
  42690. /**
  42691. * The callback that allows custom handling of the root url based on the response url.
  42692. */
  42693. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42694. /**
  42695. * Load into an asset container.
  42696. * @param scene The scene to load into
  42697. * @param data The data to import
  42698. * @param rootUrl The root url for scene and resources
  42699. * @param onError The callback when import fails
  42700. * @returns The loaded asset container
  42701. */
  42702. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42703. }
  42704. /**
  42705. * Interface used to define an async SceneLoader plugin
  42706. */
  42707. export interface ISceneLoaderPluginAsync {
  42708. /**
  42709. * The friendly name of this plugin.
  42710. */
  42711. name: string;
  42712. /**
  42713. * The file extensions supported by this plugin.
  42714. */
  42715. extensions: string | ISceneLoaderPluginExtensions;
  42716. /**
  42717. * Import meshes into a scene.
  42718. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42719. * @param scene The scene to import into
  42720. * @param data The data to import
  42721. * @param rootUrl The root url for scene and resources
  42722. * @param onProgress The callback when the load progresses
  42723. * @param fileName Defines the name of the file to load
  42724. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42725. */
  42726. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42727. meshes: AbstractMesh[];
  42728. particleSystems: IParticleSystem[];
  42729. skeletons: Skeleton[];
  42730. animationGroups: AnimationGroup[];
  42731. }>;
  42732. /**
  42733. * Load into a scene.
  42734. * @param scene The scene to load into
  42735. * @param data The data to import
  42736. * @param rootUrl The root url for scene and resources
  42737. * @param onProgress The callback when the load progresses
  42738. * @param fileName Defines the name of the file to load
  42739. * @returns Nothing
  42740. */
  42741. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42742. /**
  42743. * The callback that returns true if the data can be directly loaded.
  42744. */
  42745. canDirectLoad?: (data: string) => boolean;
  42746. /**
  42747. * The callback that allows custom handling of the root url based on the response url.
  42748. */
  42749. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42750. /**
  42751. * Load into an asset container.
  42752. * @param scene The scene to load into
  42753. * @param data The data to import
  42754. * @param rootUrl The root url for scene and resources
  42755. * @param onProgress The callback when the load progresses
  42756. * @param fileName Defines the name of the file to load
  42757. * @returns The loaded asset container
  42758. */
  42759. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42760. }
  42761. /**
  42762. * Class used to load scene from various file formats using registered plugins
  42763. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42764. */
  42765. export class SceneLoader {
  42766. /**
  42767. * No logging while loading
  42768. */
  42769. static readonly NO_LOGGING: number;
  42770. /**
  42771. * Minimal logging while loading
  42772. */
  42773. static readonly MINIMAL_LOGGING: number;
  42774. /**
  42775. * Summary logging while loading
  42776. */
  42777. static readonly SUMMARY_LOGGING: number;
  42778. /**
  42779. * Detailled logging while loading
  42780. */
  42781. static readonly DETAILED_LOGGING: number;
  42782. /**
  42783. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42784. */
  42785. static ForceFullSceneLoadingForIncremental: boolean;
  42786. /**
  42787. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42788. */
  42789. static ShowLoadingScreen: boolean;
  42790. /**
  42791. * Defines the current logging level (while loading the scene)
  42792. * @ignorenaming
  42793. */
  42794. static loggingLevel: number;
  42795. /**
  42796. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42797. */
  42798. static CleanBoneMatrixWeights: boolean;
  42799. /**
  42800. * Event raised when a plugin is used to load a scene
  42801. */
  42802. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42803. private static _registeredPlugins;
  42804. private static _getDefaultPlugin;
  42805. private static _getPluginForExtension;
  42806. private static _getPluginForDirectLoad;
  42807. private static _getPluginForFilename;
  42808. private static _getDirectLoad;
  42809. private static _loadData;
  42810. private static _getFileInfo;
  42811. /**
  42812. * Gets a plugin that can load the given extension
  42813. * @param extension defines the extension to load
  42814. * @returns a plugin or null if none works
  42815. */
  42816. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42817. /**
  42818. * Gets a boolean indicating that the given extension can be loaded
  42819. * @param extension defines the extension to load
  42820. * @returns true if the extension is supported
  42821. */
  42822. static IsPluginForExtensionAvailable(extension: string): boolean;
  42823. /**
  42824. * Adds a new plugin to the list of registered plugins
  42825. * @param plugin defines the plugin to add
  42826. */
  42827. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42828. /**
  42829. * Import meshes into a scene
  42830. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42831. * @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)
  42832. * @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)
  42833. * @param scene the instance of BABYLON.Scene to append to
  42834. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42835. * @param onProgress a callback with a progress event for each file being loaded
  42836. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42837. * @param pluginExtension the extension used to determine the plugin
  42838. * @returns The loaded plugin
  42839. */
  42840. 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>;
  42841. /**
  42842. * Import meshes into a scene
  42843. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42844. * @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)
  42845. * @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)
  42846. * @param scene the instance of BABYLON.Scene to append to
  42847. * @param onProgress a callback with a progress event for each file being loaded
  42848. * @param pluginExtension the extension used to determine the plugin
  42849. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42850. */
  42851. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42852. meshes: AbstractMesh[];
  42853. particleSystems: IParticleSystem[];
  42854. skeletons: Skeleton[];
  42855. animationGroups: AnimationGroup[];
  42856. }>;
  42857. /**
  42858. * Load a scene
  42859. * @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)
  42860. * @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)
  42861. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42862. * @param onSuccess a callback with the scene when import succeeds
  42863. * @param onProgress a callback with a progress event for each file being loaded
  42864. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42865. * @param pluginExtension the extension used to determine the plugin
  42866. * @returns The loaded plugin
  42867. */
  42868. 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>;
  42869. /**
  42870. * Load a scene
  42871. * @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)
  42872. * @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)
  42873. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42874. * @param onProgress a callback with a progress event for each file being loaded
  42875. * @param pluginExtension the extension used to determine the plugin
  42876. * @returns The loaded scene
  42877. */
  42878. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42879. /**
  42880. * Append a scene
  42881. * @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)
  42882. * @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)
  42883. * @param scene is the instance of BABYLON.Scene to append to
  42884. * @param onSuccess a callback with the scene when import succeeds
  42885. * @param onProgress a callback with a progress event for each file being loaded
  42886. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42887. * @param pluginExtension the extension used to determine the plugin
  42888. * @returns The loaded plugin
  42889. */
  42890. 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>;
  42891. /**
  42892. * Append a scene
  42893. * @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)
  42894. * @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)
  42895. * @param scene is the instance of BABYLON.Scene to append to
  42896. * @param onProgress a callback with a progress event for each file being loaded
  42897. * @param pluginExtension the extension used to determine the plugin
  42898. * @returns The given scene
  42899. */
  42900. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42901. /**
  42902. * Load a scene into an asset container
  42903. * @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)
  42904. * @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)
  42905. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42906. * @param onSuccess a callback with the scene when import succeeds
  42907. * @param onProgress a callback with a progress event for each file being loaded
  42908. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42909. * @param pluginExtension the extension used to determine the plugin
  42910. * @returns The loaded plugin
  42911. */
  42912. 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>;
  42913. /**
  42914. * Load a scene into an asset container
  42915. * @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)
  42916. * @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)
  42917. * @param scene is the instance of Scene to append to
  42918. * @param onProgress a callback with a progress event for each file being loaded
  42919. * @param pluginExtension the extension used to determine the plugin
  42920. * @returns The loaded asset container
  42921. */
  42922. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42923. }
  42924. }
  42925. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  42926. import { Scene } from "babylonjs/scene";
  42927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42928. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42929. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42930. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42931. /**
  42932. * Google Daydream controller
  42933. */
  42934. export class DaydreamController extends WebVRController {
  42935. /**
  42936. * Base Url for the controller model.
  42937. */
  42938. static MODEL_BASE_URL: string;
  42939. /**
  42940. * File name for the controller model.
  42941. */
  42942. static MODEL_FILENAME: string;
  42943. /**
  42944. * Gamepad Id prefix used to identify Daydream Controller.
  42945. */
  42946. static readonly GAMEPAD_ID_PREFIX: string;
  42947. /**
  42948. * Creates a new DaydreamController from a gamepad
  42949. * @param vrGamepad the gamepad that the controller should be created from
  42950. */
  42951. constructor(vrGamepad: any);
  42952. /**
  42953. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42954. * @param scene scene in which to add meshes
  42955. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42956. */
  42957. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42958. /**
  42959. * Called once for each button that changed state since the last frame
  42960. * @param buttonIdx Which button index changed
  42961. * @param state New state of the button
  42962. * @param changes Which properties on the state changed since last frame
  42963. */
  42964. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42965. }
  42966. }
  42967. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  42968. import { Scene } from "babylonjs/scene";
  42969. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42970. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42971. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42972. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42973. /**
  42974. * Gear VR Controller
  42975. */
  42976. export class GearVRController extends WebVRController {
  42977. /**
  42978. * Base Url for the controller model.
  42979. */
  42980. static MODEL_BASE_URL: string;
  42981. /**
  42982. * File name for the controller model.
  42983. */
  42984. static MODEL_FILENAME: string;
  42985. /**
  42986. * Gamepad Id prefix used to identify this controller.
  42987. */
  42988. static readonly GAMEPAD_ID_PREFIX: string;
  42989. private readonly _buttonIndexToObservableNameMap;
  42990. /**
  42991. * Creates a new GearVRController from a gamepad
  42992. * @param vrGamepad the gamepad that the controller should be created from
  42993. */
  42994. constructor(vrGamepad: any);
  42995. /**
  42996. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42997. * @param scene scene in which to add meshes
  42998. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42999. */
  43000. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43001. /**
  43002. * Called once for each button that changed state since the last frame
  43003. * @param buttonIdx Which button index changed
  43004. * @param state New state of the button
  43005. * @param changes Which properties on the state changed since last frame
  43006. */
  43007. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43008. }
  43009. }
  43010. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43011. import { Scene } from "babylonjs/scene";
  43012. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43013. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43014. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43015. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43016. /**
  43017. * Generic Controller
  43018. */
  43019. export class GenericController extends WebVRController {
  43020. /**
  43021. * Base Url for the controller model.
  43022. */
  43023. static readonly MODEL_BASE_URL: string;
  43024. /**
  43025. * File name for the controller model.
  43026. */
  43027. static readonly MODEL_FILENAME: string;
  43028. /**
  43029. * Creates a new GenericController from a gamepad
  43030. * @param vrGamepad the gamepad that the controller should be created from
  43031. */
  43032. constructor(vrGamepad: any);
  43033. /**
  43034. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43035. * @param scene scene in which to add meshes
  43036. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43037. */
  43038. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43039. /**
  43040. * Called once for each button that changed state since the last frame
  43041. * @param buttonIdx Which button index changed
  43042. * @param state New state of the button
  43043. * @param changes Which properties on the state changed since last frame
  43044. */
  43045. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43046. }
  43047. }
  43048. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43049. import { Observable } from "babylonjs/Misc/observable";
  43050. import { Scene } from "babylonjs/scene";
  43051. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43052. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43053. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43054. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43055. /**
  43056. * Oculus Touch Controller
  43057. */
  43058. export class OculusTouchController extends WebVRController {
  43059. /**
  43060. * Base Url for the controller model.
  43061. */
  43062. static MODEL_BASE_URL: string;
  43063. /**
  43064. * File name for the left controller model.
  43065. */
  43066. static MODEL_LEFT_FILENAME: string;
  43067. /**
  43068. * File name for the right controller model.
  43069. */
  43070. static MODEL_RIGHT_FILENAME: string;
  43071. /**
  43072. * Fired when the secondary trigger on this controller is modified
  43073. */
  43074. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43075. /**
  43076. * Fired when the thumb rest on this controller is modified
  43077. */
  43078. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43079. /**
  43080. * Creates a new OculusTouchController from a gamepad
  43081. * @param vrGamepad the gamepad that the controller should be created from
  43082. */
  43083. constructor(vrGamepad: any);
  43084. /**
  43085. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43086. * @param scene scene in which to add meshes
  43087. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43088. */
  43089. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43090. /**
  43091. * Fired when the A button on this controller is modified
  43092. */
  43093. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43094. /**
  43095. * Fired when the B button on this controller is modified
  43096. */
  43097. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43098. /**
  43099. * Fired when the X button on this controller is modified
  43100. */
  43101. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43102. /**
  43103. * Fired when the Y button on this controller is modified
  43104. */
  43105. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43106. /**
  43107. * Called once for each button that changed state since the last frame
  43108. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43109. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43110. * 2) secondary trigger (same)
  43111. * 3) A (right) X (left), touch, pressed = value
  43112. * 4) B / Y
  43113. * 5) thumb rest
  43114. * @param buttonIdx Which button index changed
  43115. * @param state New state of the button
  43116. * @param changes Which properties on the state changed since last frame
  43117. */
  43118. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43119. }
  43120. }
  43121. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43122. import { Scene } from "babylonjs/scene";
  43123. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43124. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43125. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43126. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43127. import { Observable } from "babylonjs/Misc/observable";
  43128. /**
  43129. * Vive Controller
  43130. */
  43131. export class ViveController extends WebVRController {
  43132. /**
  43133. * Base Url for the controller model.
  43134. */
  43135. static MODEL_BASE_URL: string;
  43136. /**
  43137. * File name for the controller model.
  43138. */
  43139. static MODEL_FILENAME: string;
  43140. /**
  43141. * Creates a new ViveController from a gamepad
  43142. * @param vrGamepad the gamepad that the controller should be created from
  43143. */
  43144. constructor(vrGamepad: any);
  43145. /**
  43146. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43147. * @param scene scene in which to add meshes
  43148. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43149. */
  43150. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43151. /**
  43152. * Fired when the left button on this controller is modified
  43153. */
  43154. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43155. /**
  43156. * Fired when the right button on this controller is modified
  43157. */
  43158. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43159. /**
  43160. * Fired when the menu button on this controller is modified
  43161. */
  43162. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43163. /**
  43164. * Called once for each button that changed state since the last frame
  43165. * Vive mapping:
  43166. * 0: touchpad
  43167. * 1: trigger
  43168. * 2: left AND right buttons
  43169. * 3: menu button
  43170. * @param buttonIdx Which button index changed
  43171. * @param state New state of the button
  43172. * @param changes Which properties on the state changed since last frame
  43173. */
  43174. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43175. }
  43176. }
  43177. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43178. import { Observable } from "babylonjs/Misc/observable";
  43179. import { Scene } from "babylonjs/scene";
  43180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43181. import { Ray } from "babylonjs/Culling/ray";
  43182. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43183. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43184. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43185. /**
  43186. * Defines the WindowsMotionController object that the state of the windows motion controller
  43187. */
  43188. export class WindowsMotionController extends WebVRController {
  43189. /**
  43190. * The base url used to load the left and right controller models
  43191. */
  43192. static MODEL_BASE_URL: string;
  43193. /**
  43194. * The name of the left controller model file
  43195. */
  43196. static MODEL_LEFT_FILENAME: string;
  43197. /**
  43198. * The name of the right controller model file
  43199. */
  43200. static MODEL_RIGHT_FILENAME: string;
  43201. /**
  43202. * The controller name prefix for this controller type
  43203. */
  43204. static readonly GAMEPAD_ID_PREFIX: string;
  43205. /**
  43206. * The controller id pattern for this controller type
  43207. */
  43208. private static readonly GAMEPAD_ID_PATTERN;
  43209. private _loadedMeshInfo;
  43210. private readonly _mapping;
  43211. /**
  43212. * Fired when the trackpad on this controller is clicked
  43213. */
  43214. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43215. /**
  43216. * Fired when the trackpad on this controller is modified
  43217. */
  43218. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43219. /**
  43220. * The current x and y values of this controller's trackpad
  43221. */
  43222. trackpad: StickValues;
  43223. /**
  43224. * Creates a new WindowsMotionController from a gamepad
  43225. * @param vrGamepad the gamepad that the controller should be created from
  43226. */
  43227. constructor(vrGamepad: any);
  43228. /**
  43229. * Fired when the trigger on this controller is modified
  43230. */
  43231. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43232. /**
  43233. * Fired when the menu button on this controller is modified
  43234. */
  43235. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43236. /**
  43237. * Fired when the grip button on this controller is modified
  43238. */
  43239. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43240. /**
  43241. * Fired when the thumbstick button on this controller is modified
  43242. */
  43243. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43244. /**
  43245. * Fired when the touchpad button on this controller is modified
  43246. */
  43247. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43248. /**
  43249. * Fired when the touchpad values on this controller are modified
  43250. */
  43251. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43252. private _updateTrackpad;
  43253. /**
  43254. * Called once per frame by the engine.
  43255. */
  43256. update(): void;
  43257. /**
  43258. * Called once for each button that changed state since the last frame
  43259. * @param buttonIdx Which button index changed
  43260. * @param state New state of the button
  43261. * @param changes Which properties on the state changed since last frame
  43262. */
  43263. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43264. /**
  43265. * Moves the buttons on the controller mesh based on their current state
  43266. * @param buttonName the name of the button to move
  43267. * @param buttonValue the value of the button which determines the buttons new position
  43268. */
  43269. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43270. /**
  43271. * Moves the axis on the controller mesh based on its current state
  43272. * @param axis the index of the axis
  43273. * @param axisValue the value of the axis which determines the meshes new position
  43274. * @hidden
  43275. */
  43276. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43277. /**
  43278. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43279. * @param scene scene in which to add meshes
  43280. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43281. */
  43282. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43283. /**
  43284. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43285. * can be transformed by button presses and axes values, based on this._mapping.
  43286. *
  43287. * @param scene scene in which the meshes exist
  43288. * @param meshes list of meshes that make up the controller model to process
  43289. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43290. */
  43291. private processModel;
  43292. private createMeshInfo;
  43293. /**
  43294. * Gets the ray of the controller in the direction the controller is pointing
  43295. * @param length the length the resulting ray should be
  43296. * @returns a ray in the direction the controller is pointing
  43297. */
  43298. getForwardRay(length?: number): Ray;
  43299. /**
  43300. * Disposes of the controller
  43301. */
  43302. dispose(): void;
  43303. }
  43304. }
  43305. declare module "babylonjs/Gamepads/Controllers/index" {
  43306. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  43307. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  43308. export * from "babylonjs/Gamepads/Controllers/genericController";
  43309. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  43310. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43311. export * from "babylonjs/Gamepads/Controllers/viveController";
  43312. export * from "babylonjs/Gamepads/Controllers/webVRController";
  43313. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  43314. }
  43315. declare module "babylonjs/Gamepads/index" {
  43316. export * from "babylonjs/Gamepads/Controllers/index";
  43317. export * from "babylonjs/Gamepads/gamepad";
  43318. export * from "babylonjs/Gamepads/gamepadManager";
  43319. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  43320. export * from "babylonjs/Gamepads/xboxGamepad";
  43321. }
  43322. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  43323. import { Observable } from "babylonjs/Misc/observable";
  43324. import { Nullable } from "babylonjs/types";
  43325. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43326. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43327. import { Mesh } from "babylonjs/Meshes/mesh";
  43328. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43329. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43330. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43331. /**
  43332. * Single axis scale gizmo
  43333. */
  43334. export class AxisScaleGizmo extends Gizmo {
  43335. private _coloredMaterial;
  43336. /**
  43337. * Drag behavior responsible for the gizmos dragging interactions
  43338. */
  43339. dragBehavior: PointerDragBehavior;
  43340. private _pointerObserver;
  43341. /**
  43342. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43343. */
  43344. snapDistance: number;
  43345. /**
  43346. * Event that fires each time the gizmo snaps to a new location.
  43347. * * snapDistance is the the change in distance
  43348. */
  43349. onSnapObservable: Observable<{
  43350. snapDistance: number;
  43351. }>;
  43352. /**
  43353. * If the scaling operation should be done on all axis (default: false)
  43354. */
  43355. uniformScaling: boolean;
  43356. /**
  43357. * Creates an AxisScaleGizmo
  43358. * @param gizmoLayer The utility layer the gizmo will be added to
  43359. * @param dragAxis The axis which the gizmo will be able to scale on
  43360. * @param color The color of the gizmo
  43361. */
  43362. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43363. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43364. /**
  43365. * Disposes of the gizmo
  43366. */
  43367. dispose(): void;
  43368. /**
  43369. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43370. * @param mesh The mesh to replace the default mesh of the gizmo
  43371. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43372. */
  43373. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43374. }
  43375. }
  43376. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43377. import { Observable } from "babylonjs/Misc/observable";
  43378. import { Nullable } from "babylonjs/types";
  43379. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43380. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43381. import { Mesh } from "babylonjs/Meshes/mesh";
  43382. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43383. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43384. import "babylonjs/Meshes/Builders/boxBuilder";
  43385. /**
  43386. * Bounding box gizmo
  43387. */
  43388. export class BoundingBoxGizmo extends Gizmo {
  43389. private _lineBoundingBox;
  43390. private _rotateSpheresParent;
  43391. private _scaleBoxesParent;
  43392. private _boundingDimensions;
  43393. private _renderObserver;
  43394. private _pointerObserver;
  43395. private _scaleDragSpeed;
  43396. private _tmpQuaternion;
  43397. private _tmpVector;
  43398. private _tmpRotationMatrix;
  43399. /**
  43400. * 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)
  43401. */
  43402. ignoreChildren: boolean;
  43403. /**
  43404. * 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)
  43405. */
  43406. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43407. /**
  43408. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43409. */
  43410. rotationSphereSize: number;
  43411. /**
  43412. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43413. */
  43414. scaleBoxSize: number;
  43415. /**
  43416. * 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)
  43417. */
  43418. fixedDragMeshScreenSize: boolean;
  43419. /**
  43420. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43421. */
  43422. fixedDragMeshScreenSizeDistanceFactor: number;
  43423. /**
  43424. * Fired when a rotation sphere or scale box is dragged
  43425. */
  43426. onDragStartObservable: Observable<{}>;
  43427. /**
  43428. * Fired when a scale box is dragged
  43429. */
  43430. onScaleBoxDragObservable: Observable<{}>;
  43431. /**
  43432. * Fired when a scale box drag is ended
  43433. */
  43434. onScaleBoxDragEndObservable: Observable<{}>;
  43435. /**
  43436. * Fired when a rotation sphere is dragged
  43437. */
  43438. onRotationSphereDragObservable: Observable<{}>;
  43439. /**
  43440. * Fired when a rotation sphere drag is ended
  43441. */
  43442. onRotationSphereDragEndObservable: Observable<{}>;
  43443. /**
  43444. * 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)
  43445. */
  43446. scalePivot: Nullable<Vector3>;
  43447. private _anchorMesh;
  43448. private _existingMeshScale;
  43449. private _dragMesh;
  43450. private pointerDragBehavior;
  43451. private coloredMaterial;
  43452. private hoverColoredMaterial;
  43453. /**
  43454. * Sets the color of the bounding box gizmo
  43455. * @param color the color to set
  43456. */
  43457. setColor(color: Color3): void;
  43458. /**
  43459. * Creates an BoundingBoxGizmo
  43460. * @param gizmoLayer The utility layer the gizmo will be added to
  43461. * @param color The color of the gizmo
  43462. */
  43463. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43464. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43465. private _selectNode;
  43466. /**
  43467. * Updates the bounding box information for the Gizmo
  43468. */
  43469. updateBoundingBox(): void;
  43470. private _updateRotationSpheres;
  43471. private _updateScaleBoxes;
  43472. /**
  43473. * Enables rotation on the specified axis and disables rotation on the others
  43474. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43475. */
  43476. setEnabledRotationAxis(axis: string): void;
  43477. /**
  43478. * Enables/disables scaling
  43479. * @param enable if scaling should be enabled
  43480. */
  43481. setEnabledScaling(enable: boolean): void;
  43482. private _updateDummy;
  43483. /**
  43484. * Enables a pointer drag behavior on the bounding box of the gizmo
  43485. */
  43486. enableDragBehavior(): void;
  43487. /**
  43488. * Disposes of the gizmo
  43489. */
  43490. dispose(): void;
  43491. /**
  43492. * 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)
  43493. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43494. * @returns the bounding box mesh with the passed in mesh as a child
  43495. */
  43496. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43497. /**
  43498. * CustomMeshes are not supported by this gizmo
  43499. * @param mesh The mesh to replace the default mesh of the gizmo
  43500. */
  43501. setCustomMesh(mesh: Mesh): void;
  43502. }
  43503. }
  43504. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43505. import { Observable } from "babylonjs/Misc/observable";
  43506. import { Nullable } from "babylonjs/types";
  43507. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43509. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43510. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43511. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43512. import "babylonjs/Meshes/Builders/linesBuilder";
  43513. /**
  43514. * Single plane rotation gizmo
  43515. */
  43516. export class PlaneRotationGizmo extends Gizmo {
  43517. /**
  43518. * Drag behavior responsible for the gizmos dragging interactions
  43519. */
  43520. dragBehavior: PointerDragBehavior;
  43521. private _pointerObserver;
  43522. /**
  43523. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43524. */
  43525. snapDistance: number;
  43526. /**
  43527. * Event that fires each time the gizmo snaps to a new location.
  43528. * * snapDistance is the the change in distance
  43529. */
  43530. onSnapObservable: Observable<{
  43531. snapDistance: number;
  43532. }>;
  43533. /**
  43534. * Creates a PlaneRotationGizmo
  43535. * @param gizmoLayer The utility layer the gizmo will be added to
  43536. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43537. * @param color The color of the gizmo
  43538. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43539. */
  43540. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43541. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43542. /**
  43543. * Disposes of the gizmo
  43544. */
  43545. dispose(): void;
  43546. }
  43547. }
  43548. declare module "babylonjs/Gizmos/rotationGizmo" {
  43549. import { Observable } from "babylonjs/Misc/observable";
  43550. import { Nullable } from "babylonjs/types";
  43551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43552. import { Mesh } from "babylonjs/Meshes/mesh";
  43553. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43554. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43555. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43556. /**
  43557. * Gizmo that enables rotating a mesh along 3 axis
  43558. */
  43559. export class RotationGizmo extends Gizmo {
  43560. /**
  43561. * Internal gizmo used for interactions on the x axis
  43562. */
  43563. xGizmo: PlaneRotationGizmo;
  43564. /**
  43565. * Internal gizmo used for interactions on the y axis
  43566. */
  43567. yGizmo: PlaneRotationGizmo;
  43568. /**
  43569. * Internal gizmo used for interactions on the z axis
  43570. */
  43571. zGizmo: PlaneRotationGizmo;
  43572. /** Fires an event when any of it's sub gizmos are dragged */
  43573. onDragStartObservable: Observable<{}>;
  43574. /** Fires an event when any of it's sub gizmos are released from dragging */
  43575. onDragEndObservable: Observable<{}>;
  43576. attachedMesh: Nullable<AbstractMesh>;
  43577. /**
  43578. * Creates a RotationGizmo
  43579. * @param gizmoLayer The utility layer the gizmo will be added to
  43580. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43581. */
  43582. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43583. updateGizmoRotationToMatchAttachedMesh: boolean;
  43584. /**
  43585. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43586. */
  43587. snapDistance: number;
  43588. /**
  43589. * Ratio for the scale of the gizmo (Default: 1)
  43590. */
  43591. scaleRatio: number;
  43592. /**
  43593. * Disposes of the gizmo
  43594. */
  43595. dispose(): void;
  43596. /**
  43597. * CustomMeshes are not supported by this gizmo
  43598. * @param mesh The mesh to replace the default mesh of the gizmo
  43599. */
  43600. setCustomMesh(mesh: Mesh): void;
  43601. }
  43602. }
  43603. declare module "babylonjs/Gizmos/positionGizmo" {
  43604. import { Observable } from "babylonjs/Misc/observable";
  43605. import { Nullable } from "babylonjs/types";
  43606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43607. import { Mesh } from "babylonjs/Meshes/mesh";
  43608. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43609. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43610. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43611. /**
  43612. * Gizmo that enables dragging a mesh along 3 axis
  43613. */
  43614. export class PositionGizmo extends Gizmo {
  43615. /**
  43616. * Internal gizmo used for interactions on the x axis
  43617. */
  43618. xGizmo: AxisDragGizmo;
  43619. /**
  43620. * Internal gizmo used for interactions on the y axis
  43621. */
  43622. yGizmo: AxisDragGizmo;
  43623. /**
  43624. * Internal gizmo used for interactions on the z axis
  43625. */
  43626. zGizmo: AxisDragGizmo;
  43627. /** Fires an event when any of it's sub gizmos are dragged */
  43628. onDragStartObservable: Observable<{}>;
  43629. /** Fires an event when any of it's sub gizmos are released from dragging */
  43630. onDragEndObservable: Observable<{}>;
  43631. attachedMesh: Nullable<AbstractMesh>;
  43632. /**
  43633. * Creates a PositionGizmo
  43634. * @param gizmoLayer The utility layer the gizmo will be added to
  43635. */
  43636. constructor(gizmoLayer?: UtilityLayerRenderer);
  43637. updateGizmoRotationToMatchAttachedMesh: boolean;
  43638. /**
  43639. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43640. */
  43641. snapDistance: number;
  43642. /**
  43643. * Ratio for the scale of the gizmo (Default: 1)
  43644. */
  43645. scaleRatio: number;
  43646. /**
  43647. * Disposes of the gizmo
  43648. */
  43649. dispose(): void;
  43650. /**
  43651. * CustomMeshes are not supported by this gizmo
  43652. * @param mesh The mesh to replace the default mesh of the gizmo
  43653. */
  43654. setCustomMesh(mesh: Mesh): void;
  43655. }
  43656. }
  43657. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  43658. import { Scene } from "babylonjs/scene";
  43659. import { Color4, Vector4 } from "babylonjs/Maths/math";
  43660. import { Mesh } from "babylonjs/Meshes/mesh";
  43661. /**
  43662. * Class containing static functions to help procedurally build meshes
  43663. */
  43664. export class PolyhedronBuilder {
  43665. /**
  43666. * Creates a polyhedron mesh
  43667. * * 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
  43668. * * The parameter `size` (positive float, default 1) sets the polygon size
  43669. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43670. * * 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`
  43671. * * 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
  43672. * * 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)`)
  43673. * * 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
  43674. * * 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
  43675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43676. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43678. * @param name defines the name of the mesh
  43679. * @param options defines the options used to create the mesh
  43680. * @param scene defines the hosting scene
  43681. * @returns the polyhedron mesh
  43682. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43683. */
  43684. static CreatePolyhedron(name: string, options: {
  43685. type?: number;
  43686. size?: number;
  43687. sizeX?: number;
  43688. sizeY?: number;
  43689. sizeZ?: number;
  43690. custom?: any;
  43691. faceUV?: Vector4[];
  43692. faceColors?: Color4[];
  43693. flat?: boolean;
  43694. updatable?: boolean;
  43695. sideOrientation?: number;
  43696. frontUVs?: Vector4;
  43697. backUVs?: Vector4;
  43698. }, scene: Scene): Mesh;
  43699. }
  43700. }
  43701. declare module "babylonjs/Gizmos/scaleGizmo" {
  43702. import { Observable } from "babylonjs/Misc/observable";
  43703. import { Nullable } from "babylonjs/types";
  43704. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43705. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43706. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  43707. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43708. /**
  43709. * Gizmo that enables scaling a mesh along 3 axis
  43710. */
  43711. export class ScaleGizmo extends Gizmo {
  43712. /**
  43713. * Internal gizmo used for interactions on the x axis
  43714. */
  43715. xGizmo: AxisScaleGizmo;
  43716. /**
  43717. * Internal gizmo used for interactions on the y axis
  43718. */
  43719. yGizmo: AxisScaleGizmo;
  43720. /**
  43721. * Internal gizmo used for interactions on the z axis
  43722. */
  43723. zGizmo: AxisScaleGizmo;
  43724. /**
  43725. * Internal gizmo used to scale all axis equally
  43726. */
  43727. uniformScaleGizmo: AxisScaleGizmo;
  43728. /** Fires an event when any of it's sub gizmos are dragged */
  43729. onDragStartObservable: Observable<{}>;
  43730. /** Fires an event when any of it's sub gizmos are released from dragging */
  43731. onDragEndObservable: Observable<{}>;
  43732. attachedMesh: Nullable<AbstractMesh>;
  43733. /**
  43734. * Creates a ScaleGizmo
  43735. * @param gizmoLayer The utility layer the gizmo will be added to
  43736. */
  43737. constructor(gizmoLayer?: UtilityLayerRenderer);
  43738. updateGizmoRotationToMatchAttachedMesh: boolean;
  43739. /**
  43740. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43741. */
  43742. snapDistance: number;
  43743. /**
  43744. * Ratio for the scale of the gizmo (Default: 1)
  43745. */
  43746. scaleRatio: number;
  43747. /**
  43748. * Disposes of the gizmo
  43749. */
  43750. dispose(): void;
  43751. }
  43752. }
  43753. declare module "babylonjs/Gizmos/gizmoManager" {
  43754. import { Observable } from "babylonjs/Misc/observable";
  43755. import { Nullable } from "babylonjs/types";
  43756. import { Scene, IDisposable } from "babylonjs/scene";
  43757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43758. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  43759. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  43760. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43761. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  43762. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  43763. /**
  43764. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43765. */
  43766. export class GizmoManager implements IDisposable {
  43767. private scene;
  43768. /**
  43769. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43770. */
  43771. gizmos: {
  43772. positionGizmo: Nullable<PositionGizmo>;
  43773. rotationGizmo: Nullable<RotationGizmo>;
  43774. scaleGizmo: Nullable<ScaleGizmo>;
  43775. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43776. };
  43777. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43778. clearGizmoOnEmptyPointerEvent: boolean;
  43779. /** Fires an event when the manager is attached to a mesh */
  43780. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43781. private _gizmosEnabled;
  43782. private _pointerObserver;
  43783. private _attachedMesh;
  43784. private _boundingBoxColor;
  43785. private _defaultUtilityLayer;
  43786. private _defaultKeepDepthUtilityLayer;
  43787. /**
  43788. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43789. */
  43790. boundingBoxDragBehavior: SixDofDragBehavior;
  43791. /**
  43792. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43793. */
  43794. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43795. /**
  43796. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43797. */
  43798. usePointerToAttachGizmos: boolean;
  43799. /**
  43800. * Instatiates a gizmo manager
  43801. * @param scene the scene to overlay the gizmos on top of
  43802. */
  43803. constructor(scene: Scene);
  43804. /**
  43805. * Attaches a set of gizmos to the specified mesh
  43806. * @param mesh The mesh the gizmo's should be attached to
  43807. */
  43808. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43809. /**
  43810. * If the position gizmo is enabled
  43811. */
  43812. positionGizmoEnabled: boolean;
  43813. /**
  43814. * If the rotation gizmo is enabled
  43815. */
  43816. rotationGizmoEnabled: boolean;
  43817. /**
  43818. * If the scale gizmo is enabled
  43819. */
  43820. scaleGizmoEnabled: boolean;
  43821. /**
  43822. * If the boundingBox gizmo is enabled
  43823. */
  43824. boundingBoxGizmoEnabled: boolean;
  43825. /**
  43826. * Disposes of the gizmo manager
  43827. */
  43828. dispose(): void;
  43829. }
  43830. }
  43831. declare module "babylonjs/Gizmos/lightGizmo" {
  43832. import { Nullable } from "babylonjs/types";
  43833. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43834. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43835. import { Light } from "babylonjs/Lights/light";
  43836. /**
  43837. * Gizmo that enables viewing a light
  43838. */
  43839. export class LightGizmo extends Gizmo {
  43840. private _box;
  43841. /**
  43842. * Creates a LightGizmo
  43843. * @param gizmoLayer The utility layer the gizmo will be added to
  43844. */
  43845. constructor(gizmoLayer?: UtilityLayerRenderer);
  43846. private _light;
  43847. /**
  43848. * The light that the gizmo is attached to
  43849. */
  43850. light: Nullable<Light>;
  43851. /**
  43852. * @hidden
  43853. * Updates the gizmo to match the attached mesh's position/rotation
  43854. */
  43855. protected _update(): void;
  43856. }
  43857. }
  43858. declare module "babylonjs/Gizmos/index" {
  43859. export * from "babylonjs/Gizmos/axisDragGizmo";
  43860. export * from "babylonjs/Gizmos/axisScaleGizmo";
  43861. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  43862. export * from "babylonjs/Gizmos/gizmo";
  43863. export * from "babylonjs/Gizmos/gizmoManager";
  43864. export * from "babylonjs/Gizmos/planeRotationGizmo";
  43865. export * from "babylonjs/Gizmos/positionGizmo";
  43866. export * from "babylonjs/Gizmos/rotationGizmo";
  43867. export * from "babylonjs/Gizmos/scaleGizmo";
  43868. export * from "babylonjs/Gizmos/lightGizmo";
  43869. }
  43870. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  43871. /** @hidden */
  43872. export var backgroundFragmentDeclaration: {
  43873. name: string;
  43874. shader: string;
  43875. };
  43876. }
  43877. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  43878. /** @hidden */
  43879. export var backgroundUboDeclaration: {
  43880. name: string;
  43881. shader: string;
  43882. };
  43883. }
  43884. declare module "babylonjs/Shaders/background.fragment" {
  43885. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  43886. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43887. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43888. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43889. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43890. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43891. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43892. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  43893. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43894. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43895. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43896. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43897. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43898. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43899. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43900. /** @hidden */
  43901. export var backgroundPixelShader: {
  43902. name: string;
  43903. shader: string;
  43904. };
  43905. }
  43906. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43907. /** @hidden */
  43908. export var backgroundVertexDeclaration: {
  43909. name: string;
  43910. shader: string;
  43911. };
  43912. }
  43913. declare module "babylonjs/Shaders/background.vertex" {
  43914. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43915. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43916. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43917. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43918. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43919. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43920. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43921. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43922. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43923. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43924. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43925. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43926. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43927. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43928. /** @hidden */
  43929. export var backgroundVertexShader: {
  43930. name: string;
  43931. shader: string;
  43932. };
  43933. }
  43934. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43935. import { Nullable, int, float } from "babylonjs/types";
  43936. import { Scene } from "babylonjs/scene";
  43937. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43938. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43940. import { Mesh } from "babylonjs/Meshes/mesh";
  43941. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43942. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43943. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43944. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43945. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43946. import "babylonjs/Shaders/background.fragment";
  43947. import "babylonjs/Shaders/background.vertex";
  43948. /**
  43949. * Background material used to create an efficient environement around your scene.
  43950. */
  43951. export class BackgroundMaterial extends PushMaterial {
  43952. /**
  43953. * Standard reflectance value at parallel view angle.
  43954. */
  43955. static StandardReflectance0: number;
  43956. /**
  43957. * Standard reflectance value at grazing angle.
  43958. */
  43959. static StandardReflectance90: number;
  43960. protected _primaryColor: Color3;
  43961. /**
  43962. * Key light Color (multiply against the environement texture)
  43963. */
  43964. primaryColor: Color3;
  43965. protected __perceptualColor: Nullable<Color3>;
  43966. /**
  43967. * Experimental Internal Use Only.
  43968. *
  43969. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43970. * This acts as a helper to set the primary color to a more "human friendly" value.
  43971. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43972. * output color as close as possible from the chosen value.
  43973. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43974. * part of lighting setup.)
  43975. */
  43976. _perceptualColor: Nullable<Color3>;
  43977. protected _primaryColorShadowLevel: float;
  43978. /**
  43979. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43980. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43981. */
  43982. primaryColorShadowLevel: float;
  43983. protected _primaryColorHighlightLevel: float;
  43984. /**
  43985. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43986. * The primary color is used at the level chosen to define what the white area would look.
  43987. */
  43988. primaryColorHighlightLevel: float;
  43989. protected _reflectionTexture: Nullable<BaseTexture>;
  43990. /**
  43991. * Reflection Texture used in the material.
  43992. * Should be author in a specific way for the best result (refer to the documentation).
  43993. */
  43994. reflectionTexture: Nullable<BaseTexture>;
  43995. protected _reflectionBlur: float;
  43996. /**
  43997. * Reflection Texture level of blur.
  43998. *
  43999. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44000. * texture twice.
  44001. */
  44002. reflectionBlur: float;
  44003. protected _diffuseTexture: Nullable<BaseTexture>;
  44004. /**
  44005. * Diffuse Texture used in the material.
  44006. * Should be author in a specific way for the best result (refer to the documentation).
  44007. */
  44008. diffuseTexture: Nullable<BaseTexture>;
  44009. protected _shadowLights: Nullable<IShadowLight[]>;
  44010. /**
  44011. * Specify the list of lights casting shadow on the material.
  44012. * All scene shadow lights will be included if null.
  44013. */
  44014. shadowLights: Nullable<IShadowLight[]>;
  44015. protected _shadowLevel: float;
  44016. /**
  44017. * Helps adjusting the shadow to a softer level if required.
  44018. * 0 means black shadows and 1 means no shadows.
  44019. */
  44020. shadowLevel: float;
  44021. protected _sceneCenter: Vector3;
  44022. /**
  44023. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44024. * It is usually zero but might be interesting to modify according to your setup.
  44025. */
  44026. sceneCenter: Vector3;
  44027. protected _opacityFresnel: boolean;
  44028. /**
  44029. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44030. * This helps ensuring a nice transition when the camera goes under the ground.
  44031. */
  44032. opacityFresnel: boolean;
  44033. protected _reflectionFresnel: boolean;
  44034. /**
  44035. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44036. * This helps adding a mirror texture on the ground.
  44037. */
  44038. reflectionFresnel: boolean;
  44039. protected _reflectionFalloffDistance: number;
  44040. /**
  44041. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44042. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44043. */
  44044. reflectionFalloffDistance: number;
  44045. protected _reflectionAmount: number;
  44046. /**
  44047. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44048. */
  44049. reflectionAmount: number;
  44050. protected _reflectionReflectance0: number;
  44051. /**
  44052. * This specifies the weight of the reflection at grazing angle.
  44053. */
  44054. reflectionReflectance0: number;
  44055. protected _reflectionReflectance90: number;
  44056. /**
  44057. * This specifies the weight of the reflection at a perpendicular point of view.
  44058. */
  44059. reflectionReflectance90: number;
  44060. /**
  44061. * Sets the reflection reflectance fresnel values according to the default standard
  44062. * empirically know to work well :-)
  44063. */
  44064. reflectionStandardFresnelWeight: number;
  44065. protected _useRGBColor: boolean;
  44066. /**
  44067. * Helps to directly use the maps channels instead of their level.
  44068. */
  44069. useRGBColor: boolean;
  44070. protected _enableNoise: boolean;
  44071. /**
  44072. * This helps reducing the banding effect that could occur on the background.
  44073. */
  44074. enableNoise: boolean;
  44075. /**
  44076. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44077. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44078. * Recommended to be keep at 1.0 except for special cases.
  44079. */
  44080. fovMultiplier: number;
  44081. private _fovMultiplier;
  44082. /**
  44083. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44084. */
  44085. useEquirectangularFOV: boolean;
  44086. private _maxSimultaneousLights;
  44087. /**
  44088. * Number of Simultaneous lights allowed on the material.
  44089. */
  44090. maxSimultaneousLights: int;
  44091. /**
  44092. * Default configuration related to image processing available in the Background Material.
  44093. */
  44094. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44095. /**
  44096. * Keep track of the image processing observer to allow dispose and replace.
  44097. */
  44098. private _imageProcessingObserver;
  44099. /**
  44100. * Attaches a new image processing configuration to the PBR Material.
  44101. * @param configuration (if null the scene configuration will be use)
  44102. */
  44103. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44104. /**
  44105. * Gets the image processing configuration used either in this material.
  44106. */
  44107. /**
  44108. * Sets the Default image processing configuration used either in the this material.
  44109. *
  44110. * If sets to null, the scene one is in use.
  44111. */
  44112. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44113. /**
  44114. * Gets wether the color curves effect is enabled.
  44115. */
  44116. /**
  44117. * Sets wether the color curves effect is enabled.
  44118. */
  44119. cameraColorCurvesEnabled: boolean;
  44120. /**
  44121. * Gets wether the color grading effect is enabled.
  44122. */
  44123. /**
  44124. * Gets wether the color grading effect is enabled.
  44125. */
  44126. cameraColorGradingEnabled: boolean;
  44127. /**
  44128. * Gets wether tonemapping is enabled or not.
  44129. */
  44130. /**
  44131. * Sets wether tonemapping is enabled or not
  44132. */
  44133. cameraToneMappingEnabled: boolean;
  44134. /**
  44135. * The camera exposure used on this material.
  44136. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44137. * This corresponds to a photographic exposure.
  44138. */
  44139. /**
  44140. * The camera exposure used on this material.
  44141. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44142. * This corresponds to a photographic exposure.
  44143. */
  44144. cameraExposure: float;
  44145. /**
  44146. * Gets The camera contrast used on this material.
  44147. */
  44148. /**
  44149. * Sets The camera contrast used on this material.
  44150. */
  44151. cameraContrast: float;
  44152. /**
  44153. * Gets the Color Grading 2D Lookup Texture.
  44154. */
  44155. /**
  44156. * Sets the Color Grading 2D Lookup Texture.
  44157. */
  44158. cameraColorGradingTexture: Nullable<BaseTexture>;
  44159. /**
  44160. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44161. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44162. * 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;
  44163. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44164. */
  44165. /**
  44166. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44167. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44168. * 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;
  44169. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44170. */
  44171. cameraColorCurves: Nullable<ColorCurves>;
  44172. /**
  44173. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44174. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44175. */
  44176. switchToBGR: boolean;
  44177. private _renderTargets;
  44178. private _reflectionControls;
  44179. private _white;
  44180. private _primaryShadowColor;
  44181. private _primaryHighlightColor;
  44182. /**
  44183. * Instantiates a Background Material in the given scene
  44184. * @param name The friendly name of the material
  44185. * @param scene The scene to add the material to
  44186. */
  44187. constructor(name: string, scene: Scene);
  44188. /**
  44189. * Gets a boolean indicating that current material needs to register RTT
  44190. */
  44191. readonly hasRenderTargetTextures: boolean;
  44192. /**
  44193. * The entire material has been created in order to prevent overdraw.
  44194. * @returns false
  44195. */
  44196. needAlphaTesting(): boolean;
  44197. /**
  44198. * The entire material has been created in order to prevent overdraw.
  44199. * @returns true if blending is enable
  44200. */
  44201. needAlphaBlending(): boolean;
  44202. /**
  44203. * Checks wether the material is ready to be rendered for a given mesh.
  44204. * @param mesh The mesh to render
  44205. * @param subMesh The submesh to check against
  44206. * @param useInstances Specify wether or not the material is used with instances
  44207. * @returns true if all the dependencies are ready (Textures, Effects...)
  44208. */
  44209. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44210. /**
  44211. * Compute the primary color according to the chosen perceptual color.
  44212. */
  44213. private _computePrimaryColorFromPerceptualColor;
  44214. /**
  44215. * Compute the highlights and shadow colors according to their chosen levels.
  44216. */
  44217. private _computePrimaryColors;
  44218. /**
  44219. * Build the uniform buffer used in the material.
  44220. */
  44221. buildUniformLayout(): void;
  44222. /**
  44223. * Unbind the material.
  44224. */
  44225. unbind(): void;
  44226. /**
  44227. * Bind only the world matrix to the material.
  44228. * @param world The world matrix to bind.
  44229. */
  44230. bindOnlyWorldMatrix(world: Matrix): void;
  44231. /**
  44232. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44233. * @param world The world matrix to bind.
  44234. * @param subMesh The submesh to bind for.
  44235. */
  44236. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44237. /**
  44238. * Dispose the material.
  44239. * @param forceDisposeEffect Force disposal of the associated effect.
  44240. * @param forceDisposeTextures Force disposal of the associated textures.
  44241. */
  44242. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44243. /**
  44244. * Clones the material.
  44245. * @param name The cloned name.
  44246. * @returns The cloned material.
  44247. */
  44248. clone(name: string): BackgroundMaterial;
  44249. /**
  44250. * Serializes the current material to its JSON representation.
  44251. * @returns The JSON representation.
  44252. */
  44253. serialize(): any;
  44254. /**
  44255. * Gets the class name of the material
  44256. * @returns "BackgroundMaterial"
  44257. */
  44258. getClassName(): string;
  44259. /**
  44260. * Parse a JSON input to create back a background material.
  44261. * @param source The JSON data to parse
  44262. * @param scene The scene to create the parsed material in
  44263. * @param rootUrl The root url of the assets the material depends upon
  44264. * @returns the instantiated BackgroundMaterial.
  44265. */
  44266. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44267. }
  44268. }
  44269. declare module "babylonjs/Helpers/environmentHelper" {
  44270. import { Observable } from "babylonjs/Misc/observable";
  44271. import { Nullable } from "babylonjs/types";
  44272. import { Scene } from "babylonjs/scene";
  44273. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44275. import { Mesh } from "babylonjs/Meshes/mesh";
  44276. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44277. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  44278. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44279. import "babylonjs/Meshes/Builders/planeBuilder";
  44280. import "babylonjs/Meshes/Builders/boxBuilder";
  44281. /**
  44282. * Represents the different options available during the creation of
  44283. * a Environment helper.
  44284. *
  44285. * This can control the default ground, skybox and image processing setup of your scene.
  44286. */
  44287. export interface IEnvironmentHelperOptions {
  44288. /**
  44289. * Specifies wether or not to create a ground.
  44290. * True by default.
  44291. */
  44292. createGround: boolean;
  44293. /**
  44294. * Specifies the ground size.
  44295. * 15 by default.
  44296. */
  44297. groundSize: number;
  44298. /**
  44299. * The texture used on the ground for the main color.
  44300. * Comes from the BabylonJS CDN by default.
  44301. *
  44302. * Remarks: Can be either a texture or a url.
  44303. */
  44304. groundTexture: string | BaseTexture;
  44305. /**
  44306. * The color mixed in the ground texture by default.
  44307. * BabylonJS clearColor by default.
  44308. */
  44309. groundColor: Color3;
  44310. /**
  44311. * Specifies the ground opacity.
  44312. * 1 by default.
  44313. */
  44314. groundOpacity: number;
  44315. /**
  44316. * Enables the ground to receive shadows.
  44317. * True by default.
  44318. */
  44319. enableGroundShadow: boolean;
  44320. /**
  44321. * Helps preventing the shadow to be fully black on the ground.
  44322. * 0.5 by default.
  44323. */
  44324. groundShadowLevel: number;
  44325. /**
  44326. * Creates a mirror texture attach to the ground.
  44327. * false by default.
  44328. */
  44329. enableGroundMirror: boolean;
  44330. /**
  44331. * Specifies the ground mirror size ratio.
  44332. * 0.3 by default as the default kernel is 64.
  44333. */
  44334. groundMirrorSizeRatio: number;
  44335. /**
  44336. * Specifies the ground mirror blur kernel size.
  44337. * 64 by default.
  44338. */
  44339. groundMirrorBlurKernel: number;
  44340. /**
  44341. * Specifies the ground mirror visibility amount.
  44342. * 1 by default
  44343. */
  44344. groundMirrorAmount: number;
  44345. /**
  44346. * Specifies the ground mirror reflectance weight.
  44347. * This uses the standard weight of the background material to setup the fresnel effect
  44348. * of the mirror.
  44349. * 1 by default.
  44350. */
  44351. groundMirrorFresnelWeight: number;
  44352. /**
  44353. * Specifies the ground mirror Falloff distance.
  44354. * This can helps reducing the size of the reflection.
  44355. * 0 by Default.
  44356. */
  44357. groundMirrorFallOffDistance: number;
  44358. /**
  44359. * Specifies the ground mirror texture type.
  44360. * Unsigned Int by Default.
  44361. */
  44362. groundMirrorTextureType: number;
  44363. /**
  44364. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44365. * the shown objects.
  44366. */
  44367. groundYBias: number;
  44368. /**
  44369. * Specifies wether or not to create a skybox.
  44370. * True by default.
  44371. */
  44372. createSkybox: boolean;
  44373. /**
  44374. * Specifies the skybox size.
  44375. * 20 by default.
  44376. */
  44377. skyboxSize: number;
  44378. /**
  44379. * The texture used on the skybox for the main color.
  44380. * Comes from the BabylonJS CDN by default.
  44381. *
  44382. * Remarks: Can be either a texture or a url.
  44383. */
  44384. skyboxTexture: string | BaseTexture;
  44385. /**
  44386. * The color mixed in the skybox texture by default.
  44387. * BabylonJS clearColor by default.
  44388. */
  44389. skyboxColor: Color3;
  44390. /**
  44391. * The background rotation around the Y axis of the scene.
  44392. * This helps aligning the key lights of your scene with the background.
  44393. * 0 by default.
  44394. */
  44395. backgroundYRotation: number;
  44396. /**
  44397. * Compute automatically the size of the elements to best fit with the scene.
  44398. */
  44399. sizeAuto: boolean;
  44400. /**
  44401. * Default position of the rootMesh if autoSize is not true.
  44402. */
  44403. rootPosition: Vector3;
  44404. /**
  44405. * Sets up the image processing in the scene.
  44406. * true by default.
  44407. */
  44408. setupImageProcessing: boolean;
  44409. /**
  44410. * The texture used as your environment texture in the scene.
  44411. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44412. *
  44413. * Remarks: Can be either a texture or a url.
  44414. */
  44415. environmentTexture: string | BaseTexture;
  44416. /**
  44417. * The value of the exposure to apply to the scene.
  44418. * 0.6 by default if setupImageProcessing is true.
  44419. */
  44420. cameraExposure: number;
  44421. /**
  44422. * The value of the contrast to apply to the scene.
  44423. * 1.6 by default if setupImageProcessing is true.
  44424. */
  44425. cameraContrast: number;
  44426. /**
  44427. * Specifies wether or not tonemapping should be enabled in the scene.
  44428. * true by default if setupImageProcessing is true.
  44429. */
  44430. toneMappingEnabled: boolean;
  44431. }
  44432. /**
  44433. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44434. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44435. * It also helps with the default setup of your imageProcessing configuration.
  44436. */
  44437. export class EnvironmentHelper {
  44438. /**
  44439. * Default ground texture URL.
  44440. */
  44441. private static _groundTextureCDNUrl;
  44442. /**
  44443. * Default skybox texture URL.
  44444. */
  44445. private static _skyboxTextureCDNUrl;
  44446. /**
  44447. * Default environment texture URL.
  44448. */
  44449. private static _environmentTextureCDNUrl;
  44450. /**
  44451. * Creates the default options for the helper.
  44452. */
  44453. private static _getDefaultOptions;
  44454. private _rootMesh;
  44455. /**
  44456. * Gets the root mesh created by the helper.
  44457. */
  44458. readonly rootMesh: Mesh;
  44459. private _skybox;
  44460. /**
  44461. * Gets the skybox created by the helper.
  44462. */
  44463. readonly skybox: Nullable<Mesh>;
  44464. private _skyboxTexture;
  44465. /**
  44466. * Gets the skybox texture created by the helper.
  44467. */
  44468. readonly skyboxTexture: Nullable<BaseTexture>;
  44469. private _skyboxMaterial;
  44470. /**
  44471. * Gets the skybox material created by the helper.
  44472. */
  44473. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44474. private _ground;
  44475. /**
  44476. * Gets the ground mesh created by the helper.
  44477. */
  44478. readonly ground: Nullable<Mesh>;
  44479. private _groundTexture;
  44480. /**
  44481. * Gets the ground texture created by the helper.
  44482. */
  44483. readonly groundTexture: Nullable<BaseTexture>;
  44484. private _groundMirror;
  44485. /**
  44486. * Gets the ground mirror created by the helper.
  44487. */
  44488. readonly groundMirror: Nullable<MirrorTexture>;
  44489. /**
  44490. * Gets the ground mirror render list to helps pushing the meshes
  44491. * you wish in the ground reflection.
  44492. */
  44493. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44494. private _groundMaterial;
  44495. /**
  44496. * Gets the ground material created by the helper.
  44497. */
  44498. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44499. /**
  44500. * Stores the creation options.
  44501. */
  44502. private readonly _scene;
  44503. private _options;
  44504. /**
  44505. * This observable will be notified with any error during the creation of the environment,
  44506. * mainly texture creation errors.
  44507. */
  44508. onErrorObservable: Observable<{
  44509. message?: string;
  44510. exception?: any;
  44511. }>;
  44512. /**
  44513. * constructor
  44514. * @param options Defines the options we want to customize the helper
  44515. * @param scene The scene to add the material to
  44516. */
  44517. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44518. /**
  44519. * Updates the background according to the new options
  44520. * @param options
  44521. */
  44522. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44523. /**
  44524. * Sets the primary color of all the available elements.
  44525. * @param color the main color to affect to the ground and the background
  44526. */
  44527. setMainColor(color: Color3): void;
  44528. /**
  44529. * Setup the image processing according to the specified options.
  44530. */
  44531. private _setupImageProcessing;
  44532. /**
  44533. * Setup the environment texture according to the specified options.
  44534. */
  44535. private _setupEnvironmentTexture;
  44536. /**
  44537. * Setup the background according to the specified options.
  44538. */
  44539. private _setupBackground;
  44540. /**
  44541. * Get the scene sizes according to the setup.
  44542. */
  44543. private _getSceneSize;
  44544. /**
  44545. * Setup the ground according to the specified options.
  44546. */
  44547. private _setupGround;
  44548. /**
  44549. * Setup the ground material according to the specified options.
  44550. */
  44551. private _setupGroundMaterial;
  44552. /**
  44553. * Setup the ground diffuse texture according to the specified options.
  44554. */
  44555. private _setupGroundDiffuseTexture;
  44556. /**
  44557. * Setup the ground mirror texture according to the specified options.
  44558. */
  44559. private _setupGroundMirrorTexture;
  44560. /**
  44561. * Setup the ground to receive the mirror texture.
  44562. */
  44563. private _setupMirrorInGroundMaterial;
  44564. /**
  44565. * Setup the skybox according to the specified options.
  44566. */
  44567. private _setupSkybox;
  44568. /**
  44569. * Setup the skybox material according to the specified options.
  44570. */
  44571. private _setupSkyboxMaterial;
  44572. /**
  44573. * Setup the skybox reflection texture according to the specified options.
  44574. */
  44575. private _setupSkyboxReflectionTexture;
  44576. private _errorHandler;
  44577. /**
  44578. * Dispose all the elements created by the Helper.
  44579. */
  44580. dispose(): void;
  44581. }
  44582. }
  44583. declare module "babylonjs/Helpers/photoDome" {
  44584. import { Observable } from "babylonjs/Misc/observable";
  44585. import { Nullable } from "babylonjs/types";
  44586. import { Scene } from "babylonjs/scene";
  44587. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44588. import { Mesh } from "babylonjs/Meshes/mesh";
  44589. import { Texture } from "babylonjs/Materials/Textures/texture";
  44590. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44591. import "babylonjs/Meshes/Builders/sphereBuilder";
  44592. /**
  44593. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44594. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44595. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44596. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44597. */
  44598. export class PhotoDome extends TransformNode {
  44599. private _useDirectMapping;
  44600. /**
  44601. * The texture being displayed on the sphere
  44602. */
  44603. protected _photoTexture: Texture;
  44604. /**
  44605. * Gets or sets the texture being displayed on the sphere
  44606. */
  44607. photoTexture: Texture;
  44608. /**
  44609. * Observable raised when an error occured while loading the 360 image
  44610. */
  44611. onLoadErrorObservable: Observable<string>;
  44612. /**
  44613. * The skybox material
  44614. */
  44615. protected _material: BackgroundMaterial;
  44616. /**
  44617. * The surface used for the skybox
  44618. */
  44619. protected _mesh: Mesh;
  44620. /**
  44621. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44622. * Also see the options.resolution property.
  44623. */
  44624. fovMultiplier: number;
  44625. /**
  44626. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44627. * @param name Element's name, child elements will append suffixes for their own names.
  44628. * @param urlsOfPhoto defines the url of the photo to display
  44629. * @param options defines an object containing optional or exposed sub element properties
  44630. * @param onError defines a callback called when an error occured while loading the texture
  44631. */
  44632. constructor(name: string, urlOfPhoto: string, options: {
  44633. resolution?: number;
  44634. size?: number;
  44635. useDirectMapping?: boolean;
  44636. faceForward?: boolean;
  44637. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44638. /**
  44639. * Releases resources associated with this node.
  44640. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44641. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44642. */
  44643. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44644. }
  44645. }
  44646. declare module "babylonjs/Misc/textureTools" {
  44647. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44648. import { Texture } from "babylonjs/Materials/Textures/texture";
  44649. import { Scene } from "babylonjs/scene";
  44650. /**
  44651. * Class used to host texture specific utilities
  44652. */
  44653. export class TextureTools {
  44654. /**
  44655. * Uses the GPU to create a copy texture rescaled at a given size
  44656. * @param texture Texture to copy from
  44657. * @param width defines the desired width
  44658. * @param height defines the desired height
  44659. * @param useBilinearMode defines if bilinear mode has to be used
  44660. * @return the generated texture
  44661. */
  44662. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  44663. /**
  44664. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44665. * @param scene defines the hosting scene
  44666. * @returns the environment BRDF texture
  44667. */
  44668. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44669. private static _environmentBRDFBase64Texture;
  44670. }
  44671. }
  44672. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  44673. import { Nullable } from "babylonjs/types";
  44674. import { IAnimatable } from "babylonjs/Misc/tools";
  44675. import { Color3 } from "babylonjs/Maths/math";
  44676. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44677. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44678. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44679. import { Engine } from "babylonjs/Engines/engine";
  44680. import { Scene } from "babylonjs/scene";
  44681. /**
  44682. * @hidden
  44683. */
  44684. export interface IMaterialClearCoatDefines {
  44685. CLEARCOAT: boolean;
  44686. CLEARCOAT_DEFAULTIOR: boolean;
  44687. CLEARCOAT_TEXTURE: boolean;
  44688. CLEARCOAT_TEXTUREDIRECTUV: number;
  44689. CLEARCOAT_BUMP: boolean;
  44690. CLEARCOAT_BUMPDIRECTUV: number;
  44691. CLEARCOAT_TINT: boolean;
  44692. CLEARCOAT_TINT_TEXTURE: boolean;
  44693. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44694. /** @hidden */
  44695. _areTexturesDirty: boolean;
  44696. }
  44697. /**
  44698. * Define the code related to the clear coat parameters of the pbr material.
  44699. */
  44700. export class PBRClearCoatConfiguration {
  44701. /**
  44702. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44703. * The default fits with a polyurethane material.
  44704. */
  44705. private static readonly _DefaultIndiceOfRefraction;
  44706. private _isEnabled;
  44707. /**
  44708. * Defines if the clear coat is enabled in the material.
  44709. */
  44710. isEnabled: boolean;
  44711. /**
  44712. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44713. */
  44714. intensity: number;
  44715. /**
  44716. * Defines the clear coat layer roughness.
  44717. */
  44718. roughness: number;
  44719. private _indiceOfRefraction;
  44720. /**
  44721. * Defines the indice of refraction of the clear coat.
  44722. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44723. * The default fits with a polyurethane material.
  44724. * Changing the default value is more performance intensive.
  44725. */
  44726. indiceOfRefraction: number;
  44727. private _texture;
  44728. /**
  44729. * Stores the clear coat values in a texture.
  44730. */
  44731. texture: Nullable<BaseTexture>;
  44732. private _bumpTexture;
  44733. /**
  44734. * Define the clear coat specific bump texture.
  44735. */
  44736. bumpTexture: Nullable<BaseTexture>;
  44737. private _isTintEnabled;
  44738. /**
  44739. * Defines if the clear coat tint is enabled in the material.
  44740. */
  44741. isTintEnabled: boolean;
  44742. /**
  44743. * Defines if the clear coat tint is enabled in the material.
  44744. * This is only use if tint is enabled
  44745. */
  44746. tintColor: Color3;
  44747. /**
  44748. * Defines if the distance at which the tint color should be found in the
  44749. * clear coat media.
  44750. * This is only use if tint is enabled
  44751. */
  44752. tintColorAtDistance: number;
  44753. /**
  44754. * Defines the clear coat layer thickness.
  44755. * This is only use if tint is enabled
  44756. */
  44757. tintThickness: number;
  44758. private _tintTexture;
  44759. /**
  44760. * Stores the clear tint values in a texture.
  44761. * rgb is tint
  44762. * a is a thickness factor
  44763. */
  44764. tintTexture: Nullable<BaseTexture>;
  44765. /** @hidden */
  44766. private _internalMarkAllSubMeshesAsTexturesDirty;
  44767. /** @hidden */
  44768. _markAllSubMeshesAsTexturesDirty(): void;
  44769. /**
  44770. * Instantiate a new istance of clear coat configuration.
  44771. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44772. */
  44773. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44774. /**
  44775. * Specifies that the submesh is ready to be used.
  44776. * @param defines the list of "defines" to update.
  44777. * @param scene defines the scene the material belongs to.
  44778. * @param engine defines the engine the material belongs to.
  44779. * @param disableBumpMap defines wether the material disables bump or not.
  44780. * @returns - boolean indicating that the submesh is ready or not.
  44781. */
  44782. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44783. /**
  44784. * Checks to see if a texture is used in the material.
  44785. * @param defines the list of "defines" to update.
  44786. * @param scene defines the scene to the material belongs to.
  44787. */
  44788. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44789. /**
  44790. * Binds the material data.
  44791. * @param uniformBuffer defines the Uniform buffer to fill in.
  44792. * @param scene defines the scene the material belongs to.
  44793. * @param engine defines the engine the material belongs to.
  44794. * @param disableBumpMap defines wether the material disables bump or not.
  44795. * @param isFrozen defines wether the material is frozen or not.
  44796. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44797. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44798. */
  44799. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44800. /**
  44801. * Checks to see if a texture is used in the material.
  44802. * @param texture - Base texture to use.
  44803. * @returns - Boolean specifying if a texture is used in the material.
  44804. */
  44805. hasTexture(texture: BaseTexture): boolean;
  44806. /**
  44807. * Returns an array of the actively used textures.
  44808. * @param activeTextures Array of BaseTextures
  44809. */
  44810. getActiveTextures(activeTextures: BaseTexture[]): void;
  44811. /**
  44812. * Returns the animatable textures.
  44813. * @param animatables Array of animatable textures.
  44814. */
  44815. getAnimatables(animatables: IAnimatable[]): void;
  44816. /**
  44817. * Disposes the resources of the material.
  44818. * @param forceDisposeTextures - Forces the disposal of all textures.
  44819. */
  44820. dispose(forceDisposeTextures?: boolean): void;
  44821. /**
  44822. * Get the current class name of the texture useful for serialization or dynamic coding.
  44823. * @returns "PBRClearCoatConfiguration"
  44824. */
  44825. getClassName(): string;
  44826. /**
  44827. * Add fallbacks to the effect fallbacks list.
  44828. * @param defines defines the Base texture to use.
  44829. * @param fallbacks defines the current fallback list.
  44830. * @param currentRank defines the current fallback rank.
  44831. * @returns the new fallback rank.
  44832. */
  44833. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44834. /**
  44835. * Add the required uniforms to the current list.
  44836. * @param uniforms defines the current uniform list.
  44837. */
  44838. static AddUniforms(uniforms: string[]): void;
  44839. /**
  44840. * Add the required samplers to the current list.
  44841. * @param samplers defines the current sampler list.
  44842. */
  44843. static AddSamplers(samplers: string[]): void;
  44844. /**
  44845. * Add the required uniforms to the current buffer.
  44846. * @param uniformBuffer defines the current uniform buffer.
  44847. */
  44848. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44849. /**
  44850. * Makes a duplicate of the current configuration into another one.
  44851. * @param clearCoatConfiguration define the config where to copy the info
  44852. */
  44853. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44854. /**
  44855. * Serializes this clear coat configuration.
  44856. * @returns - An object with the serialized config.
  44857. */
  44858. serialize(): any;
  44859. /**
  44860. * Parses a Clear Coat Configuration from a serialized object.
  44861. * @param source - Serialized object.
  44862. */
  44863. parse(source: any): void;
  44864. }
  44865. }
  44866. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  44867. import { EffectFallbacks } from "babylonjs/Materials/effect";
  44868. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44869. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44870. import { Vector2 } from "babylonjs/Maths/math";
  44871. import { Scene } from "babylonjs/scene";
  44872. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44873. import { IAnimatable } from "babylonjs/Misc/tools";
  44874. import { Nullable } from "babylonjs/types";
  44875. /**
  44876. * @hidden
  44877. */
  44878. export interface IMaterialAnisotropicDefines {
  44879. ANISOTROPIC: boolean;
  44880. ANISOTROPIC_TEXTURE: boolean;
  44881. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44882. MAINUV1: boolean;
  44883. _areTexturesDirty: boolean;
  44884. _needUVs: boolean;
  44885. }
  44886. /**
  44887. * Define the code related to the anisotropic parameters of the pbr material.
  44888. */
  44889. export class PBRAnisotropicConfiguration {
  44890. private _isEnabled;
  44891. /**
  44892. * Defines if the anisotropy is enabled in the material.
  44893. */
  44894. isEnabled: boolean;
  44895. /**
  44896. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44897. */
  44898. intensity: number;
  44899. /**
  44900. * Defines if the effect is along the tangents, bitangents or in between.
  44901. * By default, the effect is "strectching" the highlights along the tangents.
  44902. */
  44903. direction: Vector2;
  44904. private _texture;
  44905. /**
  44906. * Stores the anisotropy values in a texture.
  44907. * rg is direction (like normal from -1 to 1)
  44908. * b is a intensity
  44909. */
  44910. texture: Nullable<BaseTexture>;
  44911. /** @hidden */
  44912. private _internalMarkAllSubMeshesAsTexturesDirty;
  44913. /** @hidden */
  44914. _markAllSubMeshesAsTexturesDirty(): void;
  44915. /**
  44916. * Instantiate a new istance of anisotropy configuration.
  44917. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44918. */
  44919. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44920. /**
  44921. * Specifies that the submesh is ready to be used.
  44922. * @param defines the list of "defines" to update.
  44923. * @param scene defines the scene the material belongs to.
  44924. * @returns - boolean indicating that the submesh is ready or not.
  44925. */
  44926. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44927. /**
  44928. * Checks to see if a texture is used in the material.
  44929. * @param defines the list of "defines" to update.
  44930. * @param mesh the mesh we are preparing the defines for.
  44931. * @param scene defines the scene the material belongs to.
  44932. */
  44933. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44934. /**
  44935. * Binds the material data.
  44936. * @param uniformBuffer defines the Uniform buffer to fill in.
  44937. * @param scene defines the scene the material belongs to.
  44938. * @param isFrozen defines wether the material is frozen or not.
  44939. */
  44940. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44941. /**
  44942. * Checks to see if a texture is used in the material.
  44943. * @param texture - Base texture to use.
  44944. * @returns - Boolean specifying if a texture is used in the material.
  44945. */
  44946. hasTexture(texture: BaseTexture): boolean;
  44947. /**
  44948. * Returns an array of the actively used textures.
  44949. * @param activeTextures Array of BaseTextures
  44950. */
  44951. getActiveTextures(activeTextures: BaseTexture[]): void;
  44952. /**
  44953. * Returns the animatable textures.
  44954. * @param animatables Array of animatable textures.
  44955. */
  44956. getAnimatables(animatables: IAnimatable[]): void;
  44957. /**
  44958. * Disposes the resources of the material.
  44959. * @param forceDisposeTextures - Forces the disposal of all textures.
  44960. */
  44961. dispose(forceDisposeTextures?: boolean): void;
  44962. /**
  44963. * Get the current class name of the texture useful for serialization or dynamic coding.
  44964. * @returns "PBRAnisotropicConfiguration"
  44965. */
  44966. getClassName(): string;
  44967. /**
  44968. * Add fallbacks to the effect fallbacks list.
  44969. * @param defines defines the Base texture to use.
  44970. * @param fallbacks defines the current fallback list.
  44971. * @param currentRank defines the current fallback rank.
  44972. * @returns the new fallback rank.
  44973. */
  44974. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44975. /**
  44976. * Add the required uniforms to the current list.
  44977. * @param uniforms defines the current uniform list.
  44978. */
  44979. static AddUniforms(uniforms: string[]): void;
  44980. /**
  44981. * Add the required uniforms to the current buffer.
  44982. * @param uniformBuffer defines the current uniform buffer.
  44983. */
  44984. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44985. /**
  44986. * Add the required samplers to the current list.
  44987. * @param samplers defines the current sampler list.
  44988. */
  44989. static AddSamplers(samplers: string[]): void;
  44990. /**
  44991. * Makes a duplicate of the current configuration into another one.
  44992. * @param anisotropicConfiguration define the config where to copy the info
  44993. */
  44994. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44995. /**
  44996. * Serializes this anisotropy configuration.
  44997. * @returns - An object with the serialized config.
  44998. */
  44999. serialize(): any;
  45000. /**
  45001. * Parses a anisotropy Configuration from a serialized object.
  45002. * @param source - Serialized object.
  45003. */
  45004. parse(source: any): void;
  45005. }
  45006. }
  45007. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  45008. /**
  45009. * @hidden
  45010. */
  45011. export interface IMaterialBRDFDefines {
  45012. BRDF_V_HEIGHT_CORRELATED: boolean;
  45013. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45014. /** @hidden */
  45015. _areMiscDirty: boolean;
  45016. }
  45017. /**
  45018. * Define the code related to the BRDF parameters of the pbr material.
  45019. */
  45020. export class PBRBRDFConfiguration {
  45021. private _useEnergyConservation;
  45022. /**
  45023. * Defines if the material uses energy conservation.
  45024. */
  45025. useEnergyConservation: boolean;
  45026. private _useSmithVisibilityHeightCorrelated;
  45027. /**
  45028. * LEGACY Mode set to false
  45029. * Defines if the material uses height smith correlated visibility term.
  45030. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45031. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45032. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45033. * Not relying on height correlated will also disable energy conservation.
  45034. */
  45035. useSmithVisibilityHeightCorrelated: boolean;
  45036. /** @hidden */
  45037. private _internalMarkAllSubMeshesAsMiscDirty;
  45038. /** @hidden */
  45039. _markAllSubMeshesAsMiscDirty(): void;
  45040. /**
  45041. * Instantiate a new istance of clear coat configuration.
  45042. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45043. */
  45044. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45045. /**
  45046. * Checks to see if a texture is used in the material.
  45047. * @param defines the list of "defines" to update.
  45048. */
  45049. prepareDefines(defines: IMaterialBRDFDefines): void;
  45050. /**
  45051. * Get the current class name of the texture useful for serialization or dynamic coding.
  45052. * @returns "PBRClearCoatConfiguration"
  45053. */
  45054. getClassName(): string;
  45055. /**
  45056. * Makes a duplicate of the current configuration into another one.
  45057. * @param brdfConfiguration define the config where to copy the info
  45058. */
  45059. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45060. /**
  45061. * Serializes this BRDF configuration.
  45062. * @returns - An object with the serialized config.
  45063. */
  45064. serialize(): any;
  45065. /**
  45066. * Parses a BRDF Configuration from a serialized object.
  45067. * @param source - Serialized object.
  45068. */
  45069. parse(source: any): void;
  45070. }
  45071. }
  45072. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  45073. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45074. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45075. import { Color3 } from "babylonjs/Maths/math";
  45076. import { Scene } from "babylonjs/scene";
  45077. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45078. import { IAnimatable } from "babylonjs/Misc/tools";
  45079. import { Nullable } from "babylonjs/types";
  45080. /**
  45081. * @hidden
  45082. */
  45083. export interface IMaterialSheenDefines {
  45084. SHEEN: boolean;
  45085. SHEEN_TEXTURE: boolean;
  45086. SHEEN_TEXTUREDIRECTUV: number;
  45087. SHEEN_LINKWITHALBEDO: boolean;
  45088. /** @hidden */
  45089. _areTexturesDirty: boolean;
  45090. }
  45091. /**
  45092. * Define the code related to the Sheen parameters of the pbr material.
  45093. */
  45094. export class PBRSheenConfiguration {
  45095. private _isEnabled;
  45096. /**
  45097. * Defines if the material uses sheen.
  45098. */
  45099. isEnabled: boolean;
  45100. private _linkSheenWithAlbedo;
  45101. /**
  45102. * Defines if the sheen is linked to the sheen color.
  45103. */
  45104. linkSheenWithAlbedo: boolean;
  45105. /**
  45106. * Defines the sheen intensity.
  45107. */
  45108. intensity: number;
  45109. /**
  45110. * Defines the sheen color.
  45111. */
  45112. color: Color3;
  45113. private _texture;
  45114. /**
  45115. * Stores the sheen tint values in a texture.
  45116. * rgb is tint
  45117. * a is a intensity
  45118. */
  45119. texture: Nullable<BaseTexture>;
  45120. /** @hidden */
  45121. private _internalMarkAllSubMeshesAsTexturesDirty;
  45122. /** @hidden */
  45123. _markAllSubMeshesAsTexturesDirty(): void;
  45124. /**
  45125. * Instantiate a new istance of clear coat configuration.
  45126. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45127. */
  45128. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45129. /**
  45130. * Specifies that the submesh is ready to be used.
  45131. * @param defines the list of "defines" to update.
  45132. * @param scene defines the scene the material belongs to.
  45133. * @returns - boolean indicating that the submesh is ready or not.
  45134. */
  45135. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45136. /**
  45137. * Checks to see if a texture is used in the material.
  45138. * @param defines the list of "defines" to update.
  45139. * @param scene defines the scene the material belongs to.
  45140. */
  45141. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45142. /**
  45143. * Binds the material data.
  45144. * @param uniformBuffer defines the Uniform buffer to fill in.
  45145. * @param scene defines the scene the material belongs to.
  45146. * @param isFrozen defines wether the material is frozen or not.
  45147. */
  45148. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45149. /**
  45150. * Checks to see if a texture is used in the material.
  45151. * @param texture - Base texture to use.
  45152. * @returns - Boolean specifying if a texture is used in the material.
  45153. */
  45154. hasTexture(texture: BaseTexture): boolean;
  45155. /**
  45156. * Returns an array of the actively used textures.
  45157. * @param activeTextures Array of BaseTextures
  45158. */
  45159. getActiveTextures(activeTextures: BaseTexture[]): void;
  45160. /**
  45161. * Returns the animatable textures.
  45162. * @param animatables Array of animatable textures.
  45163. */
  45164. getAnimatables(animatables: IAnimatable[]): void;
  45165. /**
  45166. * Disposes the resources of the material.
  45167. * @param forceDisposeTextures - Forces the disposal of all textures.
  45168. */
  45169. dispose(forceDisposeTextures?: boolean): void;
  45170. /**
  45171. * Get the current class name of the texture useful for serialization or dynamic coding.
  45172. * @returns "PBRSheenConfiguration"
  45173. */
  45174. getClassName(): string;
  45175. /**
  45176. * Add fallbacks to the effect fallbacks list.
  45177. * @param defines defines the Base texture to use.
  45178. * @param fallbacks defines the current fallback list.
  45179. * @param currentRank defines the current fallback rank.
  45180. * @returns the new fallback rank.
  45181. */
  45182. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45183. /**
  45184. * Add the required uniforms to the current list.
  45185. * @param uniforms defines the current uniform list.
  45186. */
  45187. static AddUniforms(uniforms: string[]): void;
  45188. /**
  45189. * Add the required uniforms to the current buffer.
  45190. * @param uniformBuffer defines the current uniform buffer.
  45191. */
  45192. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45193. /**
  45194. * Add the required samplers to the current list.
  45195. * @param samplers defines the current sampler list.
  45196. */
  45197. static AddSamplers(samplers: string[]): void;
  45198. /**
  45199. * Makes a duplicate of the current configuration into another one.
  45200. * @param sheenConfiguration define the config where to copy the info
  45201. */
  45202. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45203. /**
  45204. * Serializes this BRDF configuration.
  45205. * @returns - An object with the serialized config.
  45206. */
  45207. serialize(): any;
  45208. /**
  45209. * Parses a Sheen Configuration from a serialized object.
  45210. * @param source - Serialized object.
  45211. */
  45212. parse(source: any): void;
  45213. }
  45214. }
  45215. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  45216. /** @hidden */
  45217. export var pbrFragmentDeclaration: {
  45218. name: string;
  45219. shader: string;
  45220. };
  45221. }
  45222. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  45223. /** @hidden */
  45224. export var pbrUboDeclaration: {
  45225. name: string;
  45226. shader: string;
  45227. };
  45228. }
  45229. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  45230. /** @hidden */
  45231. export var pbrFunctions: {
  45232. name: string;
  45233. shader: string;
  45234. };
  45235. }
  45236. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  45237. /** @hidden */
  45238. export var harmonicsFunctions: {
  45239. name: string;
  45240. shader: string;
  45241. };
  45242. }
  45243. declare module "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions" {
  45244. /** @hidden */
  45245. export var pbrPreLightingFunctions: {
  45246. name: string;
  45247. shader: string;
  45248. };
  45249. }
  45250. declare module "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions" {
  45251. /** @hidden */
  45252. export var pbrFalloffLightingFunctions: {
  45253. name: string;
  45254. shader: string;
  45255. };
  45256. }
  45257. declare module "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions" {
  45258. /** @hidden */
  45259. export var pbrLightingFunctions: {
  45260. name: string;
  45261. shader: string;
  45262. };
  45263. }
  45264. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  45265. /** @hidden */
  45266. export var pbrDebug: {
  45267. name: string;
  45268. shader: string;
  45269. };
  45270. }
  45271. declare module "babylonjs/Shaders/pbr.fragment" {
  45272. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  45273. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  45274. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45275. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45276. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45277. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45278. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45279. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45280. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45281. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  45282. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  45283. import "babylonjs/Shaders/ShadersInclude/pbrPreLightingFunctions";
  45284. import "babylonjs/Shaders/ShadersInclude/pbrFalloffLightingFunctions";
  45285. import "babylonjs/Shaders/ShadersInclude/pbrLightingFunctions";
  45286. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  45287. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45288. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45289. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45290. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45291. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  45292. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  45293. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45294. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  45295. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45296. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  45297. /** @hidden */
  45298. export var pbrPixelShader: {
  45299. name: string;
  45300. shader: string;
  45301. };
  45302. }
  45303. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  45304. /** @hidden */
  45305. export var pbrVertexDeclaration: {
  45306. name: string;
  45307. shader: string;
  45308. };
  45309. }
  45310. declare module "babylonjs/Shaders/pbr.vertex" {
  45311. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  45312. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  45313. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45314. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45315. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45316. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  45317. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  45318. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45319. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45320. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45321. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45322. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45323. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45324. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  45325. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  45326. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45327. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45328. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  45329. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45330. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45331. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45332. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  45333. /** @hidden */
  45334. export var pbrVertexShader: {
  45335. name: string;
  45336. shader: string;
  45337. };
  45338. }
  45339. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  45340. import { IAnimatable } from "babylonjs/Misc/tools";
  45341. import { Nullable } from "babylonjs/types";
  45342. import { Scene } from "babylonjs/scene";
  45343. import { Matrix, Color3 } from "babylonjs/Maths/math";
  45344. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45345. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45346. import { Mesh } from "babylonjs/Meshes/mesh";
  45347. import { PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  45348. import { PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  45349. import { PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  45350. import { PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  45351. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45352. import { Material } from "babylonjs/Materials/material";
  45353. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45354. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45355. import "babylonjs/Shaders/pbr.fragment";
  45356. import "babylonjs/Shaders/pbr.vertex";
  45357. /**
  45358. * The Physically based material base class of BJS.
  45359. *
  45360. * This offers the main features of a standard PBR material.
  45361. * For more information, please refer to the documentation :
  45362. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45363. */
  45364. export abstract class PBRBaseMaterial extends PushMaterial {
  45365. /**
  45366. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45367. */
  45368. static readonly PBRMATERIAL_OPAQUE: number;
  45369. /**
  45370. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45371. */
  45372. static readonly PBRMATERIAL_ALPHATEST: number;
  45373. /**
  45374. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45375. */
  45376. static readonly PBRMATERIAL_ALPHABLEND: number;
  45377. /**
  45378. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45379. * They are also discarded below the alpha cutoff threshold to improve performances.
  45380. */
  45381. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45382. /**
  45383. * Defines the default value of how much AO map is occluding the analytical lights
  45384. * (point spot...).
  45385. */
  45386. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45387. /**
  45388. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45389. */
  45390. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45391. /**
  45392. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45393. * to enhance interoperability with other engines.
  45394. */
  45395. static readonly LIGHTFALLOFF_GLTF: number;
  45396. /**
  45397. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45398. * to enhance interoperability with other materials.
  45399. */
  45400. static readonly LIGHTFALLOFF_STANDARD: number;
  45401. /**
  45402. * Intensity of the direct lights e.g. the four lights available in your scene.
  45403. * This impacts both the direct diffuse and specular highlights.
  45404. */
  45405. protected _directIntensity: number;
  45406. /**
  45407. * Intensity of the emissive part of the material.
  45408. * This helps controlling the emissive effect without modifying the emissive color.
  45409. */
  45410. protected _emissiveIntensity: number;
  45411. /**
  45412. * Intensity of the environment e.g. how much the environment will light the object
  45413. * either through harmonics for rough material or through the refelction for shiny ones.
  45414. */
  45415. protected _environmentIntensity: number;
  45416. /**
  45417. * This is a special control allowing the reduction of the specular highlights coming from the
  45418. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45419. */
  45420. protected _specularIntensity: number;
  45421. /**
  45422. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45423. */
  45424. private _lightingInfos;
  45425. /**
  45426. * Debug Control allowing disabling the bump map on this material.
  45427. */
  45428. protected _disableBumpMap: boolean;
  45429. /**
  45430. * AKA Diffuse Texture in standard nomenclature.
  45431. */
  45432. protected _albedoTexture: BaseTexture;
  45433. /**
  45434. * AKA Occlusion Texture in other nomenclature.
  45435. */
  45436. protected _ambientTexture: BaseTexture;
  45437. /**
  45438. * AKA Occlusion Texture Intensity in other nomenclature.
  45439. */
  45440. protected _ambientTextureStrength: number;
  45441. /**
  45442. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45443. * 1 means it completely occludes it
  45444. * 0 mean it has no impact
  45445. */
  45446. protected _ambientTextureImpactOnAnalyticalLights: number;
  45447. /**
  45448. * Stores the alpha values in a texture.
  45449. */
  45450. protected _opacityTexture: BaseTexture;
  45451. /**
  45452. * Stores the reflection values in a texture.
  45453. */
  45454. protected _reflectionTexture: BaseTexture;
  45455. /**
  45456. * Stores the refraction values in a texture.
  45457. */
  45458. protected _refractionTexture: BaseTexture;
  45459. /**
  45460. * Stores the emissive values in a texture.
  45461. */
  45462. protected _emissiveTexture: BaseTexture;
  45463. /**
  45464. * AKA Specular texture in other nomenclature.
  45465. */
  45466. protected _reflectivityTexture: BaseTexture;
  45467. /**
  45468. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45469. */
  45470. protected _metallicTexture: BaseTexture;
  45471. /**
  45472. * Specifies the metallic scalar of the metallic/roughness workflow.
  45473. * Can also be used to scale the metalness values of the metallic texture.
  45474. */
  45475. protected _metallic: Nullable<number>;
  45476. /**
  45477. * Specifies the roughness scalar of the metallic/roughness workflow.
  45478. * Can also be used to scale the roughness values of the metallic texture.
  45479. */
  45480. protected _roughness: Nullable<number>;
  45481. /**
  45482. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45483. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45484. */
  45485. protected _microSurfaceTexture: BaseTexture;
  45486. /**
  45487. * Stores surface normal data used to displace a mesh in a texture.
  45488. */
  45489. protected _bumpTexture: BaseTexture;
  45490. /**
  45491. * Stores the pre-calculated light information of a mesh in a texture.
  45492. */
  45493. protected _lightmapTexture: BaseTexture;
  45494. /**
  45495. * The color of a material in ambient lighting.
  45496. */
  45497. protected _ambientColor: Color3;
  45498. /**
  45499. * AKA Diffuse Color in other nomenclature.
  45500. */
  45501. protected _albedoColor: Color3;
  45502. /**
  45503. * AKA Specular Color in other nomenclature.
  45504. */
  45505. protected _reflectivityColor: Color3;
  45506. /**
  45507. * The color applied when light is reflected from a material.
  45508. */
  45509. protected _reflectionColor: Color3;
  45510. /**
  45511. * The color applied when light is emitted from a material.
  45512. */
  45513. protected _emissiveColor: Color3;
  45514. /**
  45515. * AKA Glossiness in other nomenclature.
  45516. */
  45517. protected _microSurface: number;
  45518. /**
  45519. * source material index of refraction (IOR)' / 'destination material IOR.
  45520. */
  45521. protected _indexOfRefraction: number;
  45522. /**
  45523. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45524. */
  45525. protected _invertRefractionY: boolean;
  45526. /**
  45527. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45528. * Materials half opaque for instance using refraction could benefit from this control.
  45529. */
  45530. protected _linkRefractionWithTransparency: boolean;
  45531. /**
  45532. * Specifies that the material will use the light map as a show map.
  45533. */
  45534. protected _useLightmapAsShadowmap: boolean;
  45535. /**
  45536. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45537. * makes the reflect vector face the model (under horizon).
  45538. */
  45539. protected _useHorizonOcclusion: boolean;
  45540. /**
  45541. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45542. * too much the area relying on ambient texture to define their ambient occlusion.
  45543. */
  45544. protected _useRadianceOcclusion: boolean;
  45545. /**
  45546. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45547. */
  45548. protected _useAlphaFromAlbedoTexture: boolean;
  45549. /**
  45550. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45551. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45552. */
  45553. protected _useSpecularOverAlpha: boolean;
  45554. /**
  45555. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45556. */
  45557. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45558. /**
  45559. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45560. */
  45561. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45562. /**
  45563. * Specifies if the metallic texture contains the roughness information in its green channel.
  45564. */
  45565. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45566. /**
  45567. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45568. */
  45569. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45570. /**
  45571. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45572. */
  45573. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45574. /**
  45575. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45576. */
  45577. protected _useAmbientInGrayScale: boolean;
  45578. /**
  45579. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45580. * The material will try to infer what glossiness each pixel should be.
  45581. */
  45582. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45583. /**
  45584. * Defines the falloff type used in this material.
  45585. * It by default is Physical.
  45586. */
  45587. protected _lightFalloff: number;
  45588. /**
  45589. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45590. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45591. */
  45592. protected _useRadianceOverAlpha: boolean;
  45593. /**
  45594. * Allows using an object space normal map (instead of tangent space).
  45595. */
  45596. protected _useObjectSpaceNormalMap: boolean;
  45597. /**
  45598. * Allows using the bump map in parallax mode.
  45599. */
  45600. protected _useParallax: boolean;
  45601. /**
  45602. * Allows using the bump map in parallax occlusion mode.
  45603. */
  45604. protected _useParallaxOcclusion: boolean;
  45605. /**
  45606. * Controls the scale bias of the parallax mode.
  45607. */
  45608. protected _parallaxScaleBias: number;
  45609. /**
  45610. * If sets to true, disables all the lights affecting the material.
  45611. */
  45612. protected _disableLighting: boolean;
  45613. /**
  45614. * Number of Simultaneous lights allowed on the material.
  45615. */
  45616. protected _maxSimultaneousLights: number;
  45617. /**
  45618. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45619. */
  45620. protected _invertNormalMapX: boolean;
  45621. /**
  45622. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45623. */
  45624. protected _invertNormalMapY: boolean;
  45625. /**
  45626. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45627. */
  45628. protected _twoSidedLighting: boolean;
  45629. /**
  45630. * Defines the alpha limits in alpha test mode.
  45631. */
  45632. protected _alphaCutOff: number;
  45633. /**
  45634. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45635. */
  45636. protected _forceAlphaTest: boolean;
  45637. /**
  45638. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45639. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45640. */
  45641. protected _useAlphaFresnel: boolean;
  45642. /**
  45643. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45644. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45645. */
  45646. protected _useLinearAlphaFresnel: boolean;
  45647. /**
  45648. * The transparency mode of the material.
  45649. */
  45650. protected _transparencyMode: Nullable<number>;
  45651. /**
  45652. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45653. * from cos thetav and roughness:
  45654. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45655. */
  45656. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45657. /**
  45658. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45659. */
  45660. protected _forceIrradianceInFragment: boolean;
  45661. /**
  45662. * Force normal to face away from face.
  45663. */
  45664. protected _forceNormalForward: boolean;
  45665. /**
  45666. * Enables specular anti aliasing in the PBR shader.
  45667. * It will both interacts on the Geometry for analytical and IBL lighting.
  45668. * It also prefilter the roughness map based on the bump values.
  45669. */
  45670. protected _enableSpecularAntiAliasing: boolean;
  45671. /**
  45672. * Default configuration related to image processing available in the PBR Material.
  45673. */
  45674. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45675. /**
  45676. * Keep track of the image processing observer to allow dispose and replace.
  45677. */
  45678. private _imageProcessingObserver;
  45679. /**
  45680. * Attaches a new image processing configuration to the PBR Material.
  45681. * @param configuration
  45682. */
  45683. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45684. /**
  45685. * Stores the available render targets.
  45686. */
  45687. private _renderTargets;
  45688. /**
  45689. * Sets the global ambient color for the material used in lighting calculations.
  45690. */
  45691. private _globalAmbientColor;
  45692. /**
  45693. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45694. */
  45695. private _useLogarithmicDepth;
  45696. /**
  45697. * If set to true, no lighting calculations will be applied.
  45698. */
  45699. private _unlit;
  45700. private _debugMode;
  45701. /**
  45702. * @hidden
  45703. * This is reserved for the inspector.
  45704. * Defines the material debug mode.
  45705. * It helps seeing only some components of the material while troubleshooting.
  45706. */
  45707. debugMode: number;
  45708. /**
  45709. * @hidden
  45710. * This is reserved for the inspector.
  45711. * Specify from where on screen the debug mode should start.
  45712. * The value goes from -1 (full screen) to 1 (not visible)
  45713. * It helps with side by side comparison against the final render
  45714. * This defaults to -1
  45715. */
  45716. private debugLimit;
  45717. /**
  45718. * @hidden
  45719. * This is reserved for the inspector.
  45720. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45721. * You can use the factor to better multiply the final value.
  45722. */
  45723. private debugFactor;
  45724. /**
  45725. * Defines the clear coat layer parameters for the material.
  45726. */
  45727. readonly clearCoat: PBRClearCoatConfiguration;
  45728. /**
  45729. * Defines the anisotropic parameters for the material.
  45730. */
  45731. readonly anisotropy: PBRAnisotropicConfiguration;
  45732. /**
  45733. * Defines the BRDF parameters for the material.
  45734. */
  45735. readonly brdf: PBRBRDFConfiguration;
  45736. /**
  45737. * Defines the Sheen parameters for the material.
  45738. */
  45739. readonly sheen: PBRSheenConfiguration;
  45740. /**
  45741. * Instantiates a new PBRMaterial instance.
  45742. *
  45743. * @param name The material name
  45744. * @param scene The scene the material will be use in.
  45745. */
  45746. constructor(name: string, scene: Scene);
  45747. /**
  45748. * Gets a boolean indicating that current material needs to register RTT
  45749. */
  45750. readonly hasRenderTargetTextures: boolean;
  45751. /**
  45752. * Gets the name of the material class.
  45753. */
  45754. getClassName(): string;
  45755. /**
  45756. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45757. */
  45758. /**
  45759. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45760. */
  45761. useLogarithmicDepth: boolean;
  45762. /**
  45763. * Gets the current transparency mode.
  45764. */
  45765. /**
  45766. * Sets the transparency mode of the material.
  45767. *
  45768. * | Value | Type | Description |
  45769. * | ----- | ----------------------------------- | ----------- |
  45770. * | 0 | OPAQUE | |
  45771. * | 1 | ALPHATEST | |
  45772. * | 2 | ALPHABLEND | |
  45773. * | 3 | ALPHATESTANDBLEND | |
  45774. *
  45775. */
  45776. transparencyMode: Nullable<number>;
  45777. /**
  45778. * Returns true if alpha blending should be disabled.
  45779. */
  45780. private readonly _disableAlphaBlending;
  45781. /**
  45782. * Specifies whether or not this material should be rendered in alpha blend mode.
  45783. */
  45784. needAlphaBlending(): boolean;
  45785. /**
  45786. * Specifies if the mesh will require alpha blending.
  45787. * @param mesh - BJS mesh.
  45788. */
  45789. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45790. /**
  45791. * Specifies whether or not this material should be rendered in alpha test mode.
  45792. */
  45793. needAlphaTesting(): boolean;
  45794. /**
  45795. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45796. */
  45797. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45798. /**
  45799. * Gets the texture used for the alpha test.
  45800. */
  45801. getAlphaTestTexture(): BaseTexture;
  45802. /**
  45803. * Specifies that the submesh is ready to be used.
  45804. * @param mesh - BJS mesh.
  45805. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45806. * @param useInstances - Specifies that instances should be used.
  45807. * @returns - boolean indicating that the submesh is ready or not.
  45808. */
  45809. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45810. /**
  45811. * Specifies if the material uses metallic roughness workflow.
  45812. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45813. */
  45814. isMetallicWorkflow(): boolean;
  45815. private _prepareEffect;
  45816. private _prepareDefines;
  45817. /**
  45818. * Force shader compilation
  45819. */
  45820. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45821. clipPlane: boolean;
  45822. }>): void;
  45823. /**
  45824. * Initializes the uniform buffer layout for the shader.
  45825. */
  45826. buildUniformLayout(): void;
  45827. /**
  45828. * Unbinds the textures.
  45829. */
  45830. unbind(): void;
  45831. /**
  45832. * Binds the submesh data.
  45833. * @param world - The world matrix.
  45834. * @param mesh - The BJS mesh.
  45835. * @param subMesh - A submesh of the BJS mesh.
  45836. */
  45837. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45838. /**
  45839. * Returns the animatable textures.
  45840. * @returns - Array of animatable textures.
  45841. */
  45842. getAnimatables(): IAnimatable[];
  45843. /**
  45844. * Returns the texture used for reflections.
  45845. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45846. */
  45847. private _getReflectionTexture;
  45848. /**
  45849. * Returns the texture used for refraction or null if none is used.
  45850. * @returns - Refection texture if present. If no refraction texture and refraction
  45851. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45852. */
  45853. private _getRefractionTexture;
  45854. /**
  45855. * Returns an array of the actively used textures.
  45856. * @returns - Array of BaseTextures
  45857. */
  45858. getActiveTextures(): BaseTexture[];
  45859. /**
  45860. * Checks to see if a texture is used in the material.
  45861. * @param texture - Base texture to use.
  45862. * @returns - Boolean specifying if a texture is used in the material.
  45863. */
  45864. hasTexture(texture: BaseTexture): boolean;
  45865. /**
  45866. * Disposes the resources of the material.
  45867. * @param forceDisposeEffect - Forces the disposal of effects.
  45868. * @param forceDisposeTextures - Forces the disposal of all textures.
  45869. */
  45870. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45871. }
  45872. }
  45873. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  45874. import { Nullable } from "babylonjs/types";
  45875. import { Scene } from "babylonjs/scene";
  45876. import { Color3 } from "babylonjs/Maths/math";
  45877. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45878. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45879. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45880. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  45881. /**
  45882. * The Physically based material of BJS.
  45883. *
  45884. * This offers the main features of a standard PBR material.
  45885. * For more information, please refer to the documentation :
  45886. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45887. */
  45888. export class PBRMaterial extends PBRBaseMaterial {
  45889. /**
  45890. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45891. */
  45892. static readonly PBRMATERIAL_OPAQUE: number;
  45893. /**
  45894. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45895. */
  45896. static readonly PBRMATERIAL_ALPHATEST: number;
  45897. /**
  45898. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45899. */
  45900. static readonly PBRMATERIAL_ALPHABLEND: number;
  45901. /**
  45902. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45903. * They are also discarded below the alpha cutoff threshold to improve performances.
  45904. */
  45905. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45906. /**
  45907. * Defines the default value of how much AO map is occluding the analytical lights
  45908. * (point spot...).
  45909. */
  45910. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45911. /**
  45912. * Intensity of the direct lights e.g. the four lights available in your scene.
  45913. * This impacts both the direct diffuse and specular highlights.
  45914. */
  45915. directIntensity: number;
  45916. /**
  45917. * Intensity of the emissive part of the material.
  45918. * This helps controlling the emissive effect without modifying the emissive color.
  45919. */
  45920. emissiveIntensity: number;
  45921. /**
  45922. * Intensity of the environment e.g. how much the environment will light the object
  45923. * either through harmonics for rough material or through the refelction for shiny ones.
  45924. */
  45925. environmentIntensity: number;
  45926. /**
  45927. * This is a special control allowing the reduction of the specular highlights coming from the
  45928. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45929. */
  45930. specularIntensity: number;
  45931. /**
  45932. * Debug Control allowing disabling the bump map on this material.
  45933. */
  45934. disableBumpMap: boolean;
  45935. /**
  45936. * AKA Diffuse Texture in standard nomenclature.
  45937. */
  45938. albedoTexture: BaseTexture;
  45939. /**
  45940. * AKA Occlusion Texture in other nomenclature.
  45941. */
  45942. ambientTexture: BaseTexture;
  45943. /**
  45944. * AKA Occlusion Texture Intensity in other nomenclature.
  45945. */
  45946. ambientTextureStrength: number;
  45947. /**
  45948. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45949. * 1 means it completely occludes it
  45950. * 0 mean it has no impact
  45951. */
  45952. ambientTextureImpactOnAnalyticalLights: number;
  45953. /**
  45954. * Stores the alpha values in a texture.
  45955. */
  45956. opacityTexture: BaseTexture;
  45957. /**
  45958. * Stores the reflection values in a texture.
  45959. */
  45960. reflectionTexture: Nullable<BaseTexture>;
  45961. /**
  45962. * Stores the emissive values in a texture.
  45963. */
  45964. emissiveTexture: BaseTexture;
  45965. /**
  45966. * AKA Specular texture in other nomenclature.
  45967. */
  45968. reflectivityTexture: BaseTexture;
  45969. /**
  45970. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45971. */
  45972. metallicTexture: BaseTexture;
  45973. /**
  45974. * Specifies the metallic scalar of the metallic/roughness workflow.
  45975. * Can also be used to scale the metalness values of the metallic texture.
  45976. */
  45977. metallic: Nullable<number>;
  45978. /**
  45979. * Specifies the roughness scalar of the metallic/roughness workflow.
  45980. * Can also be used to scale the roughness values of the metallic texture.
  45981. */
  45982. roughness: Nullable<number>;
  45983. /**
  45984. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45985. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45986. */
  45987. microSurfaceTexture: BaseTexture;
  45988. /**
  45989. * Stores surface normal data used to displace a mesh in a texture.
  45990. */
  45991. bumpTexture: BaseTexture;
  45992. /**
  45993. * Stores the pre-calculated light information of a mesh in a texture.
  45994. */
  45995. lightmapTexture: BaseTexture;
  45996. /**
  45997. * Stores the refracted light information in a texture.
  45998. */
  45999. refractionTexture: BaseTexture;
  46000. /**
  46001. * The color of a material in ambient lighting.
  46002. */
  46003. ambientColor: Color3;
  46004. /**
  46005. * AKA Diffuse Color in other nomenclature.
  46006. */
  46007. albedoColor: Color3;
  46008. /**
  46009. * AKA Specular Color in other nomenclature.
  46010. */
  46011. reflectivityColor: Color3;
  46012. /**
  46013. * The color reflected from the material.
  46014. */
  46015. reflectionColor: Color3;
  46016. /**
  46017. * The color emitted from the material.
  46018. */
  46019. emissiveColor: Color3;
  46020. /**
  46021. * AKA Glossiness in other nomenclature.
  46022. */
  46023. microSurface: number;
  46024. /**
  46025. * source material index of refraction (IOR)' / 'destination material IOR.
  46026. */
  46027. indexOfRefraction: number;
  46028. /**
  46029. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46030. */
  46031. invertRefractionY: boolean;
  46032. /**
  46033. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46034. * Materials half opaque for instance using refraction could benefit from this control.
  46035. */
  46036. linkRefractionWithTransparency: boolean;
  46037. /**
  46038. * If true, the light map contains occlusion information instead of lighting info.
  46039. */
  46040. useLightmapAsShadowmap: boolean;
  46041. /**
  46042. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46043. */
  46044. useAlphaFromAlbedoTexture: boolean;
  46045. /**
  46046. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46047. */
  46048. forceAlphaTest: boolean;
  46049. /**
  46050. * Defines the alpha limits in alpha test mode.
  46051. */
  46052. alphaCutOff: number;
  46053. /**
  46054. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46055. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46056. */
  46057. useSpecularOverAlpha: boolean;
  46058. /**
  46059. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46060. */
  46061. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46062. /**
  46063. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46064. */
  46065. useRoughnessFromMetallicTextureAlpha: boolean;
  46066. /**
  46067. * Specifies if the metallic texture contains the roughness information in its green channel.
  46068. */
  46069. useRoughnessFromMetallicTextureGreen: boolean;
  46070. /**
  46071. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46072. */
  46073. useMetallnessFromMetallicTextureBlue: boolean;
  46074. /**
  46075. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46076. */
  46077. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46078. /**
  46079. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46080. */
  46081. useAmbientInGrayScale: boolean;
  46082. /**
  46083. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46084. * The material will try to infer what glossiness each pixel should be.
  46085. */
  46086. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46087. /**
  46088. * BJS is using an harcoded light falloff based on a manually sets up range.
  46089. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46090. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46091. */
  46092. /**
  46093. * BJS is using an harcoded light falloff based on a manually sets up range.
  46094. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46095. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46096. */
  46097. usePhysicalLightFalloff: boolean;
  46098. /**
  46099. * In order to support the falloff compatibility with gltf, a special mode has been added
  46100. * to reproduce the gltf light falloff.
  46101. */
  46102. /**
  46103. * In order to support the falloff compatibility with gltf, a special mode has been added
  46104. * to reproduce the gltf light falloff.
  46105. */
  46106. useGLTFLightFalloff: boolean;
  46107. /**
  46108. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46109. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46110. */
  46111. useRadianceOverAlpha: boolean;
  46112. /**
  46113. * Allows using an object space normal map (instead of tangent space).
  46114. */
  46115. useObjectSpaceNormalMap: boolean;
  46116. /**
  46117. * Allows using the bump map in parallax mode.
  46118. */
  46119. useParallax: boolean;
  46120. /**
  46121. * Allows using the bump map in parallax occlusion mode.
  46122. */
  46123. useParallaxOcclusion: boolean;
  46124. /**
  46125. * Controls the scale bias of the parallax mode.
  46126. */
  46127. parallaxScaleBias: number;
  46128. /**
  46129. * If sets to true, disables all the lights affecting the material.
  46130. */
  46131. disableLighting: boolean;
  46132. /**
  46133. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46134. */
  46135. forceIrradianceInFragment: boolean;
  46136. /**
  46137. * Number of Simultaneous lights allowed on the material.
  46138. */
  46139. maxSimultaneousLights: number;
  46140. /**
  46141. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46142. */
  46143. invertNormalMapX: boolean;
  46144. /**
  46145. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46146. */
  46147. invertNormalMapY: boolean;
  46148. /**
  46149. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46150. */
  46151. twoSidedLighting: boolean;
  46152. /**
  46153. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46154. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46155. */
  46156. useAlphaFresnel: boolean;
  46157. /**
  46158. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46159. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46160. */
  46161. useLinearAlphaFresnel: boolean;
  46162. /**
  46163. * Let user defines the brdf lookup texture used for IBL.
  46164. * A default 8bit version is embedded but you could point at :
  46165. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  46166. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46167. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46168. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46169. */
  46170. environmentBRDFTexture: Nullable<BaseTexture>;
  46171. /**
  46172. * Force normal to face away from face.
  46173. */
  46174. forceNormalForward: boolean;
  46175. /**
  46176. * Enables specular anti aliasing in the PBR shader.
  46177. * It will both interacts on the Geometry for analytical and IBL lighting.
  46178. * It also prefilter the roughness map based on the bump values.
  46179. */
  46180. enableSpecularAntiAliasing: boolean;
  46181. /**
  46182. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46183. * makes the reflect vector face the model (under horizon).
  46184. */
  46185. useHorizonOcclusion: boolean;
  46186. /**
  46187. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46188. * too much the area relying on ambient texture to define their ambient occlusion.
  46189. */
  46190. useRadianceOcclusion: boolean;
  46191. /**
  46192. * If set to true, no lighting calculations will be applied.
  46193. */
  46194. unlit: boolean;
  46195. /**
  46196. * Gets the image processing configuration used either in this material.
  46197. */
  46198. /**
  46199. * Sets the Default image processing configuration used either in the this material.
  46200. *
  46201. * If sets to null, the scene one is in use.
  46202. */
  46203. imageProcessingConfiguration: ImageProcessingConfiguration;
  46204. /**
  46205. * Gets wether the color curves effect is enabled.
  46206. */
  46207. /**
  46208. * Sets wether the color curves effect is enabled.
  46209. */
  46210. cameraColorCurvesEnabled: boolean;
  46211. /**
  46212. * Gets wether the color grading effect is enabled.
  46213. */
  46214. /**
  46215. * Gets wether the color grading effect is enabled.
  46216. */
  46217. cameraColorGradingEnabled: boolean;
  46218. /**
  46219. * Gets wether tonemapping is enabled or not.
  46220. */
  46221. /**
  46222. * Sets wether tonemapping is enabled or not
  46223. */
  46224. cameraToneMappingEnabled: boolean;
  46225. /**
  46226. * The camera exposure used on this material.
  46227. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46228. * This corresponds to a photographic exposure.
  46229. */
  46230. /**
  46231. * The camera exposure used on this material.
  46232. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46233. * This corresponds to a photographic exposure.
  46234. */
  46235. cameraExposure: number;
  46236. /**
  46237. * Gets The camera contrast used on this material.
  46238. */
  46239. /**
  46240. * Sets The camera contrast used on this material.
  46241. */
  46242. cameraContrast: number;
  46243. /**
  46244. * Gets the Color Grading 2D Lookup Texture.
  46245. */
  46246. /**
  46247. * Sets the Color Grading 2D Lookup Texture.
  46248. */
  46249. cameraColorGradingTexture: Nullable<BaseTexture>;
  46250. /**
  46251. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46252. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46253. * 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;
  46254. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46255. */
  46256. /**
  46257. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46258. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46259. * 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;
  46260. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46261. */
  46262. cameraColorCurves: Nullable<ColorCurves>;
  46263. /**
  46264. * Instantiates a new PBRMaterial instance.
  46265. *
  46266. * @param name The material name
  46267. * @param scene The scene the material will be use in.
  46268. */
  46269. constructor(name: string, scene: Scene);
  46270. /**
  46271. * Returns the name of this material class.
  46272. */
  46273. getClassName(): string;
  46274. /**
  46275. * Makes a duplicate of the current material.
  46276. * @param name - name to use for the new material.
  46277. */
  46278. clone(name: string): PBRMaterial;
  46279. /**
  46280. * Serializes this PBR Material.
  46281. * @returns - An object with the serialized material.
  46282. */
  46283. serialize(): any;
  46284. /**
  46285. * Parses a PBR Material from a serialized object.
  46286. * @param source - Serialized object.
  46287. * @param scene - BJS scene instance.
  46288. * @param rootUrl - url for the scene object
  46289. * @returns - PBRMaterial
  46290. */
  46291. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46292. }
  46293. }
  46294. declare module "babylonjs/Misc/dds" {
  46295. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46296. import { Engine } from "babylonjs/Engines/engine";
  46297. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46298. import { Nullable } from "babylonjs/types";
  46299. import { Scene } from "babylonjs/scene";
  46300. /**
  46301. * Direct draw surface info
  46302. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46303. */
  46304. export interface DDSInfo {
  46305. /**
  46306. * Width of the texture
  46307. */
  46308. width: number;
  46309. /**
  46310. * Width of the texture
  46311. */
  46312. height: number;
  46313. /**
  46314. * Number of Mipmaps for the texture
  46315. * @see https://en.wikipedia.org/wiki/Mipmap
  46316. */
  46317. mipmapCount: number;
  46318. /**
  46319. * If the textures format is a known fourCC format
  46320. * @see https://www.fourcc.org/
  46321. */
  46322. isFourCC: boolean;
  46323. /**
  46324. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46325. */
  46326. isRGB: boolean;
  46327. /**
  46328. * If the texture is a lumincance format
  46329. */
  46330. isLuminance: boolean;
  46331. /**
  46332. * If this is a cube texture
  46333. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46334. */
  46335. isCube: boolean;
  46336. /**
  46337. * If the texture is a compressed format eg. FOURCC_DXT1
  46338. */
  46339. isCompressed: boolean;
  46340. /**
  46341. * The dxgiFormat of the texture
  46342. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46343. */
  46344. dxgiFormat: number;
  46345. /**
  46346. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46347. */
  46348. textureType: number;
  46349. /**
  46350. * Sphericle polynomial created for the dds texture
  46351. */
  46352. sphericalPolynomial?: SphericalPolynomial;
  46353. }
  46354. /**
  46355. * Class used to provide DDS decompression tools
  46356. */
  46357. export class DDSTools {
  46358. /**
  46359. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46360. */
  46361. static StoreLODInAlphaChannel: boolean;
  46362. /**
  46363. * Gets DDS information from an array buffer
  46364. * @param arrayBuffer defines the array buffer to read data from
  46365. * @returns the DDS information
  46366. */
  46367. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46368. private static _FloatView;
  46369. private static _Int32View;
  46370. private static _ToHalfFloat;
  46371. private static _FromHalfFloat;
  46372. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46373. private static _GetHalfFloatRGBAArrayBuffer;
  46374. private static _GetFloatRGBAArrayBuffer;
  46375. private static _GetFloatAsUIntRGBAArrayBuffer;
  46376. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46377. private static _GetRGBAArrayBuffer;
  46378. private static _ExtractLongWordOrder;
  46379. private static _GetRGBArrayBuffer;
  46380. private static _GetLuminanceArrayBuffer;
  46381. /**
  46382. * Uploads DDS Levels to a Babylon Texture
  46383. * @hidden
  46384. */
  46385. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46386. }
  46387. module "babylonjs/Engines/engine" {
  46388. interface Engine {
  46389. /**
  46390. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46391. * @param rootUrl defines the url where the file to load is located
  46392. * @param scene defines the current scene
  46393. * @param lodScale defines scale to apply to the mip map selection
  46394. * @param lodOffset defines offset to apply to the mip map selection
  46395. * @param onLoad defines an optional callback raised when the texture is loaded
  46396. * @param onError defines an optional callback raised if there is an issue to load the texture
  46397. * @param format defines the format of the data
  46398. * @param forcedExtension defines the extension to use to pick the right loader
  46399. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46400. * @returns the cube texture as an InternalTexture
  46401. */
  46402. 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;
  46403. }
  46404. }
  46405. }
  46406. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  46407. import { Nullable } from "babylonjs/types";
  46408. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46409. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46410. /**
  46411. * Implementation of the DDS Texture Loader.
  46412. * @hidden
  46413. */
  46414. export class _DDSTextureLoader implements IInternalTextureLoader {
  46415. /**
  46416. * Defines wether the loader supports cascade loading the different faces.
  46417. */
  46418. readonly supportCascades: boolean;
  46419. /**
  46420. * This returns if the loader support the current file information.
  46421. * @param extension defines the file extension of the file being loaded
  46422. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46423. * @param fallback defines the fallback internal texture if any
  46424. * @param isBase64 defines whether the texture is encoded as a base64
  46425. * @param isBuffer defines whether the texture data are stored as a buffer
  46426. * @returns true if the loader can load the specified file
  46427. */
  46428. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46429. /**
  46430. * Transform the url before loading if required.
  46431. * @param rootUrl the url of the texture
  46432. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46433. * @returns the transformed texture
  46434. */
  46435. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46436. /**
  46437. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46438. * @param rootUrl the url of the texture
  46439. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46440. * @returns the fallback texture
  46441. */
  46442. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46443. /**
  46444. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46445. * @param data contains the texture data
  46446. * @param texture defines the BabylonJS internal texture
  46447. * @param createPolynomials will be true if polynomials have been requested
  46448. * @param onLoad defines the callback to trigger once the texture is ready
  46449. * @param onError defines the callback to trigger in case of error
  46450. */
  46451. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46452. /**
  46453. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46454. * @param data contains the texture data
  46455. * @param texture defines the BabylonJS internal texture
  46456. * @param callback defines the method to call once ready to upload
  46457. */
  46458. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46459. }
  46460. }
  46461. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46462. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46463. /** @hidden */
  46464. export var rgbdEncodePixelShader: {
  46465. name: string;
  46466. shader: string;
  46467. };
  46468. }
  46469. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46470. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46471. /** @hidden */
  46472. export var rgbdDecodePixelShader: {
  46473. name: string;
  46474. shader: string;
  46475. };
  46476. }
  46477. declare module "babylonjs/Misc/environmentTextureTools" {
  46478. import { Nullable } from "babylonjs/types";
  46479. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46480. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46481. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46482. import "babylonjs/Shaders/rgbdEncode.fragment";
  46483. import "babylonjs/Shaders/rgbdDecode.fragment";
  46484. /**
  46485. * Raw texture data and descriptor sufficient for WebGL texture upload
  46486. */
  46487. export interface EnvironmentTextureInfo {
  46488. /**
  46489. * Version of the environment map
  46490. */
  46491. version: number;
  46492. /**
  46493. * Width of image
  46494. */
  46495. width: number;
  46496. /**
  46497. * Irradiance information stored in the file.
  46498. */
  46499. irradiance: any;
  46500. /**
  46501. * Specular information stored in the file.
  46502. */
  46503. specular: any;
  46504. }
  46505. /**
  46506. * Sets of helpers addressing the serialization and deserialization of environment texture
  46507. * stored in a BabylonJS env file.
  46508. * Those files are usually stored as .env files.
  46509. */
  46510. export class EnvironmentTextureTools {
  46511. /**
  46512. * Magic number identifying the env file.
  46513. */
  46514. private static _MagicBytes;
  46515. /**
  46516. * Gets the environment info from an env file.
  46517. * @param data The array buffer containing the .env bytes.
  46518. * @returns the environment file info (the json header) if successfully parsed.
  46519. */
  46520. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46521. /**
  46522. * Creates an environment texture from a loaded cube texture.
  46523. * @param texture defines the cube texture to convert in env file
  46524. * @return a promise containing the environment data if succesfull.
  46525. */
  46526. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46527. /**
  46528. * Creates a JSON representation of the spherical data.
  46529. * @param texture defines the texture containing the polynomials
  46530. * @return the JSON representation of the spherical info
  46531. */
  46532. private static _CreateEnvTextureIrradiance;
  46533. /**
  46534. * Uploads the texture info contained in the env file to the GPU.
  46535. * @param texture defines the internal texture to upload to
  46536. * @param arrayBuffer defines the buffer cotaining the data to load
  46537. * @param info defines the texture info retrieved through the GetEnvInfo method
  46538. * @returns a promise
  46539. */
  46540. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46541. /**
  46542. * Uploads the levels of image data to the GPU.
  46543. * @param texture defines the internal texture to upload to
  46544. * @param imageData defines the array buffer views of image data [mipmap][face]
  46545. * @returns a promise
  46546. */
  46547. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46548. /**
  46549. * Uploads spherical polynomials information to the texture.
  46550. * @param texture defines the texture we are trying to upload the information to
  46551. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46552. */
  46553. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46554. /** @hidden */
  46555. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46556. }
  46557. }
  46558. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  46559. import { Nullable } from "babylonjs/types";
  46560. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46561. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46562. /**
  46563. * Implementation of the ENV Texture Loader.
  46564. * @hidden
  46565. */
  46566. export class _ENVTextureLoader implements IInternalTextureLoader {
  46567. /**
  46568. * Defines wether the loader supports cascade loading the different faces.
  46569. */
  46570. readonly supportCascades: boolean;
  46571. /**
  46572. * This returns if the loader support the current file information.
  46573. * @param extension defines the file extension of the file being loaded
  46574. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46575. * @param fallback defines the fallback internal texture if any
  46576. * @param isBase64 defines whether the texture is encoded as a base64
  46577. * @param isBuffer defines whether the texture data are stored as a buffer
  46578. * @returns true if the loader can load the specified file
  46579. */
  46580. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46581. /**
  46582. * Transform the url before loading if required.
  46583. * @param rootUrl the url of the texture
  46584. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46585. * @returns the transformed texture
  46586. */
  46587. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46588. /**
  46589. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46590. * @param rootUrl the url of the texture
  46591. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46592. * @returns the fallback texture
  46593. */
  46594. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46595. /**
  46596. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46597. * @param data contains the texture data
  46598. * @param texture defines the BabylonJS internal texture
  46599. * @param createPolynomials will be true if polynomials have been requested
  46600. * @param onLoad defines the callback to trigger once the texture is ready
  46601. * @param onError defines the callback to trigger in case of error
  46602. */
  46603. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46604. /**
  46605. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46606. * @param data contains the texture data
  46607. * @param texture defines the BabylonJS internal texture
  46608. * @param callback defines the method to call once ready to upload
  46609. */
  46610. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46611. }
  46612. }
  46613. declare module "babylonjs/Misc/khronosTextureContainer" {
  46614. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46615. /**
  46616. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46617. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46618. */
  46619. export class KhronosTextureContainer {
  46620. /** contents of the KTX container file */
  46621. arrayBuffer: any;
  46622. private static HEADER_LEN;
  46623. private static COMPRESSED_2D;
  46624. private static COMPRESSED_3D;
  46625. private static TEX_2D;
  46626. private static TEX_3D;
  46627. /**
  46628. * Gets the openGL type
  46629. */
  46630. glType: number;
  46631. /**
  46632. * Gets the openGL type size
  46633. */
  46634. glTypeSize: number;
  46635. /**
  46636. * Gets the openGL format
  46637. */
  46638. glFormat: number;
  46639. /**
  46640. * Gets the openGL internal format
  46641. */
  46642. glInternalFormat: number;
  46643. /**
  46644. * Gets the base internal format
  46645. */
  46646. glBaseInternalFormat: number;
  46647. /**
  46648. * Gets image width in pixel
  46649. */
  46650. pixelWidth: number;
  46651. /**
  46652. * Gets image height in pixel
  46653. */
  46654. pixelHeight: number;
  46655. /**
  46656. * Gets image depth in pixels
  46657. */
  46658. pixelDepth: number;
  46659. /**
  46660. * Gets the number of array elements
  46661. */
  46662. numberOfArrayElements: number;
  46663. /**
  46664. * Gets the number of faces
  46665. */
  46666. numberOfFaces: number;
  46667. /**
  46668. * Gets the number of mipmap levels
  46669. */
  46670. numberOfMipmapLevels: number;
  46671. /**
  46672. * Gets the bytes of key value data
  46673. */
  46674. bytesOfKeyValueData: number;
  46675. /**
  46676. * Gets the load type
  46677. */
  46678. loadType: number;
  46679. /**
  46680. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46681. */
  46682. isInvalid: boolean;
  46683. /**
  46684. * Creates a new KhronosTextureContainer
  46685. * @param arrayBuffer contents of the KTX container file
  46686. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46687. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46688. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46689. */
  46690. constructor(
  46691. /** contents of the KTX container file */
  46692. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46693. /**
  46694. * Uploads KTX content to a Babylon Texture.
  46695. * It is assumed that the texture has already been created & is currently bound
  46696. * @hidden
  46697. */
  46698. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46699. private _upload2DCompressedLevels;
  46700. }
  46701. }
  46702. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  46703. import { Nullable } from "babylonjs/types";
  46704. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46705. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  46706. /**
  46707. * Implementation of the KTX Texture Loader.
  46708. * @hidden
  46709. */
  46710. export class _KTXTextureLoader implements IInternalTextureLoader {
  46711. /**
  46712. * Defines wether the loader supports cascade loading the different faces.
  46713. */
  46714. readonly supportCascades: boolean;
  46715. /**
  46716. * This returns if the loader support the current file information.
  46717. * @param extension defines the file extension of the file being loaded
  46718. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46719. * @param fallback defines the fallback internal texture if any
  46720. * @param isBase64 defines whether the texture is encoded as a base64
  46721. * @param isBuffer defines whether the texture data are stored as a buffer
  46722. * @returns true if the loader can load the specified file
  46723. */
  46724. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46725. /**
  46726. * Transform the url before loading if required.
  46727. * @param rootUrl the url of the texture
  46728. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46729. * @returns the transformed texture
  46730. */
  46731. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46732. /**
  46733. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46734. * @param rootUrl the url of the texture
  46735. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46736. * @returns the fallback texture
  46737. */
  46738. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46739. /**
  46740. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46741. * @param data contains the texture data
  46742. * @param texture defines the BabylonJS internal texture
  46743. * @param createPolynomials will be true if polynomials have been requested
  46744. * @param onLoad defines the callback to trigger once the texture is ready
  46745. * @param onError defines the callback to trigger in case of error
  46746. */
  46747. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46748. /**
  46749. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46750. * @param data contains the texture data
  46751. * @param texture defines the BabylonJS internal texture
  46752. * @param callback defines the method to call once ready to upload
  46753. */
  46754. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46755. }
  46756. }
  46757. declare module "babylonjs/Helpers/sceneHelpers" {
  46758. import { Nullable } from "babylonjs/types";
  46759. import { Mesh } from "babylonjs/Meshes/mesh";
  46760. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46761. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  46762. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46763. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  46764. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  46765. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  46766. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  46767. import "babylonjs/Meshes/Builders/boxBuilder";
  46768. /** @hidden */
  46769. export var _forceSceneHelpersToBundle: boolean;
  46770. module "babylonjs/scene" {
  46771. interface Scene {
  46772. /**
  46773. * Creates a default light for the scene.
  46774. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46775. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46776. */
  46777. createDefaultLight(replace?: boolean): void;
  46778. /**
  46779. * Creates a default camera for the scene.
  46780. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46781. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46782. * @param replace has default false, when true replaces the active camera in the scene
  46783. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46784. */
  46785. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46786. /**
  46787. * Creates a default camera and a default light.
  46788. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46789. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46790. * @param replace has the default false, when true replaces the active camera/light in the scene
  46791. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46792. */
  46793. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46794. /**
  46795. * Creates a new sky box
  46796. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46797. * @param environmentTexture defines the texture to use as environment texture
  46798. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46799. * @param scale defines the overall scale of the skybox
  46800. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46801. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46802. * @returns a new mesh holding the sky box
  46803. */
  46804. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46805. /**
  46806. * Creates a new environment
  46807. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46808. * @param options defines the options you can use to configure the environment
  46809. * @returns the new EnvironmentHelper
  46810. */
  46811. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46812. /**
  46813. * Creates a new VREXperienceHelper
  46814. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46815. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46816. * @returns a new VREXperienceHelper
  46817. */
  46818. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46819. /**
  46820. * Creates a new XREXperienceHelper
  46821. * @see http://doc.babylonjs.com/how_to/webxr
  46822. * @returns a promise for a new XREXperienceHelper
  46823. */
  46824. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46825. }
  46826. }
  46827. }
  46828. declare module "babylonjs/Helpers/videoDome" {
  46829. import { Scene } from "babylonjs/scene";
  46830. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46831. import { Mesh } from "babylonjs/Meshes/mesh";
  46832. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  46833. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46834. import "babylonjs/Meshes/Builders/sphereBuilder";
  46835. /**
  46836. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46837. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46838. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46839. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46840. */
  46841. export class VideoDome extends TransformNode {
  46842. /**
  46843. * Define the video source as a Monoscopic panoramic 360 video.
  46844. */
  46845. static readonly MODE_MONOSCOPIC: number;
  46846. /**
  46847. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46848. */
  46849. static readonly MODE_TOPBOTTOM: number;
  46850. /**
  46851. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46852. */
  46853. static readonly MODE_SIDEBYSIDE: number;
  46854. private _useDirectMapping;
  46855. /**
  46856. * The video texture being displayed on the sphere
  46857. */
  46858. protected _videoTexture: VideoTexture;
  46859. /**
  46860. * Gets the video texture being displayed on the sphere
  46861. */
  46862. readonly videoTexture: VideoTexture;
  46863. /**
  46864. * The skybox material
  46865. */
  46866. protected _material: BackgroundMaterial;
  46867. /**
  46868. * The surface used for the skybox
  46869. */
  46870. protected _mesh: Mesh;
  46871. /**
  46872. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46873. * Also see the options.resolution property.
  46874. */
  46875. fovMultiplier: number;
  46876. private _videoMode;
  46877. /**
  46878. * Gets or set the current video mode for the video. It can be:
  46879. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46880. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46881. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46882. */
  46883. videoMode: number;
  46884. /**
  46885. * Oberserver used in Stereoscopic VR Mode.
  46886. */
  46887. private _onBeforeCameraRenderObserver;
  46888. /**
  46889. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46890. * @param name Element's name, child elements will append suffixes for their own names.
  46891. * @param urlsOrVideo defines the url(s) or the video element to use
  46892. * @param options An object containing optional or exposed sub element properties
  46893. */
  46894. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46895. resolution?: number;
  46896. clickToPlay?: boolean;
  46897. autoPlay?: boolean;
  46898. loop?: boolean;
  46899. size?: number;
  46900. poster?: string;
  46901. faceForward?: boolean;
  46902. useDirectMapping?: boolean;
  46903. }, scene: Scene);
  46904. private _changeVideoMode;
  46905. /**
  46906. * Releases resources associated with this node.
  46907. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46908. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46909. */
  46910. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46911. }
  46912. }
  46913. declare module "babylonjs/Helpers/index" {
  46914. export * from "babylonjs/Helpers/environmentHelper";
  46915. export * from "babylonjs/Helpers/photoDome";
  46916. export * from "babylonjs/Helpers/sceneHelpers";
  46917. export * from "babylonjs/Helpers/videoDome";
  46918. }
  46919. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  46920. import { PerfCounter } from "babylonjs/Misc/tools";
  46921. import { IDisposable } from "babylonjs/scene";
  46922. import { Engine } from "babylonjs/Engines/engine";
  46923. /**
  46924. * This class can be used to get instrumentation data from a Babylon engine
  46925. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46926. */
  46927. export class EngineInstrumentation implements IDisposable {
  46928. /**
  46929. * Define the instrumented engine.
  46930. */
  46931. engine: Engine;
  46932. private _captureGPUFrameTime;
  46933. private _gpuFrameTimeToken;
  46934. private _gpuFrameTime;
  46935. private _captureShaderCompilationTime;
  46936. private _shaderCompilationTime;
  46937. private _onBeginFrameObserver;
  46938. private _onEndFrameObserver;
  46939. private _onBeforeShaderCompilationObserver;
  46940. private _onAfterShaderCompilationObserver;
  46941. /**
  46942. * Gets the perf counter used for GPU frame time
  46943. */
  46944. readonly gpuFrameTimeCounter: PerfCounter;
  46945. /**
  46946. * Gets the GPU frame time capture status
  46947. */
  46948. /**
  46949. * Enable or disable the GPU frame time capture
  46950. */
  46951. captureGPUFrameTime: boolean;
  46952. /**
  46953. * Gets the perf counter used for shader compilation time
  46954. */
  46955. readonly shaderCompilationTimeCounter: PerfCounter;
  46956. /**
  46957. * Gets the shader compilation time capture status
  46958. */
  46959. /**
  46960. * Enable or disable the shader compilation time capture
  46961. */
  46962. captureShaderCompilationTime: boolean;
  46963. /**
  46964. * Instantiates a new engine instrumentation.
  46965. * This class can be used to get instrumentation data from a Babylon engine
  46966. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46967. * @param engine Defines the engine to instrument
  46968. */
  46969. constructor(
  46970. /**
  46971. * Define the instrumented engine.
  46972. */
  46973. engine: Engine);
  46974. /**
  46975. * Dispose and release associated resources.
  46976. */
  46977. dispose(): void;
  46978. }
  46979. }
  46980. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  46981. import { PerfCounter } from "babylonjs/Misc/tools";
  46982. import { Scene, IDisposable } from "babylonjs/scene";
  46983. /**
  46984. * This class can be used to get instrumentation data from a Babylon engine
  46985. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46986. */
  46987. export class SceneInstrumentation implements IDisposable {
  46988. /**
  46989. * Defines the scene to instrument
  46990. */
  46991. scene: Scene;
  46992. private _captureActiveMeshesEvaluationTime;
  46993. private _activeMeshesEvaluationTime;
  46994. private _captureRenderTargetsRenderTime;
  46995. private _renderTargetsRenderTime;
  46996. private _captureFrameTime;
  46997. private _frameTime;
  46998. private _captureRenderTime;
  46999. private _renderTime;
  47000. private _captureInterFrameTime;
  47001. private _interFrameTime;
  47002. private _captureParticlesRenderTime;
  47003. private _particlesRenderTime;
  47004. private _captureSpritesRenderTime;
  47005. private _spritesRenderTime;
  47006. private _capturePhysicsTime;
  47007. private _physicsTime;
  47008. private _captureAnimationsTime;
  47009. private _animationsTime;
  47010. private _captureCameraRenderTime;
  47011. private _cameraRenderTime;
  47012. private _onBeforeActiveMeshesEvaluationObserver;
  47013. private _onAfterActiveMeshesEvaluationObserver;
  47014. private _onBeforeRenderTargetsRenderObserver;
  47015. private _onAfterRenderTargetsRenderObserver;
  47016. private _onAfterRenderObserver;
  47017. private _onBeforeDrawPhaseObserver;
  47018. private _onAfterDrawPhaseObserver;
  47019. private _onBeforeAnimationsObserver;
  47020. private _onBeforeParticlesRenderingObserver;
  47021. private _onAfterParticlesRenderingObserver;
  47022. private _onBeforeSpritesRenderingObserver;
  47023. private _onAfterSpritesRenderingObserver;
  47024. private _onBeforePhysicsObserver;
  47025. private _onAfterPhysicsObserver;
  47026. private _onAfterAnimationsObserver;
  47027. private _onBeforeCameraRenderObserver;
  47028. private _onAfterCameraRenderObserver;
  47029. /**
  47030. * Gets the perf counter used for active meshes evaluation time
  47031. */
  47032. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47033. /**
  47034. * Gets the active meshes evaluation time capture status
  47035. */
  47036. /**
  47037. * Enable or disable the active meshes evaluation time capture
  47038. */
  47039. captureActiveMeshesEvaluationTime: boolean;
  47040. /**
  47041. * Gets the perf counter used for render targets render time
  47042. */
  47043. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47044. /**
  47045. * Gets the render targets render time capture status
  47046. */
  47047. /**
  47048. * Enable or disable the render targets render time capture
  47049. */
  47050. captureRenderTargetsRenderTime: boolean;
  47051. /**
  47052. * Gets the perf counter used for particles render time
  47053. */
  47054. readonly particlesRenderTimeCounter: PerfCounter;
  47055. /**
  47056. * Gets the particles render time capture status
  47057. */
  47058. /**
  47059. * Enable or disable the particles render time capture
  47060. */
  47061. captureParticlesRenderTime: boolean;
  47062. /**
  47063. * Gets the perf counter used for sprites render time
  47064. */
  47065. readonly spritesRenderTimeCounter: PerfCounter;
  47066. /**
  47067. * Gets the sprites render time capture status
  47068. */
  47069. /**
  47070. * Enable or disable the sprites render time capture
  47071. */
  47072. captureSpritesRenderTime: boolean;
  47073. /**
  47074. * Gets the perf counter used for physics time
  47075. */
  47076. readonly physicsTimeCounter: PerfCounter;
  47077. /**
  47078. * Gets the physics time capture status
  47079. */
  47080. /**
  47081. * Enable or disable the physics time capture
  47082. */
  47083. capturePhysicsTime: boolean;
  47084. /**
  47085. * Gets the perf counter used for animations time
  47086. */
  47087. readonly animationsTimeCounter: PerfCounter;
  47088. /**
  47089. * Gets the animations time capture status
  47090. */
  47091. /**
  47092. * Enable or disable the animations time capture
  47093. */
  47094. captureAnimationsTime: boolean;
  47095. /**
  47096. * Gets the perf counter used for frame time capture
  47097. */
  47098. readonly frameTimeCounter: PerfCounter;
  47099. /**
  47100. * Gets the frame time capture status
  47101. */
  47102. /**
  47103. * Enable or disable the frame time capture
  47104. */
  47105. captureFrameTime: boolean;
  47106. /**
  47107. * Gets the perf counter used for inter-frames time capture
  47108. */
  47109. readonly interFrameTimeCounter: PerfCounter;
  47110. /**
  47111. * Gets the inter-frames time capture status
  47112. */
  47113. /**
  47114. * Enable or disable the inter-frames time capture
  47115. */
  47116. captureInterFrameTime: boolean;
  47117. /**
  47118. * Gets the perf counter used for render time capture
  47119. */
  47120. readonly renderTimeCounter: PerfCounter;
  47121. /**
  47122. * Gets the render time capture status
  47123. */
  47124. /**
  47125. * Enable or disable the render time capture
  47126. */
  47127. captureRenderTime: boolean;
  47128. /**
  47129. * Gets the perf counter used for camera render time capture
  47130. */
  47131. readonly cameraRenderTimeCounter: PerfCounter;
  47132. /**
  47133. * Gets the camera render time capture status
  47134. */
  47135. /**
  47136. * Enable or disable the camera render time capture
  47137. */
  47138. captureCameraRenderTime: boolean;
  47139. /**
  47140. * Gets the perf counter used for draw calls
  47141. */
  47142. readonly drawCallsCounter: PerfCounter;
  47143. /**
  47144. * Gets the perf counter used for texture collisions
  47145. */
  47146. readonly textureCollisionsCounter: PerfCounter;
  47147. /**
  47148. * Instantiates a new scene instrumentation.
  47149. * This class can be used to get instrumentation data from a Babylon engine
  47150. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47151. * @param scene Defines the scene to instrument
  47152. */
  47153. constructor(
  47154. /**
  47155. * Defines the scene to instrument
  47156. */
  47157. scene: Scene);
  47158. /**
  47159. * Dispose and release associated resources.
  47160. */
  47161. dispose(): void;
  47162. }
  47163. }
  47164. declare module "babylonjs/Instrumentation/index" {
  47165. export * from "babylonjs/Instrumentation/engineInstrumentation";
  47166. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  47167. export * from "babylonjs/Instrumentation/timeToken";
  47168. }
  47169. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  47170. /** @hidden */
  47171. export var glowMapGenerationPixelShader: {
  47172. name: string;
  47173. shader: string;
  47174. };
  47175. }
  47176. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  47177. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47178. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47179. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47180. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47181. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47182. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47183. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47184. /** @hidden */
  47185. export var glowMapGenerationVertexShader: {
  47186. name: string;
  47187. shader: string;
  47188. };
  47189. }
  47190. declare module "babylonjs/Layers/effectLayer" {
  47191. import { Observable } from "babylonjs/Misc/observable";
  47192. import { Nullable } from "babylonjs/types";
  47193. import { Camera } from "babylonjs/Cameras/camera";
  47194. import { Scene } from "babylonjs/scene";
  47195. import { Color4, ISize } from "babylonjs/Maths/math";
  47196. import { Engine } from "babylonjs/Engines/engine";
  47197. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47199. import { Mesh } from "babylonjs/Meshes/mesh";
  47200. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  47201. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47202. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47203. import { Effect } from "babylonjs/Materials/effect";
  47204. import { Material } from "babylonjs/Materials/material";
  47205. import "babylonjs/Shaders/glowMapGeneration.fragment";
  47206. import "babylonjs/Shaders/glowMapGeneration.vertex";
  47207. /**
  47208. * Effect layer options. This helps customizing the behaviour
  47209. * of the effect layer.
  47210. */
  47211. export interface IEffectLayerOptions {
  47212. /**
  47213. * Multiplication factor apply to the canvas size to compute the render target size
  47214. * used to generated the objects (the smaller the faster).
  47215. */
  47216. mainTextureRatio: number;
  47217. /**
  47218. * Enforces a fixed size texture to ensure effect stability across devices.
  47219. */
  47220. mainTextureFixedSize?: number;
  47221. /**
  47222. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  47223. */
  47224. alphaBlendingMode: number;
  47225. /**
  47226. * The camera attached to the layer.
  47227. */
  47228. camera: Nullable<Camera>;
  47229. /**
  47230. * The rendering group to draw the layer in.
  47231. */
  47232. renderingGroupId: number;
  47233. }
  47234. /**
  47235. * The effect layer Helps adding post process effect blended with the main pass.
  47236. *
  47237. * This can be for instance use to generate glow or higlight effects on the scene.
  47238. *
  47239. * The effect layer class can not be used directly and is intented to inherited from to be
  47240. * customized per effects.
  47241. */
  47242. export abstract class EffectLayer {
  47243. private _vertexBuffers;
  47244. private _indexBuffer;
  47245. private _cachedDefines;
  47246. private _effectLayerMapGenerationEffect;
  47247. private _effectLayerOptions;
  47248. private _mergeEffect;
  47249. protected _scene: Scene;
  47250. protected _engine: Engine;
  47251. protected _maxSize: number;
  47252. protected _mainTextureDesiredSize: ISize;
  47253. protected _mainTexture: RenderTargetTexture;
  47254. protected _shouldRender: boolean;
  47255. protected _postProcesses: PostProcess[];
  47256. protected _textures: BaseTexture[];
  47257. protected _emissiveTextureAndColor: {
  47258. texture: Nullable<BaseTexture>;
  47259. color: Color4;
  47260. };
  47261. /**
  47262. * The name of the layer
  47263. */
  47264. name: string;
  47265. /**
  47266. * The clear color of the texture used to generate the glow map.
  47267. */
  47268. neutralColor: Color4;
  47269. /**
  47270. * Specifies wether the highlight layer is enabled or not.
  47271. */
  47272. isEnabled: boolean;
  47273. /**
  47274. * Gets the camera attached to the layer.
  47275. */
  47276. readonly camera: Nullable<Camera>;
  47277. /**
  47278. * Gets the rendering group id the layer should render in.
  47279. */
  47280. readonly renderingGroupId: number;
  47281. /**
  47282. * An event triggered when the effect layer has been disposed.
  47283. */
  47284. onDisposeObservable: Observable<EffectLayer>;
  47285. /**
  47286. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  47287. */
  47288. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  47289. /**
  47290. * An event triggered when the generated texture is being merged in the scene.
  47291. */
  47292. onBeforeComposeObservable: Observable<EffectLayer>;
  47293. /**
  47294. * An event triggered when the generated texture has been merged in the scene.
  47295. */
  47296. onAfterComposeObservable: Observable<EffectLayer>;
  47297. /**
  47298. * An event triggered when the efffect layer changes its size.
  47299. */
  47300. onSizeChangedObservable: Observable<EffectLayer>;
  47301. /** @hidden */
  47302. static _SceneComponentInitialization: (scene: Scene) => void;
  47303. /**
  47304. * Instantiates a new effect Layer and references it in the scene.
  47305. * @param name The name of the layer
  47306. * @param scene The scene to use the layer in
  47307. */
  47308. constructor(
  47309. /** The Friendly of the effect in the scene */
  47310. name: string, scene: Scene);
  47311. /**
  47312. * Get the effect name of the layer.
  47313. * @return The effect name
  47314. */
  47315. abstract getEffectName(): string;
  47316. /**
  47317. * Checks for the readiness of the element composing the layer.
  47318. * @param subMesh the mesh to check for
  47319. * @param useInstances specify wether or not to use instances to render the mesh
  47320. * @return true if ready otherwise, false
  47321. */
  47322. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47323. /**
  47324. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47325. * @returns true if the effect requires stencil during the main canvas render pass.
  47326. */
  47327. abstract needStencil(): boolean;
  47328. /**
  47329. * Create the merge effect. This is the shader use to blit the information back
  47330. * to the main canvas at the end of the scene rendering.
  47331. * @returns The effect containing the shader used to merge the effect on the main canvas
  47332. */
  47333. protected abstract _createMergeEffect(): Effect;
  47334. /**
  47335. * Creates the render target textures and post processes used in the effect layer.
  47336. */
  47337. protected abstract _createTextureAndPostProcesses(): void;
  47338. /**
  47339. * Implementation specific of rendering the generating effect on the main canvas.
  47340. * @param effect The effect used to render through
  47341. */
  47342. protected abstract _internalRender(effect: Effect): void;
  47343. /**
  47344. * Sets the required values for both the emissive texture and and the main color.
  47345. */
  47346. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47347. /**
  47348. * Free any resources and references associated to a mesh.
  47349. * Internal use
  47350. * @param mesh The mesh to free.
  47351. */
  47352. abstract _disposeMesh(mesh: Mesh): void;
  47353. /**
  47354. * Serializes this layer (Glow or Highlight for example)
  47355. * @returns a serialized layer object
  47356. */
  47357. abstract serialize?(): any;
  47358. /**
  47359. * Initializes the effect layer with the required options.
  47360. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47361. */
  47362. protected _init(options: Partial<IEffectLayerOptions>): void;
  47363. /**
  47364. * Generates the index buffer of the full screen quad blending to the main canvas.
  47365. */
  47366. private _generateIndexBuffer;
  47367. /**
  47368. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47369. */
  47370. private _genrateVertexBuffer;
  47371. /**
  47372. * Sets the main texture desired size which is the closest power of two
  47373. * of the engine canvas size.
  47374. */
  47375. private _setMainTextureSize;
  47376. /**
  47377. * Creates the main texture for the effect layer.
  47378. */
  47379. protected _createMainTexture(): void;
  47380. /**
  47381. * Adds specific effects defines.
  47382. * @param defines The defines to add specifics to.
  47383. */
  47384. protected _addCustomEffectDefines(defines: string[]): void;
  47385. /**
  47386. * Checks for the readiness of the element composing the layer.
  47387. * @param subMesh the mesh to check for
  47388. * @param useInstances specify wether or not to use instances to render the mesh
  47389. * @param emissiveTexture the associated emissive texture used to generate the glow
  47390. * @return true if ready otherwise, false
  47391. */
  47392. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47393. /**
  47394. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47395. */
  47396. render(): void;
  47397. /**
  47398. * Determine if a given mesh will be used in the current effect.
  47399. * @param mesh mesh to test
  47400. * @returns true if the mesh will be used
  47401. */
  47402. hasMesh(mesh: AbstractMesh): boolean;
  47403. /**
  47404. * Returns true if the layer contains information to display, otherwise false.
  47405. * @returns true if the glow layer should be rendered
  47406. */
  47407. shouldRender(): boolean;
  47408. /**
  47409. * Returns true if the mesh should render, otherwise false.
  47410. * @param mesh The mesh to render
  47411. * @returns true if it should render otherwise false
  47412. */
  47413. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47414. /**
  47415. * Returns true if the mesh can be rendered, otherwise false.
  47416. * @param mesh The mesh to render
  47417. * @param material The material used on the mesh
  47418. * @returns true if it can be rendered otherwise false
  47419. */
  47420. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47421. /**
  47422. * Returns true if the mesh should render, otherwise false.
  47423. * @param mesh The mesh to render
  47424. * @returns true if it should render otherwise false
  47425. */
  47426. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47427. /**
  47428. * Renders the submesh passed in parameter to the generation map.
  47429. */
  47430. protected _renderSubMesh(subMesh: SubMesh): void;
  47431. /**
  47432. * Rebuild the required buffers.
  47433. * @hidden Internal use only.
  47434. */
  47435. _rebuild(): void;
  47436. /**
  47437. * Dispose only the render target textures and post process.
  47438. */
  47439. private _disposeTextureAndPostProcesses;
  47440. /**
  47441. * Dispose the highlight layer and free resources.
  47442. */
  47443. dispose(): void;
  47444. /**
  47445. * Gets the class name of the effect layer
  47446. * @returns the string with the class name of the effect layer
  47447. */
  47448. getClassName(): string;
  47449. /**
  47450. * Creates an effect layer from parsed effect layer data
  47451. * @param parsedEffectLayer defines effect layer data
  47452. * @param scene defines the current scene
  47453. * @param rootUrl defines the root URL containing the effect layer information
  47454. * @returns a parsed effect Layer
  47455. */
  47456. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47457. }
  47458. }
  47459. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  47460. import { Scene } from "babylonjs/scene";
  47461. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47462. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47463. import { AbstractScene } from "babylonjs/abstractScene";
  47464. module "babylonjs/abstractScene" {
  47465. interface AbstractScene {
  47466. /**
  47467. * The list of effect layers (highlights/glow) added to the scene
  47468. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47469. * @see http://doc.babylonjs.com/how_to/glow_layer
  47470. */
  47471. effectLayers: Array<EffectLayer>;
  47472. /**
  47473. * Removes the given effect layer from this scene.
  47474. * @param toRemove defines the effect layer to remove
  47475. * @returns the index of the removed effect layer
  47476. */
  47477. removeEffectLayer(toRemove: EffectLayer): number;
  47478. /**
  47479. * Adds the given effect layer to this scene
  47480. * @param newEffectLayer defines the effect layer to add
  47481. */
  47482. addEffectLayer(newEffectLayer: EffectLayer): void;
  47483. }
  47484. }
  47485. /**
  47486. * Defines the layer scene component responsible to manage any effect layers
  47487. * in a given scene.
  47488. */
  47489. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47490. /**
  47491. * The component name helpfull to identify the component in the list of scene components.
  47492. */
  47493. readonly name: string;
  47494. /**
  47495. * The scene the component belongs to.
  47496. */
  47497. scene: Scene;
  47498. private _engine;
  47499. private _renderEffects;
  47500. private _needStencil;
  47501. private _previousStencilState;
  47502. /**
  47503. * Creates a new instance of the component for the given scene
  47504. * @param scene Defines the scene to register the component in
  47505. */
  47506. constructor(scene: Scene);
  47507. /**
  47508. * Registers the component in a given scene
  47509. */
  47510. register(): void;
  47511. /**
  47512. * Rebuilds the elements related to this component in case of
  47513. * context lost for instance.
  47514. */
  47515. rebuild(): void;
  47516. /**
  47517. * Serializes the component data to the specified json object
  47518. * @param serializationObject The object to serialize to
  47519. */
  47520. serialize(serializationObject: any): void;
  47521. /**
  47522. * Adds all the element from the container to the scene
  47523. * @param container the container holding the elements
  47524. */
  47525. addFromContainer(container: AbstractScene): void;
  47526. /**
  47527. * Removes all the elements in the container from the scene
  47528. * @param container contains the elements to remove
  47529. */
  47530. removeFromContainer(container: AbstractScene): void;
  47531. /**
  47532. * Disposes the component and the associated ressources.
  47533. */
  47534. dispose(): void;
  47535. private _isReadyForMesh;
  47536. private _renderMainTexture;
  47537. private _setStencil;
  47538. private _setStencilBack;
  47539. private _draw;
  47540. private _drawCamera;
  47541. private _drawRenderingGroup;
  47542. }
  47543. }
  47544. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  47545. /** @hidden */
  47546. export var glowMapMergePixelShader: {
  47547. name: string;
  47548. shader: string;
  47549. };
  47550. }
  47551. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  47552. /** @hidden */
  47553. export var glowMapMergeVertexShader: {
  47554. name: string;
  47555. shader: string;
  47556. };
  47557. }
  47558. declare module "babylonjs/Layers/glowLayer" {
  47559. import { Nullable } from "babylonjs/types";
  47560. import { Camera } from "babylonjs/Cameras/camera";
  47561. import { Scene } from "babylonjs/scene";
  47562. import { Color4 } from "babylonjs/Maths/math";
  47563. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47564. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47565. import { Mesh } from "babylonjs/Meshes/mesh";
  47566. import { Texture } from "babylonjs/Materials/Textures/texture";
  47567. import { Effect } from "babylonjs/Materials/effect";
  47568. import { Material } from "babylonjs/Materials/material";
  47569. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47570. import "babylonjs/Shaders/glowMapMerge.fragment";
  47571. import "babylonjs/Shaders/glowMapMerge.vertex";
  47572. import "babylonjs/Layers/effectLayerSceneComponent";
  47573. module "babylonjs/abstractScene" {
  47574. interface AbstractScene {
  47575. /**
  47576. * Return a the first highlight layer of the scene with a given name.
  47577. * @param name The name of the highlight layer to look for.
  47578. * @return The highlight layer if found otherwise null.
  47579. */
  47580. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47581. }
  47582. }
  47583. /**
  47584. * Glow layer options. This helps customizing the behaviour
  47585. * of the glow layer.
  47586. */
  47587. export interface IGlowLayerOptions {
  47588. /**
  47589. * Multiplication factor apply to the canvas size to compute the render target size
  47590. * used to generated the glowing objects (the smaller the faster).
  47591. */
  47592. mainTextureRatio: number;
  47593. /**
  47594. * Enforces a fixed size texture to ensure resize independant blur.
  47595. */
  47596. mainTextureFixedSize?: number;
  47597. /**
  47598. * How big is the kernel of the blur texture.
  47599. */
  47600. blurKernelSize: number;
  47601. /**
  47602. * The camera attached to the layer.
  47603. */
  47604. camera: Nullable<Camera>;
  47605. /**
  47606. * Enable MSAA by chosing the number of samples.
  47607. */
  47608. mainTextureSamples?: number;
  47609. /**
  47610. * The rendering group to draw the layer in.
  47611. */
  47612. renderingGroupId: number;
  47613. }
  47614. /**
  47615. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47616. *
  47617. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47618. * glowy meshes to your scene.
  47619. *
  47620. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47621. */
  47622. export class GlowLayer extends EffectLayer {
  47623. /**
  47624. * Effect Name of the layer.
  47625. */
  47626. static readonly EffectName: string;
  47627. /**
  47628. * The default blur kernel size used for the glow.
  47629. */
  47630. static DefaultBlurKernelSize: number;
  47631. /**
  47632. * The default texture size ratio used for the glow.
  47633. */
  47634. static DefaultTextureRatio: number;
  47635. /**
  47636. * Sets the kernel size of the blur.
  47637. */
  47638. /**
  47639. * Gets the kernel size of the blur.
  47640. */
  47641. blurKernelSize: number;
  47642. /**
  47643. * Sets the glow intensity.
  47644. */
  47645. /**
  47646. * Gets the glow intensity.
  47647. */
  47648. intensity: number;
  47649. private _options;
  47650. private _intensity;
  47651. private _horizontalBlurPostprocess1;
  47652. private _verticalBlurPostprocess1;
  47653. private _horizontalBlurPostprocess2;
  47654. private _verticalBlurPostprocess2;
  47655. private _blurTexture1;
  47656. private _blurTexture2;
  47657. private _postProcesses1;
  47658. private _postProcesses2;
  47659. private _includedOnlyMeshes;
  47660. private _excludedMeshes;
  47661. /**
  47662. * Callback used to let the user override the color selection on a per mesh basis
  47663. */
  47664. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47665. /**
  47666. * Callback used to let the user override the texture selection on a per mesh basis
  47667. */
  47668. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47669. /**
  47670. * Instantiates a new glow Layer and references it to the scene.
  47671. * @param name The name of the layer
  47672. * @param scene The scene to use the layer in
  47673. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47674. */
  47675. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47676. /**
  47677. * Get the effect name of the layer.
  47678. * @return The effect name
  47679. */
  47680. getEffectName(): string;
  47681. /**
  47682. * Create the merge effect. This is the shader use to blit the information back
  47683. * to the main canvas at the end of the scene rendering.
  47684. */
  47685. protected _createMergeEffect(): Effect;
  47686. /**
  47687. * Creates the render target textures and post processes used in the glow layer.
  47688. */
  47689. protected _createTextureAndPostProcesses(): void;
  47690. /**
  47691. * Checks for the readiness of the element composing the layer.
  47692. * @param subMesh the mesh to check for
  47693. * @param useInstances specify wether or not to use instances to render the mesh
  47694. * @param emissiveTexture the associated emissive texture used to generate the glow
  47695. * @return true if ready otherwise, false
  47696. */
  47697. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47698. /**
  47699. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47700. */
  47701. needStencil(): boolean;
  47702. /**
  47703. * Returns true if the mesh can be rendered, otherwise false.
  47704. * @param mesh The mesh to render
  47705. * @param material The material used on the mesh
  47706. * @returns true if it can be rendered otherwise false
  47707. */
  47708. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47709. /**
  47710. * Implementation specific of rendering the generating effect on the main canvas.
  47711. * @param effect The effect used to render through
  47712. */
  47713. protected _internalRender(effect: Effect): void;
  47714. /**
  47715. * Sets the required values for both the emissive texture and and the main color.
  47716. */
  47717. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47718. /**
  47719. * Returns true if the mesh should render, otherwise false.
  47720. * @param mesh The mesh to render
  47721. * @returns true if it should render otherwise false
  47722. */
  47723. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47724. /**
  47725. * Adds specific effects defines.
  47726. * @param defines The defines to add specifics to.
  47727. */
  47728. protected _addCustomEffectDefines(defines: string[]): void;
  47729. /**
  47730. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47731. * @param mesh The mesh to exclude from the glow layer
  47732. */
  47733. addExcludedMesh(mesh: Mesh): void;
  47734. /**
  47735. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47736. * @param mesh The mesh to remove
  47737. */
  47738. removeExcludedMesh(mesh: Mesh): void;
  47739. /**
  47740. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47741. * @param mesh The mesh to include in the glow layer
  47742. */
  47743. addIncludedOnlyMesh(mesh: Mesh): void;
  47744. /**
  47745. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47746. * @param mesh The mesh to remove
  47747. */
  47748. removeIncludedOnlyMesh(mesh: Mesh): void;
  47749. /**
  47750. * Determine if a given mesh will be used in the glow layer
  47751. * @param mesh The mesh to test
  47752. * @returns true if the mesh will be highlighted by the current glow layer
  47753. */
  47754. hasMesh(mesh: AbstractMesh): boolean;
  47755. /**
  47756. * Free any resources and references associated to a mesh.
  47757. * Internal use
  47758. * @param mesh The mesh to free.
  47759. * @hidden
  47760. */
  47761. _disposeMesh(mesh: Mesh): void;
  47762. /**
  47763. * Gets the class name of the effect layer
  47764. * @returns the string with the class name of the effect layer
  47765. */
  47766. getClassName(): string;
  47767. /**
  47768. * Serializes this glow layer
  47769. * @returns a serialized glow layer object
  47770. */
  47771. serialize(): any;
  47772. /**
  47773. * Creates a Glow Layer from parsed glow layer data
  47774. * @param parsedGlowLayer defines glow layer data
  47775. * @param scene defines the current scene
  47776. * @param rootUrl defines the root URL containing the glow layer information
  47777. * @returns a parsed Glow Layer
  47778. */
  47779. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47780. }
  47781. }
  47782. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  47783. /** @hidden */
  47784. export var glowBlurPostProcessPixelShader: {
  47785. name: string;
  47786. shader: string;
  47787. };
  47788. }
  47789. declare module "babylonjs/Layers/highlightLayer" {
  47790. import { Observable } from "babylonjs/Misc/observable";
  47791. import { Nullable } from "babylonjs/types";
  47792. import { Camera } from "babylonjs/Cameras/camera";
  47793. import { Scene } from "babylonjs/scene";
  47794. import { Color3, Color4 } from "babylonjs/Maths/math";
  47795. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47797. import { Mesh } from "babylonjs/Meshes/mesh";
  47798. import { Effect } from "babylonjs/Materials/effect";
  47799. import { Material } from "babylonjs/Materials/material";
  47800. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  47801. import "babylonjs/Shaders/glowMapMerge.fragment";
  47802. import "babylonjs/Shaders/glowMapMerge.vertex";
  47803. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  47804. module "babylonjs/abstractScene" {
  47805. interface AbstractScene {
  47806. /**
  47807. * Return a the first highlight layer of the scene with a given name.
  47808. * @param name The name of the highlight layer to look for.
  47809. * @return The highlight layer if found otherwise null.
  47810. */
  47811. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47812. }
  47813. }
  47814. /**
  47815. * Highlight layer options. This helps customizing the behaviour
  47816. * of the highlight layer.
  47817. */
  47818. export interface IHighlightLayerOptions {
  47819. /**
  47820. * Multiplication factor apply to the canvas size to compute the render target size
  47821. * used to generated the glowing objects (the smaller the faster).
  47822. */
  47823. mainTextureRatio: number;
  47824. /**
  47825. * Enforces a fixed size texture to ensure resize independant blur.
  47826. */
  47827. mainTextureFixedSize?: number;
  47828. /**
  47829. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47830. * of the picture to blur (the smaller the faster).
  47831. */
  47832. blurTextureSizeRatio: number;
  47833. /**
  47834. * How big in texel of the blur texture is the vertical blur.
  47835. */
  47836. blurVerticalSize: number;
  47837. /**
  47838. * How big in texel of the blur texture is the horizontal blur.
  47839. */
  47840. blurHorizontalSize: number;
  47841. /**
  47842. * Alpha blending mode used to apply the blur. Default is combine.
  47843. */
  47844. alphaBlendingMode: number;
  47845. /**
  47846. * The camera attached to the layer.
  47847. */
  47848. camera: Nullable<Camera>;
  47849. /**
  47850. * Should we display highlight as a solid stroke?
  47851. */
  47852. isStroke?: boolean;
  47853. /**
  47854. * The rendering group to draw the layer in.
  47855. */
  47856. renderingGroupId: number;
  47857. }
  47858. /**
  47859. * The highlight layer Helps adding a glow effect around a mesh.
  47860. *
  47861. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47862. * glowy meshes to your scene.
  47863. *
  47864. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47865. */
  47866. export class HighlightLayer extends EffectLayer {
  47867. name: string;
  47868. /**
  47869. * Effect Name of the highlight layer.
  47870. */
  47871. static readonly EffectName: string;
  47872. /**
  47873. * The neutral color used during the preparation of the glow effect.
  47874. * This is black by default as the blend operation is a blend operation.
  47875. */
  47876. static NeutralColor: Color4;
  47877. /**
  47878. * Stencil value used for glowing meshes.
  47879. */
  47880. static GlowingMeshStencilReference: number;
  47881. /**
  47882. * Stencil value used for the other meshes in the scene.
  47883. */
  47884. static NormalMeshStencilReference: number;
  47885. /**
  47886. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47887. */
  47888. innerGlow: boolean;
  47889. /**
  47890. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47891. */
  47892. outerGlow: boolean;
  47893. /**
  47894. * Specifies the horizontal size of the blur.
  47895. */
  47896. /**
  47897. * Gets the horizontal size of the blur.
  47898. */
  47899. blurHorizontalSize: number;
  47900. /**
  47901. * Specifies the vertical size of the blur.
  47902. */
  47903. /**
  47904. * Gets the vertical size of the blur.
  47905. */
  47906. blurVerticalSize: number;
  47907. /**
  47908. * An event triggered when the highlight layer is being blurred.
  47909. */
  47910. onBeforeBlurObservable: Observable<HighlightLayer>;
  47911. /**
  47912. * An event triggered when the highlight layer has been blurred.
  47913. */
  47914. onAfterBlurObservable: Observable<HighlightLayer>;
  47915. private _instanceGlowingMeshStencilReference;
  47916. private _options;
  47917. private _downSamplePostprocess;
  47918. private _horizontalBlurPostprocess;
  47919. private _verticalBlurPostprocess;
  47920. private _blurTexture;
  47921. private _meshes;
  47922. private _excludedMeshes;
  47923. /**
  47924. * Instantiates a new highlight Layer and references it to the scene..
  47925. * @param name The name of the layer
  47926. * @param scene The scene to use the layer in
  47927. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47928. */
  47929. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47930. /**
  47931. * Get the effect name of the layer.
  47932. * @return The effect name
  47933. */
  47934. getEffectName(): string;
  47935. /**
  47936. * Create the merge effect. This is the shader use to blit the information back
  47937. * to the main canvas at the end of the scene rendering.
  47938. */
  47939. protected _createMergeEffect(): Effect;
  47940. /**
  47941. * Creates the render target textures and post processes used in the highlight layer.
  47942. */
  47943. protected _createTextureAndPostProcesses(): void;
  47944. /**
  47945. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47946. */
  47947. needStencil(): boolean;
  47948. /**
  47949. * Checks for the readiness of the element composing the layer.
  47950. * @param subMesh the mesh to check for
  47951. * @param useInstances specify wether or not to use instances to render the mesh
  47952. * @param emissiveTexture the associated emissive texture used to generate the glow
  47953. * @return true if ready otherwise, false
  47954. */
  47955. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47956. /**
  47957. * Implementation specific of rendering the generating effect on the main canvas.
  47958. * @param effect The effect used to render through
  47959. */
  47960. protected _internalRender(effect: Effect): void;
  47961. /**
  47962. * Returns true if the layer contains information to display, otherwise false.
  47963. */
  47964. shouldRender(): boolean;
  47965. /**
  47966. * Returns true if the mesh should render, otherwise false.
  47967. * @param mesh The mesh to render
  47968. * @returns true if it should render otherwise false
  47969. */
  47970. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47971. /**
  47972. * Sets the required values for both the emissive texture and and the main color.
  47973. */
  47974. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47975. /**
  47976. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47977. * @param mesh The mesh to exclude from the highlight layer
  47978. */
  47979. addExcludedMesh(mesh: Mesh): void;
  47980. /**
  47981. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47982. * @param mesh The mesh to highlight
  47983. */
  47984. removeExcludedMesh(mesh: Mesh): void;
  47985. /**
  47986. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47987. * @param mesh mesh to test
  47988. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47989. */
  47990. hasMesh(mesh: AbstractMesh): boolean;
  47991. /**
  47992. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47993. * @param mesh The mesh to highlight
  47994. * @param color The color of the highlight
  47995. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47996. */
  47997. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47998. /**
  47999. * Remove a mesh from the highlight layer in order to make it stop glowing.
  48000. * @param mesh The mesh to highlight
  48001. */
  48002. removeMesh(mesh: Mesh): void;
  48003. /**
  48004. * Force the stencil to the normal expected value for none glowing parts
  48005. */
  48006. private _defaultStencilReference;
  48007. /**
  48008. * Free any resources and references associated to a mesh.
  48009. * Internal use
  48010. * @param mesh The mesh to free.
  48011. * @hidden
  48012. */
  48013. _disposeMesh(mesh: Mesh): void;
  48014. /**
  48015. * Dispose the highlight layer and free resources.
  48016. */
  48017. dispose(): void;
  48018. /**
  48019. * Gets the class name of the effect layer
  48020. * @returns the string with the class name of the effect layer
  48021. */
  48022. getClassName(): string;
  48023. /**
  48024. * Serializes this Highlight layer
  48025. * @returns a serialized Highlight layer object
  48026. */
  48027. serialize(): any;
  48028. /**
  48029. * Creates a Highlight layer from parsed Highlight layer data
  48030. * @param parsedHightlightLayer defines the Highlight layer data
  48031. * @param scene defines the current scene
  48032. * @param rootUrl defines the root URL containing the Highlight layer information
  48033. * @returns a parsed Highlight layer
  48034. */
  48035. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48036. }
  48037. }
  48038. declare module "babylonjs/Layers/index" {
  48039. export * from "babylonjs/Layers/effectLayer";
  48040. export * from "babylonjs/Layers/effectLayerSceneComponent";
  48041. export * from "babylonjs/Layers/glowLayer";
  48042. export * from "babylonjs/Layers/highlightLayer";
  48043. export * from "babylonjs/Layers/layer";
  48044. export * from "babylonjs/Layers/layerSceneComponent";
  48045. }
  48046. declare module "babylonjs/Shaders/lensFlare.fragment" {
  48047. /** @hidden */
  48048. export var lensFlarePixelShader: {
  48049. name: string;
  48050. shader: string;
  48051. };
  48052. }
  48053. declare module "babylonjs/Shaders/lensFlare.vertex" {
  48054. /** @hidden */
  48055. export var lensFlareVertexShader: {
  48056. name: string;
  48057. shader: string;
  48058. };
  48059. }
  48060. declare module "babylonjs/LensFlares/lensFlareSystem" {
  48061. import { Scene } from "babylonjs/scene";
  48062. import { Vector3, Viewport } from "babylonjs/Maths/math";
  48063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48064. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  48065. import "babylonjs/Shaders/lensFlare.fragment";
  48066. import "babylonjs/Shaders/lensFlare.vertex";
  48067. /**
  48068. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48069. * It is usually composed of several `lensFlare`.
  48070. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48071. */
  48072. export class LensFlareSystem {
  48073. /**
  48074. * Define the name of the lens flare system
  48075. */
  48076. name: string;
  48077. /**
  48078. * List of lens flares used in this system.
  48079. */
  48080. lensFlares: LensFlare[];
  48081. /**
  48082. * Define a limit from the border the lens flare can be visible.
  48083. */
  48084. borderLimit: number;
  48085. /**
  48086. * Define a viewport border we do not want to see the lens flare in.
  48087. */
  48088. viewportBorder: number;
  48089. /**
  48090. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48091. */
  48092. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48093. /**
  48094. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48095. */
  48096. layerMask: number;
  48097. /**
  48098. * Define the id of the lens flare system in the scene.
  48099. * (equal to name by default)
  48100. */
  48101. id: string;
  48102. private _scene;
  48103. private _emitter;
  48104. private _vertexBuffers;
  48105. private _indexBuffer;
  48106. private _effect;
  48107. private _positionX;
  48108. private _positionY;
  48109. private _isEnabled;
  48110. /** @hidden */
  48111. static _SceneComponentInitialization: (scene: Scene) => void;
  48112. /**
  48113. * Instantiates a lens flare system.
  48114. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48115. * It is usually composed of several `lensFlare`.
  48116. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48117. * @param name Define the name of the lens flare system in the scene
  48118. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48119. * @param scene Define the scene the lens flare system belongs to
  48120. */
  48121. constructor(
  48122. /**
  48123. * Define the name of the lens flare system
  48124. */
  48125. name: string, emitter: any, scene: Scene);
  48126. /**
  48127. * Define if the lens flare system is enabled.
  48128. */
  48129. isEnabled: boolean;
  48130. /**
  48131. * Get the scene the effects belongs to.
  48132. * @returns the scene holding the lens flare system
  48133. */
  48134. getScene(): Scene;
  48135. /**
  48136. * Get the emitter of the lens flare system.
  48137. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48138. * @returns the emitter of the lens flare system
  48139. */
  48140. getEmitter(): any;
  48141. /**
  48142. * Set the emitter of the lens flare system.
  48143. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48144. * @param newEmitter Define the new emitter of the system
  48145. */
  48146. setEmitter(newEmitter: any): void;
  48147. /**
  48148. * Get the lens flare system emitter position.
  48149. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48150. * @returns the position
  48151. */
  48152. getEmitterPosition(): Vector3;
  48153. /**
  48154. * @hidden
  48155. */
  48156. computeEffectivePosition(globalViewport: Viewport): boolean;
  48157. /** @hidden */
  48158. _isVisible(): boolean;
  48159. /**
  48160. * @hidden
  48161. */
  48162. render(): boolean;
  48163. /**
  48164. * Dispose and release the lens flare with its associated resources.
  48165. */
  48166. dispose(): void;
  48167. /**
  48168. * Parse a lens flare system from a JSON repressentation
  48169. * @param parsedLensFlareSystem Define the JSON to parse
  48170. * @param scene Define the scene the parsed system should be instantiated in
  48171. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  48172. * @returns the parsed system
  48173. */
  48174. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  48175. /**
  48176. * Serialize the current Lens Flare System into a JSON representation.
  48177. * @returns the serialized JSON
  48178. */
  48179. serialize(): any;
  48180. }
  48181. }
  48182. declare module "babylonjs/LensFlares/lensFlare" {
  48183. import { Nullable } from "babylonjs/types";
  48184. import { Color3 } from "babylonjs/Maths/math";
  48185. import { Texture } from "babylonjs/Materials/Textures/texture";
  48186. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  48187. /**
  48188. * This represents one of the lens effect in a `lensFlareSystem`.
  48189. * It controls one of the indiviual texture used in the effect.
  48190. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48191. */
  48192. export class LensFlare {
  48193. /**
  48194. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48195. */
  48196. size: number;
  48197. /**
  48198. * 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.
  48199. */
  48200. position: number;
  48201. /**
  48202. * Define the lens color.
  48203. */
  48204. color: Color3;
  48205. /**
  48206. * Define the lens texture.
  48207. */
  48208. texture: Nullable<Texture>;
  48209. /**
  48210. * Define the alpha mode to render this particular lens.
  48211. */
  48212. alphaMode: number;
  48213. private _system;
  48214. /**
  48215. * Creates a new Lens Flare.
  48216. * This represents one of the lens effect in a `lensFlareSystem`.
  48217. * It controls one of the indiviual texture used in the effect.
  48218. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48219. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  48220. * @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.
  48221. * @param color Define the lens color
  48222. * @param imgUrl Define the lens texture url
  48223. * @param system Define the `lensFlareSystem` this flare is part of
  48224. * @returns The newly created Lens Flare
  48225. */
  48226. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  48227. /**
  48228. * Instantiates a new Lens Flare.
  48229. * This represents one of the lens effect in a `lensFlareSystem`.
  48230. * It controls one of the indiviual texture used in the effect.
  48231. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48232. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  48233. * @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.
  48234. * @param color Define the lens color
  48235. * @param imgUrl Define the lens texture url
  48236. * @param system Define the `lensFlareSystem` this flare is part of
  48237. */
  48238. constructor(
  48239. /**
  48240. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48241. */
  48242. size: number,
  48243. /**
  48244. * 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.
  48245. */
  48246. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  48247. /**
  48248. * Dispose and release the lens flare with its associated resources.
  48249. */
  48250. dispose(): void;
  48251. }
  48252. }
  48253. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  48254. import { Nullable } from "babylonjs/types";
  48255. import { Scene } from "babylonjs/scene";
  48256. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48257. import { AbstractScene } from "babylonjs/abstractScene";
  48258. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  48259. module "babylonjs/abstractScene" {
  48260. interface AbstractScene {
  48261. /**
  48262. * The list of lens flare system added to the scene
  48263. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48264. */
  48265. lensFlareSystems: Array<LensFlareSystem>;
  48266. /**
  48267. * Removes the given lens flare system from this scene.
  48268. * @param toRemove The lens flare system to remove
  48269. * @returns The index of the removed lens flare system
  48270. */
  48271. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  48272. /**
  48273. * Adds the given lens flare system to this scene
  48274. * @param newLensFlareSystem The lens flare system to add
  48275. */
  48276. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  48277. /**
  48278. * Gets a lens flare system using its name
  48279. * @param name defines the name to look for
  48280. * @returns the lens flare system or null if not found
  48281. */
  48282. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  48283. /**
  48284. * Gets a lens flare system using its id
  48285. * @param id defines the id to look for
  48286. * @returns the lens flare system or null if not found
  48287. */
  48288. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  48289. }
  48290. }
  48291. /**
  48292. * Defines the lens flare scene component responsible to manage any lens flares
  48293. * in a given scene.
  48294. */
  48295. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  48296. /**
  48297. * The component name helpfull to identify the component in the list of scene components.
  48298. */
  48299. readonly name: string;
  48300. /**
  48301. * The scene the component belongs to.
  48302. */
  48303. scene: Scene;
  48304. /**
  48305. * Creates a new instance of the component for the given scene
  48306. * @param scene Defines the scene to register the component in
  48307. */
  48308. constructor(scene: Scene);
  48309. /**
  48310. * Registers the component in a given scene
  48311. */
  48312. register(): void;
  48313. /**
  48314. * Rebuilds the elements related to this component in case of
  48315. * context lost for instance.
  48316. */
  48317. rebuild(): void;
  48318. /**
  48319. * Adds all the element from the container to the scene
  48320. * @param container the container holding the elements
  48321. */
  48322. addFromContainer(container: AbstractScene): void;
  48323. /**
  48324. * Removes all the elements in the container from the scene
  48325. * @param container contains the elements to remove
  48326. */
  48327. removeFromContainer(container: AbstractScene): void;
  48328. /**
  48329. * Serializes the component data to the specified json object
  48330. * @param serializationObject The object to serialize to
  48331. */
  48332. serialize(serializationObject: any): void;
  48333. /**
  48334. * Disposes the component and the associated ressources.
  48335. */
  48336. dispose(): void;
  48337. private _draw;
  48338. }
  48339. }
  48340. declare module "babylonjs/LensFlares/index" {
  48341. export * from "babylonjs/LensFlares/lensFlare";
  48342. export * from "babylonjs/LensFlares/lensFlareSystem";
  48343. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  48344. }
  48345. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  48346. import { Scene } from "babylonjs/scene";
  48347. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48348. import { AbstractScene } from "babylonjs/abstractScene";
  48349. /**
  48350. * Defines the shadow generator component responsible to manage any shadow generators
  48351. * in a given scene.
  48352. */
  48353. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  48354. /**
  48355. * The component name helpfull to identify the component in the list of scene components.
  48356. */
  48357. readonly name: string;
  48358. /**
  48359. * The scene the component belongs to.
  48360. */
  48361. scene: Scene;
  48362. /**
  48363. * Creates a new instance of the component for the given scene
  48364. * @param scene Defines the scene to register the component in
  48365. */
  48366. constructor(scene: Scene);
  48367. /**
  48368. * Registers the component in a given scene
  48369. */
  48370. register(): void;
  48371. /**
  48372. * Rebuilds the elements related to this component in case of
  48373. * context lost for instance.
  48374. */
  48375. rebuild(): void;
  48376. /**
  48377. * Serializes the component data to the specified json object
  48378. * @param serializationObject The object to serialize to
  48379. */
  48380. serialize(serializationObject: any): void;
  48381. /**
  48382. * Adds all the element from the container to the scene
  48383. * @param container the container holding the elements
  48384. */
  48385. addFromContainer(container: AbstractScene): void;
  48386. /**
  48387. * Removes all the elements in the container from the scene
  48388. * @param container contains the elements to remove
  48389. */
  48390. removeFromContainer(container: AbstractScene): void;
  48391. /**
  48392. * Rebuilds the elements related to this component in case of
  48393. * context lost for instance.
  48394. */
  48395. dispose(): void;
  48396. private _gatherRenderTargets;
  48397. }
  48398. }
  48399. declare module "babylonjs/Lights/Shadows/index" {
  48400. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  48401. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  48402. }
  48403. declare module "babylonjs/Lights/directionalLight" {
  48404. import { Camera } from "babylonjs/Cameras/camera";
  48405. import { Scene } from "babylonjs/scene";
  48406. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48407. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48408. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48409. import { Effect } from "babylonjs/Materials/effect";
  48410. /**
  48411. * A directional light is defined by a direction (what a surprise!).
  48412. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48413. * 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.
  48414. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48415. */
  48416. export class DirectionalLight extends ShadowLight {
  48417. private _shadowFrustumSize;
  48418. /**
  48419. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48420. */
  48421. /**
  48422. * Specifies a fix frustum size for the shadow generation.
  48423. */
  48424. shadowFrustumSize: number;
  48425. private _shadowOrthoScale;
  48426. /**
  48427. * Gets the shadow projection scale against the optimal computed one.
  48428. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48429. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48430. */
  48431. /**
  48432. * Sets the shadow projection scale against the optimal computed one.
  48433. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48434. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48435. */
  48436. shadowOrthoScale: number;
  48437. /**
  48438. * Automatically compute the projection matrix to best fit (including all the casters)
  48439. * on each frame.
  48440. */
  48441. autoUpdateExtends: boolean;
  48442. private _orthoLeft;
  48443. private _orthoRight;
  48444. private _orthoTop;
  48445. private _orthoBottom;
  48446. /**
  48447. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48448. * The directional light is emitted from everywhere in the given direction.
  48449. * It can cast shadows.
  48450. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48451. * @param name The friendly name of the light
  48452. * @param direction The direction of the light
  48453. * @param scene The scene the light belongs to
  48454. */
  48455. constructor(name: string, direction: Vector3, scene: Scene);
  48456. /**
  48457. * Returns the string "DirectionalLight".
  48458. * @return The class name
  48459. */
  48460. getClassName(): string;
  48461. /**
  48462. * Returns the integer 1.
  48463. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48464. */
  48465. getTypeID(): number;
  48466. /**
  48467. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48468. * Returns the DirectionalLight Shadow projection matrix.
  48469. */
  48470. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48471. /**
  48472. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48473. * Returns the DirectionalLight Shadow projection matrix.
  48474. */
  48475. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48476. /**
  48477. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48478. * Returns the DirectionalLight Shadow projection matrix.
  48479. */
  48480. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48481. protected _buildUniformLayout(): void;
  48482. /**
  48483. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48484. * @param effect The effect to update
  48485. * @param lightIndex The index of the light in the effect to update
  48486. * @returns The directional light
  48487. */
  48488. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48489. /**
  48490. * Gets the minZ used for shadow according to both the scene and the light.
  48491. *
  48492. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48493. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48494. * @param activeCamera The camera we are returning the min for
  48495. * @returns the depth min z
  48496. */
  48497. getDepthMinZ(activeCamera: Camera): number;
  48498. /**
  48499. * Gets the maxZ used for shadow according to both the scene and the light.
  48500. *
  48501. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48502. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48503. * @param activeCamera The camera we are returning the max for
  48504. * @returns the depth max z
  48505. */
  48506. getDepthMaxZ(activeCamera: Camera): number;
  48507. /**
  48508. * Prepares the list of defines specific to the light type.
  48509. * @param defines the list of defines
  48510. * @param lightIndex defines the index of the light for the effect
  48511. */
  48512. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48513. }
  48514. }
  48515. declare module "babylonjs/Lights/pointLight" {
  48516. import { Scene } from "babylonjs/scene";
  48517. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48518. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48519. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48520. import { Effect } from "babylonjs/Materials/effect";
  48521. /**
  48522. * A point light is a light defined by an unique point in world space.
  48523. * The light is emitted in every direction from this point.
  48524. * A good example of a point light is a standard light bulb.
  48525. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48526. */
  48527. export class PointLight extends ShadowLight {
  48528. private _shadowAngle;
  48529. /**
  48530. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48531. * This specifies what angle the shadow will use to be created.
  48532. *
  48533. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48534. */
  48535. /**
  48536. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48537. * This specifies what angle the shadow will use to be created.
  48538. *
  48539. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48540. */
  48541. shadowAngle: number;
  48542. /**
  48543. * Gets the direction if it has been set.
  48544. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48545. */
  48546. /**
  48547. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48548. */
  48549. direction: Vector3;
  48550. /**
  48551. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48552. * A PointLight emits the light in every direction.
  48553. * It can cast shadows.
  48554. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48555. * ```javascript
  48556. * var pointLight = new PointLight("pl", camera.position, scene);
  48557. * ```
  48558. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48559. * @param name The light friendly name
  48560. * @param position The position of the point light in the scene
  48561. * @param scene The scene the lights belongs to
  48562. */
  48563. constructor(name: string, position: Vector3, scene: Scene);
  48564. /**
  48565. * Returns the string "PointLight"
  48566. * @returns the class name
  48567. */
  48568. getClassName(): string;
  48569. /**
  48570. * Returns the integer 0.
  48571. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48572. */
  48573. getTypeID(): number;
  48574. /**
  48575. * Specifies wether or not the shadowmap should be a cube texture.
  48576. * @returns true if the shadowmap needs to be a cube texture.
  48577. */
  48578. needCube(): boolean;
  48579. /**
  48580. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48581. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48582. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48583. */
  48584. getShadowDirection(faceIndex?: number): Vector3;
  48585. /**
  48586. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48587. * - fov = PI / 2
  48588. * - aspect ratio : 1.0
  48589. * - z-near and far equal to the active camera minZ and maxZ.
  48590. * Returns the PointLight.
  48591. */
  48592. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48593. protected _buildUniformLayout(): void;
  48594. /**
  48595. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48596. * @param effect The effect to update
  48597. * @param lightIndex The index of the light in the effect to update
  48598. * @returns The point light
  48599. */
  48600. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48601. /**
  48602. * Prepares the list of defines specific to the light type.
  48603. * @param defines the list of defines
  48604. * @param lightIndex defines the index of the light for the effect
  48605. */
  48606. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48607. }
  48608. }
  48609. declare module "babylonjs/Lights/spotLight" {
  48610. import { Nullable } from "babylonjs/types";
  48611. import { Scene } from "babylonjs/scene";
  48612. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48614. import { Effect } from "babylonjs/Materials/effect";
  48615. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48616. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  48617. /**
  48618. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48619. * These values define a cone of light starting from the position, emitting toward the direction.
  48620. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48621. * and the exponent defines the speed of the decay of the light with distance (reach).
  48622. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48623. */
  48624. export class SpotLight extends ShadowLight {
  48625. private _angle;
  48626. private _innerAngle;
  48627. private _cosHalfAngle;
  48628. private _lightAngleScale;
  48629. private _lightAngleOffset;
  48630. /**
  48631. * Gets the cone angle of the spot light in Radians.
  48632. */
  48633. /**
  48634. * Sets the cone angle of the spot light in Radians.
  48635. */
  48636. angle: number;
  48637. /**
  48638. * Only used in gltf falloff mode, this defines the angle where
  48639. * the directional falloff will start before cutting at angle which could be seen
  48640. * as outer angle.
  48641. */
  48642. /**
  48643. * Only used in gltf falloff mode, this defines the angle where
  48644. * the directional falloff will start before cutting at angle which could be seen
  48645. * as outer angle.
  48646. */
  48647. innerAngle: number;
  48648. private _shadowAngleScale;
  48649. /**
  48650. * Allows scaling the angle of the light for shadow generation only.
  48651. */
  48652. /**
  48653. * Allows scaling the angle of the light for shadow generation only.
  48654. */
  48655. shadowAngleScale: number;
  48656. /**
  48657. * The light decay speed with the distance from the emission spot.
  48658. */
  48659. exponent: number;
  48660. private _projectionTextureMatrix;
  48661. /**
  48662. * Allows reading the projecton texture
  48663. */
  48664. readonly projectionTextureMatrix: Matrix;
  48665. protected _projectionTextureLightNear: number;
  48666. /**
  48667. * Gets the near clip of the Spotlight for texture projection.
  48668. */
  48669. /**
  48670. * Sets the near clip of the Spotlight for texture projection.
  48671. */
  48672. projectionTextureLightNear: number;
  48673. protected _projectionTextureLightFar: number;
  48674. /**
  48675. * Gets the far clip of the Spotlight for texture projection.
  48676. */
  48677. /**
  48678. * Sets the far clip of the Spotlight for texture projection.
  48679. */
  48680. projectionTextureLightFar: number;
  48681. protected _projectionTextureUpDirection: Vector3;
  48682. /**
  48683. * Gets the Up vector of the Spotlight for texture projection.
  48684. */
  48685. /**
  48686. * Sets the Up vector of the Spotlight for texture projection.
  48687. */
  48688. projectionTextureUpDirection: Vector3;
  48689. private _projectionTexture;
  48690. /**
  48691. * Gets the projection texture of the light.
  48692. */
  48693. /**
  48694. * Sets the projection texture of the light.
  48695. */
  48696. projectionTexture: Nullable<BaseTexture>;
  48697. private _projectionTextureViewLightDirty;
  48698. private _projectionTextureProjectionLightDirty;
  48699. private _projectionTextureDirty;
  48700. private _projectionTextureViewTargetVector;
  48701. private _projectionTextureViewLightMatrix;
  48702. private _projectionTextureProjectionLightMatrix;
  48703. private _projectionTextureScalingMatrix;
  48704. /**
  48705. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48706. * It can cast shadows.
  48707. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48708. * @param name The light friendly name
  48709. * @param position The position of the spot light in the scene
  48710. * @param direction The direction of the light in the scene
  48711. * @param angle The cone angle of the light in Radians
  48712. * @param exponent The light decay speed with the distance from the emission spot
  48713. * @param scene The scene the lights belongs to
  48714. */
  48715. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48716. /**
  48717. * Returns the string "SpotLight".
  48718. * @returns the class name
  48719. */
  48720. getClassName(): string;
  48721. /**
  48722. * Returns the integer 2.
  48723. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48724. */
  48725. getTypeID(): number;
  48726. /**
  48727. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48728. */
  48729. protected _setDirection(value: Vector3): void;
  48730. /**
  48731. * Overrides the position setter to recompute the projection texture view light Matrix.
  48732. */
  48733. protected _setPosition(value: Vector3): void;
  48734. /**
  48735. * 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.
  48736. * Returns the SpotLight.
  48737. */
  48738. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48739. protected _computeProjectionTextureViewLightMatrix(): void;
  48740. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48741. /**
  48742. * Main function for light texture projection matrix computing.
  48743. */
  48744. protected _computeProjectionTextureMatrix(): void;
  48745. protected _buildUniformLayout(): void;
  48746. private _computeAngleValues;
  48747. /**
  48748. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48749. * @param effect The effect to update
  48750. * @param lightIndex The index of the light in the effect to update
  48751. * @returns The spot light
  48752. */
  48753. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48754. /**
  48755. * Disposes the light and the associated resources.
  48756. */
  48757. dispose(): void;
  48758. /**
  48759. * Prepares the list of defines specific to the light type.
  48760. * @param defines the list of defines
  48761. * @param lightIndex defines the index of the light for the effect
  48762. */
  48763. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48764. }
  48765. }
  48766. declare module "babylonjs/Lights/index" {
  48767. export * from "babylonjs/Lights/light";
  48768. export * from "babylonjs/Lights/shadowLight";
  48769. export * from "babylonjs/Lights/Shadows/index";
  48770. export * from "babylonjs/Lights/directionalLight";
  48771. export * from "babylonjs/Lights/hemisphericLight";
  48772. export * from "babylonjs/Lights/pointLight";
  48773. export * from "babylonjs/Lights/spotLight";
  48774. }
  48775. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  48776. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48777. /**
  48778. * Header information of HDR texture files.
  48779. */
  48780. export interface HDRInfo {
  48781. /**
  48782. * The height of the texture in pixels.
  48783. */
  48784. height: number;
  48785. /**
  48786. * The width of the texture in pixels.
  48787. */
  48788. width: number;
  48789. /**
  48790. * The index of the beginning of the data in the binary file.
  48791. */
  48792. dataPosition: number;
  48793. }
  48794. /**
  48795. * This groups tools to convert HDR texture to native colors array.
  48796. */
  48797. export class HDRTools {
  48798. private static Ldexp;
  48799. private static Rgbe2float;
  48800. private static readStringLine;
  48801. /**
  48802. * Reads header information from an RGBE texture stored in a native array.
  48803. * More information on this format are available here:
  48804. * https://en.wikipedia.org/wiki/RGBE_image_format
  48805. *
  48806. * @param uint8array The binary file stored in native array.
  48807. * @return The header information.
  48808. */
  48809. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48810. /**
  48811. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48812. * This RGBE texture needs to store the information as a panorama.
  48813. *
  48814. * More information on this format are available here:
  48815. * https://en.wikipedia.org/wiki/RGBE_image_format
  48816. *
  48817. * @param buffer The binary file stored in an array buffer.
  48818. * @param size The expected size of the extracted cubemap.
  48819. * @return The Cube Map information.
  48820. */
  48821. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48822. /**
  48823. * Returns the pixels data extracted from an RGBE texture.
  48824. * This pixels will be stored left to right up to down in the R G B order in one array.
  48825. *
  48826. * More information on this format are available here:
  48827. * https://en.wikipedia.org/wiki/RGBE_image_format
  48828. *
  48829. * @param uint8array The binary file stored in an array buffer.
  48830. * @param hdrInfo The header information of the file.
  48831. * @return The pixels data in RGB right to left up to down order.
  48832. */
  48833. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48834. private static RGBE_ReadPixels_RLE;
  48835. }
  48836. }
  48837. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  48838. import { Nullable } from "babylonjs/types";
  48839. import { Scene } from "babylonjs/scene";
  48840. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  48841. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48842. /**
  48843. * This represents a texture coming from an HDR input.
  48844. *
  48845. * The only supported format is currently panorama picture stored in RGBE format.
  48846. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48847. */
  48848. export class HDRCubeTexture extends BaseTexture {
  48849. private static _facesMapping;
  48850. private _generateHarmonics;
  48851. private _noMipmap;
  48852. private _textureMatrix;
  48853. private _size;
  48854. private _onLoad;
  48855. private _onError;
  48856. /**
  48857. * The texture URL.
  48858. */
  48859. url: string;
  48860. /**
  48861. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48862. */
  48863. coordinatesMode: number;
  48864. protected _isBlocking: boolean;
  48865. /**
  48866. * Sets wether or not the texture is blocking during loading.
  48867. */
  48868. /**
  48869. * Gets wether or not the texture is blocking during loading.
  48870. */
  48871. isBlocking: boolean;
  48872. protected _rotationY: number;
  48873. /**
  48874. * Sets texture matrix rotation angle around Y axis in radians.
  48875. */
  48876. /**
  48877. * Gets texture matrix rotation angle around Y axis radians.
  48878. */
  48879. rotationY: number;
  48880. /**
  48881. * Gets or sets the center of the bounding box associated with the cube texture
  48882. * It must define where the camera used to render the texture was set
  48883. */
  48884. boundingBoxPosition: Vector3;
  48885. private _boundingBoxSize;
  48886. /**
  48887. * Gets or sets the size of the bounding box associated with the cube texture
  48888. * When defined, the cubemap will switch to local mode
  48889. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48890. * @example https://www.babylonjs-playground.com/#RNASML
  48891. */
  48892. boundingBoxSize: Vector3;
  48893. /**
  48894. * Instantiates an HDRTexture from the following parameters.
  48895. *
  48896. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48897. * @param scene The scene the texture will be used in
  48898. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48899. * @param noMipmap Forces to not generate the mipmap if true
  48900. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48901. * @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)
  48902. * @param reserved Reserved flag for internal use.
  48903. */
  48904. 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>);
  48905. /**
  48906. * Get the current class name of the texture useful for serialization or dynamic coding.
  48907. * @returns "HDRCubeTexture"
  48908. */
  48909. getClassName(): string;
  48910. /**
  48911. * Occurs when the file is raw .hdr file.
  48912. */
  48913. private loadTexture;
  48914. clone(): HDRCubeTexture;
  48915. delayLoad(): void;
  48916. /**
  48917. * Get the texture reflection matrix used to rotate/transform the reflection.
  48918. * @returns the reflection matrix
  48919. */
  48920. getReflectionTextureMatrix(): Matrix;
  48921. /**
  48922. * Set the texture reflection matrix used to rotate/transform the reflection.
  48923. * @param value Define the reflection matrix to set
  48924. */
  48925. setReflectionTextureMatrix(value: Matrix): void;
  48926. /**
  48927. * Parses a JSON representation of an HDR Texture in order to create the texture
  48928. * @param parsedTexture Define the JSON representation
  48929. * @param scene Define the scene the texture should be created in
  48930. * @param rootUrl Define the root url in case we need to load relative dependencies
  48931. * @returns the newly created texture after parsing
  48932. */
  48933. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48934. serialize(): any;
  48935. }
  48936. }
  48937. declare module "babylonjs/Physics/physicsEngine" {
  48938. import { Nullable } from "babylonjs/types";
  48939. import { Vector3 } from "babylonjs/Maths/math";
  48940. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48941. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  48942. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  48943. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  48944. /**
  48945. * Class used to control physics engine
  48946. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48947. */
  48948. export class PhysicsEngine implements IPhysicsEngine {
  48949. private _physicsPlugin;
  48950. /**
  48951. * Global value used to control the smallest number supported by the simulation
  48952. */
  48953. static Epsilon: number;
  48954. private _impostors;
  48955. private _joints;
  48956. /**
  48957. * Gets the gravity vector used by the simulation
  48958. */
  48959. gravity: Vector3;
  48960. /**
  48961. * Factory used to create the default physics plugin.
  48962. * @returns The default physics plugin
  48963. */
  48964. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48965. /**
  48966. * Creates a new Physics Engine
  48967. * @param gravity defines the gravity vector used by the simulation
  48968. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48969. */
  48970. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48971. /**
  48972. * Sets the gravity vector used by the simulation
  48973. * @param gravity defines the gravity vector to use
  48974. */
  48975. setGravity(gravity: Vector3): void;
  48976. /**
  48977. * Set the time step of the physics engine.
  48978. * Default is 1/60.
  48979. * To slow it down, enter 1/600 for example.
  48980. * To speed it up, 1/30
  48981. * @param newTimeStep defines the new timestep to apply to this world.
  48982. */
  48983. setTimeStep(newTimeStep?: number): void;
  48984. /**
  48985. * Get the time step of the physics engine.
  48986. * @returns the current time step
  48987. */
  48988. getTimeStep(): number;
  48989. /**
  48990. * Release all resources
  48991. */
  48992. dispose(): void;
  48993. /**
  48994. * Gets the name of the current physics plugin
  48995. * @returns the name of the plugin
  48996. */
  48997. getPhysicsPluginName(): string;
  48998. /**
  48999. * Adding a new impostor for the impostor tracking.
  49000. * This will be done by the impostor itself.
  49001. * @param impostor the impostor to add
  49002. */
  49003. addImpostor(impostor: PhysicsImpostor): void;
  49004. /**
  49005. * Remove an impostor from the engine.
  49006. * This impostor and its mesh will not longer be updated by the physics engine.
  49007. * @param impostor the impostor to remove
  49008. */
  49009. removeImpostor(impostor: PhysicsImpostor): void;
  49010. /**
  49011. * Add a joint to the physics engine
  49012. * @param mainImpostor defines the main impostor to which the joint is added.
  49013. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49014. * @param joint defines the joint that will connect both impostors.
  49015. */
  49016. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49017. /**
  49018. * Removes a joint from the simulation
  49019. * @param mainImpostor defines the impostor used with the joint
  49020. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49021. * @param joint defines the joint to remove
  49022. */
  49023. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49024. /**
  49025. * Called by the scene. No need to call it.
  49026. * @param delta defines the timespam between frames
  49027. */
  49028. _step(delta: number): void;
  49029. /**
  49030. * Gets the current plugin used to run the simulation
  49031. * @returns current plugin
  49032. */
  49033. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49034. /**
  49035. * Gets the list of physic impostors
  49036. * @returns an array of PhysicsImpostor
  49037. */
  49038. getImpostors(): Array<PhysicsImpostor>;
  49039. /**
  49040. * Gets the impostor for a physics enabled object
  49041. * @param object defines the object impersonated by the impostor
  49042. * @returns the PhysicsImpostor or null if not found
  49043. */
  49044. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49045. /**
  49046. * Gets the impostor for a physics body object
  49047. * @param body defines physics body used by the impostor
  49048. * @returns the PhysicsImpostor or null if not found
  49049. */
  49050. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49051. /**
  49052. * Does a raycast in the physics world
  49053. * @param from when should the ray start?
  49054. * @param to when should the ray end?
  49055. * @returns PhysicsRaycastResult
  49056. */
  49057. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49058. }
  49059. }
  49060. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  49061. import { Nullable } from "babylonjs/types";
  49062. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49064. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49065. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49066. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49067. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49068. /** @hidden */
  49069. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49070. private _useDeltaForWorldStep;
  49071. world: any;
  49072. name: string;
  49073. private _physicsMaterials;
  49074. private _fixedTimeStep;
  49075. private _cannonRaycastResult;
  49076. private _raycastResult;
  49077. BJSCANNON: any;
  49078. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49079. setGravity(gravity: Vector3): void;
  49080. setTimeStep(timeStep: number): void;
  49081. getTimeStep(): number;
  49082. executeStep(delta: number): void;
  49083. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49084. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49085. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49086. private _processChildMeshes;
  49087. removePhysicsBody(impostor: PhysicsImpostor): void;
  49088. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49089. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49090. private _addMaterial;
  49091. private _checkWithEpsilon;
  49092. private _createShape;
  49093. private _createHeightmap;
  49094. private _minus90X;
  49095. private _plus90X;
  49096. private _tmpPosition;
  49097. private _tmpDeltaPosition;
  49098. private _tmpUnityRotation;
  49099. private _updatePhysicsBodyTransformation;
  49100. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49101. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49102. isSupported(): boolean;
  49103. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49104. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49105. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49106. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49107. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49108. getBodyMass(impostor: PhysicsImpostor): number;
  49109. getBodyFriction(impostor: PhysicsImpostor): number;
  49110. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49111. getBodyRestitution(impostor: PhysicsImpostor): number;
  49112. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49113. sleepBody(impostor: PhysicsImpostor): void;
  49114. wakeUpBody(impostor: PhysicsImpostor): void;
  49115. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49116. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49117. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49118. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49119. getRadius(impostor: PhysicsImpostor): number;
  49120. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49121. dispose(): void;
  49122. private _extendNamespace;
  49123. /**
  49124. * Does a raycast in the physics world
  49125. * @param from when should the ray start?
  49126. * @param to when should the ray end?
  49127. * @returns PhysicsRaycastResult
  49128. */
  49129. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49130. }
  49131. }
  49132. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  49133. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49134. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49135. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49137. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49138. import { Nullable } from "babylonjs/types";
  49139. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49140. /** @hidden */
  49141. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49142. world: any;
  49143. name: string;
  49144. BJSOIMO: any;
  49145. private _raycastResult;
  49146. constructor(iterations?: number, oimoInjection?: any);
  49147. setGravity(gravity: Vector3): void;
  49148. setTimeStep(timeStep: number): void;
  49149. getTimeStep(): number;
  49150. private _tmpImpostorsArray;
  49151. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49152. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49153. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49154. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49155. private _tmpPositionVector;
  49156. removePhysicsBody(impostor: PhysicsImpostor): void;
  49157. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49158. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49159. isSupported(): boolean;
  49160. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49161. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49162. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49163. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49164. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49165. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49166. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49167. getBodyMass(impostor: PhysicsImpostor): number;
  49168. getBodyFriction(impostor: PhysicsImpostor): number;
  49169. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49170. getBodyRestitution(impostor: PhysicsImpostor): number;
  49171. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49172. sleepBody(impostor: PhysicsImpostor): void;
  49173. wakeUpBody(impostor: PhysicsImpostor): void;
  49174. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49175. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49176. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49177. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49178. getRadius(impostor: PhysicsImpostor): number;
  49179. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49180. dispose(): void;
  49181. /**
  49182. * Does a raycast in the physics world
  49183. * @param from when should the ray start?
  49184. * @param to when should the ray end?
  49185. * @returns PhysicsRaycastResult
  49186. */
  49187. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49188. }
  49189. }
  49190. declare module "babylonjs/Probes/reflectionProbe" {
  49191. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49192. import { Vector3 } from "babylonjs/Maths/math";
  49193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49194. import { Nullable } from "babylonjs/types";
  49195. import { Scene } from "babylonjs/scene";
  49196. module "babylonjs/abstractScene" {
  49197. interface AbstractScene {
  49198. /**
  49199. * The list of reflection probes added to the scene
  49200. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49201. */
  49202. reflectionProbes: Array<ReflectionProbe>;
  49203. /**
  49204. * Removes the given reflection probe from this scene.
  49205. * @param toRemove The reflection probe to remove
  49206. * @returns The index of the removed reflection probe
  49207. */
  49208. removeReflectionProbe(toRemove: ReflectionProbe): number;
  49209. /**
  49210. * Adds the given reflection probe to this scene.
  49211. * @param newReflectionProbe The reflection probe to add
  49212. */
  49213. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  49214. }
  49215. }
  49216. /**
  49217. * Class used to generate realtime reflection / refraction cube textures
  49218. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49219. */
  49220. export class ReflectionProbe {
  49221. /** defines the name of the probe */
  49222. name: string;
  49223. private _scene;
  49224. private _renderTargetTexture;
  49225. private _projectionMatrix;
  49226. private _viewMatrix;
  49227. private _target;
  49228. private _add;
  49229. private _attachedMesh;
  49230. private _invertYAxis;
  49231. /** Gets or sets probe position (center of the cube map) */
  49232. position: Vector3;
  49233. /**
  49234. * Creates a new reflection probe
  49235. * @param name defines the name of the probe
  49236. * @param size defines the texture resolution (for each face)
  49237. * @param scene defines the hosting scene
  49238. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  49239. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  49240. */
  49241. constructor(
  49242. /** defines the name of the probe */
  49243. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  49244. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  49245. samples: number;
  49246. /** Gets or sets the refresh rate to use (on every frame by default) */
  49247. refreshRate: number;
  49248. /**
  49249. * Gets the hosting scene
  49250. * @returns a Scene
  49251. */
  49252. getScene(): Scene;
  49253. /** Gets the internal CubeTexture used to render to */
  49254. readonly cubeTexture: RenderTargetTexture;
  49255. /** Gets the list of meshes to render */
  49256. readonly renderList: Nullable<AbstractMesh[]>;
  49257. /**
  49258. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  49259. * @param mesh defines the mesh to attach to
  49260. */
  49261. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49262. /**
  49263. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  49264. * @param renderingGroupId The rendering group id corresponding to its index
  49265. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49266. */
  49267. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  49268. /**
  49269. * Clean all associated resources
  49270. */
  49271. dispose(): void;
  49272. /**
  49273. * Converts the reflection probe information to a readable string for debug purpose.
  49274. * @param fullDetails Supports for multiple levels of logging within scene loading
  49275. * @returns the human readable reflection probe info
  49276. */
  49277. toString(fullDetails?: boolean): string;
  49278. /**
  49279. * Get the class name of the relfection probe.
  49280. * @returns "ReflectionProbe"
  49281. */
  49282. getClassName(): string;
  49283. /**
  49284. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  49285. * @returns The JSON representation of the texture
  49286. */
  49287. serialize(): any;
  49288. /**
  49289. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  49290. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  49291. * @param scene Define the scene the parsed reflection probe should be instantiated in
  49292. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49293. * @returns The parsed reflection probe if successful
  49294. */
  49295. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49296. }
  49297. }
  49298. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  49299. /** @hidden */
  49300. export var _BabylonLoaderRegistered: boolean;
  49301. }
  49302. declare module "babylonjs/Loading/Plugins/index" {
  49303. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  49304. }
  49305. declare module "babylonjs/Loading/index" {
  49306. export * from "babylonjs/Loading/loadingScreen";
  49307. export * from "babylonjs/Loading/Plugins/index";
  49308. export * from "babylonjs/Loading/sceneLoader";
  49309. export * from "babylonjs/Loading/sceneLoaderFlags";
  49310. }
  49311. declare module "babylonjs/Materials/Background/index" {
  49312. export * from "babylonjs/Materials/Background/backgroundMaterial";
  49313. }
  49314. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  49315. import { Scene } from "babylonjs/scene";
  49316. import { Color3 } from "babylonjs/Maths/math";
  49317. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49318. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49319. /**
  49320. * The Physically based simple base material of BJS.
  49321. *
  49322. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49323. * It is used as the base class for both the specGloss and metalRough conventions.
  49324. */
  49325. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49326. /**
  49327. * Number of Simultaneous lights allowed on the material.
  49328. */
  49329. maxSimultaneousLights: number;
  49330. /**
  49331. * If sets to true, disables all the lights affecting the material.
  49332. */
  49333. disableLighting: boolean;
  49334. /**
  49335. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49336. */
  49337. environmentTexture: BaseTexture;
  49338. /**
  49339. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49340. */
  49341. invertNormalMapX: boolean;
  49342. /**
  49343. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49344. */
  49345. invertNormalMapY: boolean;
  49346. /**
  49347. * Normal map used in the model.
  49348. */
  49349. normalTexture: BaseTexture;
  49350. /**
  49351. * Emissivie color used to self-illuminate the model.
  49352. */
  49353. emissiveColor: Color3;
  49354. /**
  49355. * Emissivie texture used to self-illuminate the model.
  49356. */
  49357. emissiveTexture: BaseTexture;
  49358. /**
  49359. * Occlusion Channel Strenght.
  49360. */
  49361. occlusionStrength: number;
  49362. /**
  49363. * Occlusion Texture of the material (adding extra occlusion effects).
  49364. */
  49365. occlusionTexture: BaseTexture;
  49366. /**
  49367. * Defines the alpha limits in alpha test mode.
  49368. */
  49369. alphaCutOff: number;
  49370. /**
  49371. * Gets the current double sided mode.
  49372. */
  49373. /**
  49374. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49375. */
  49376. doubleSided: boolean;
  49377. /**
  49378. * Stores the pre-calculated light information of a mesh in a texture.
  49379. */
  49380. lightmapTexture: BaseTexture;
  49381. /**
  49382. * If true, the light map contains occlusion information instead of lighting info.
  49383. */
  49384. useLightmapAsShadowmap: boolean;
  49385. /**
  49386. * Instantiates a new PBRMaterial instance.
  49387. *
  49388. * @param name The material name
  49389. * @param scene The scene the material will be use in.
  49390. */
  49391. constructor(name: string, scene: Scene);
  49392. getClassName(): string;
  49393. }
  49394. }
  49395. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  49396. import { Scene } from "babylonjs/scene";
  49397. import { Color3 } from "babylonjs/Maths/math";
  49398. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49399. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49400. /**
  49401. * The PBR material of BJS following the metal roughness convention.
  49402. *
  49403. * This fits to the PBR convention in the GLTF definition:
  49404. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49405. */
  49406. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49407. /**
  49408. * The base color has two different interpretations depending on the value of metalness.
  49409. * When the material is a metal, the base color is the specific measured reflectance value
  49410. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49411. * of the material.
  49412. */
  49413. baseColor: Color3;
  49414. /**
  49415. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49416. * well as opacity information in the alpha channel.
  49417. */
  49418. baseTexture: BaseTexture;
  49419. /**
  49420. * Specifies the metallic scalar value of the material.
  49421. * Can also be used to scale the metalness values of the metallic texture.
  49422. */
  49423. metallic: number;
  49424. /**
  49425. * Specifies the roughness scalar value of the material.
  49426. * Can also be used to scale the roughness values of the metallic texture.
  49427. */
  49428. roughness: number;
  49429. /**
  49430. * Texture containing both the metallic value in the B channel and the
  49431. * roughness value in the G channel to keep better precision.
  49432. */
  49433. metallicRoughnessTexture: BaseTexture;
  49434. /**
  49435. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49436. *
  49437. * @param name The material name
  49438. * @param scene The scene the material will be use in.
  49439. */
  49440. constructor(name: string, scene: Scene);
  49441. /**
  49442. * Return the currrent class name of the material.
  49443. */
  49444. getClassName(): string;
  49445. /**
  49446. * Makes a duplicate of the current material.
  49447. * @param name - name to use for the new material.
  49448. */
  49449. clone(name: string): PBRMetallicRoughnessMaterial;
  49450. /**
  49451. * Serialize the material to a parsable JSON object.
  49452. */
  49453. serialize(): any;
  49454. /**
  49455. * Parses a JSON object correponding to the serialize function.
  49456. */
  49457. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49458. }
  49459. }
  49460. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  49461. import { Scene } from "babylonjs/scene";
  49462. import { Color3 } from "babylonjs/Maths/math";
  49463. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49464. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49465. /**
  49466. * The PBR material of BJS following the specular glossiness convention.
  49467. *
  49468. * This fits to the PBR convention in the GLTF definition:
  49469. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49470. */
  49471. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49472. /**
  49473. * Specifies the diffuse color of the material.
  49474. */
  49475. diffuseColor: Color3;
  49476. /**
  49477. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49478. * channel.
  49479. */
  49480. diffuseTexture: BaseTexture;
  49481. /**
  49482. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49483. */
  49484. specularColor: Color3;
  49485. /**
  49486. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49487. */
  49488. glossiness: number;
  49489. /**
  49490. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49491. */
  49492. specularGlossinessTexture: BaseTexture;
  49493. /**
  49494. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49495. *
  49496. * @param name The material name
  49497. * @param scene The scene the material will be use in.
  49498. */
  49499. constructor(name: string, scene: Scene);
  49500. /**
  49501. * Return the currrent class name of the material.
  49502. */
  49503. getClassName(): string;
  49504. /**
  49505. * Makes a duplicate of the current material.
  49506. * @param name - name to use for the new material.
  49507. */
  49508. clone(name: string): PBRSpecularGlossinessMaterial;
  49509. /**
  49510. * Serialize the material to a parsable JSON object.
  49511. */
  49512. serialize(): any;
  49513. /**
  49514. * Parses a JSON object correponding to the serialize function.
  49515. */
  49516. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49517. }
  49518. }
  49519. declare module "babylonjs/Materials/PBR/index" {
  49520. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49521. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  49522. export * from "babylonjs/Materials/PBR/pbrMaterial";
  49523. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  49524. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  49525. }
  49526. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  49527. import { Nullable } from "babylonjs/types";
  49528. import { Scene } from "babylonjs/scene";
  49529. import { Matrix } from "babylonjs/Maths/math";
  49530. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49531. /**
  49532. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49533. * It can help converting any input color in a desired output one. This can then be used to create effects
  49534. * from sepia, black and white to sixties or futuristic rendering...
  49535. *
  49536. * The only supported format is currently 3dl.
  49537. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49538. */
  49539. export class ColorGradingTexture extends BaseTexture {
  49540. /**
  49541. * The current texture matrix. (will always be identity in color grading texture)
  49542. */
  49543. private _textureMatrix;
  49544. /**
  49545. * The texture URL.
  49546. */
  49547. url: string;
  49548. /**
  49549. * Empty line regex stored for GC.
  49550. */
  49551. private static _noneEmptyLineRegex;
  49552. private _engine;
  49553. /**
  49554. * Instantiates a ColorGradingTexture from the following parameters.
  49555. *
  49556. * @param url The location of the color gradind data (currently only supporting 3dl)
  49557. * @param scene The scene the texture will be used in
  49558. */
  49559. constructor(url: string, scene: Scene);
  49560. /**
  49561. * Returns the texture matrix used in most of the material.
  49562. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49563. */
  49564. getTextureMatrix(): Matrix;
  49565. /**
  49566. * Occurs when the file being loaded is a .3dl LUT file.
  49567. */
  49568. private load3dlTexture;
  49569. /**
  49570. * Starts the loading process of the texture.
  49571. */
  49572. private loadTexture;
  49573. /**
  49574. * Clones the color gradind texture.
  49575. */
  49576. clone(): ColorGradingTexture;
  49577. /**
  49578. * Called during delayed load for textures.
  49579. */
  49580. delayLoad(): void;
  49581. /**
  49582. * Parses a color grading texture serialized by Babylon.
  49583. * @param parsedTexture The texture information being parsedTexture
  49584. * @param scene The scene to load the texture in
  49585. * @param rootUrl The root url of the data assets to load
  49586. * @return A color gradind texture
  49587. */
  49588. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49589. /**
  49590. * Serializes the LUT texture to json format.
  49591. */
  49592. serialize(): any;
  49593. }
  49594. }
  49595. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  49596. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49597. import { Scene } from "babylonjs/scene";
  49598. import { Nullable } from "babylonjs/types";
  49599. /**
  49600. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  49601. */
  49602. export class EquiRectangularCubeTexture extends BaseTexture {
  49603. /** The six faces of the cube. */
  49604. private static _FacesMapping;
  49605. private _noMipmap;
  49606. private _onLoad;
  49607. private _onError;
  49608. /** The size of the cubemap. */
  49609. private _size;
  49610. /** The buffer of the image. */
  49611. private _buffer;
  49612. /** The width of the input image. */
  49613. private _width;
  49614. /** The height of the input image. */
  49615. private _height;
  49616. /** The URL to the image. */
  49617. url: string;
  49618. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  49619. coordinatesMode: number;
  49620. /**
  49621. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  49622. * @param url The location of the image
  49623. * @param scene The scene the texture will be used in
  49624. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49625. * @param noMipmap Forces to not generate the mipmap if true
  49626. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  49627. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  49628. * @param onLoad — defines a callback called when texture is loaded
  49629. * @param onError — defines a callback called if there is an error
  49630. */
  49631. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  49632. /**
  49633. * Load the image data, by putting the image on a canvas and extracting its buffer.
  49634. */
  49635. private loadImage;
  49636. /**
  49637. * Convert the image buffer into a cubemap and create a CubeTexture.
  49638. */
  49639. private loadTexture;
  49640. /**
  49641. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  49642. * @param buffer The ArrayBuffer that should be converted.
  49643. * @returns The buffer as Float32Array.
  49644. */
  49645. private getFloat32ArrayFromArrayBuffer;
  49646. /**
  49647. * Get the current class name of the texture useful for serialization or dynamic coding.
  49648. * @returns "EquiRectangularCubeTexture"
  49649. */
  49650. getClassName(): string;
  49651. /**
  49652. * Create a clone of the current EquiRectangularCubeTexture and return it.
  49653. * @returns A clone of the current EquiRectangularCubeTexture.
  49654. */
  49655. clone(): EquiRectangularCubeTexture;
  49656. }
  49657. }
  49658. declare module "babylonjs/Misc/tga" {
  49659. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49660. /**
  49661. * Based on jsTGALoader - Javascript loader for TGA file
  49662. * By Vincent Thibault
  49663. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49664. */
  49665. export class TGATools {
  49666. private static _TYPE_INDEXED;
  49667. private static _TYPE_RGB;
  49668. private static _TYPE_GREY;
  49669. private static _TYPE_RLE_INDEXED;
  49670. private static _TYPE_RLE_RGB;
  49671. private static _TYPE_RLE_GREY;
  49672. private static _ORIGIN_MASK;
  49673. private static _ORIGIN_SHIFT;
  49674. private static _ORIGIN_BL;
  49675. private static _ORIGIN_BR;
  49676. private static _ORIGIN_UL;
  49677. private static _ORIGIN_UR;
  49678. /**
  49679. * Gets the header of a TGA file
  49680. * @param data defines the TGA data
  49681. * @returns the header
  49682. */
  49683. static GetTGAHeader(data: Uint8Array): any;
  49684. /**
  49685. * Uploads TGA content to a Babylon Texture
  49686. * @hidden
  49687. */
  49688. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49689. /** @hidden */
  49690. 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;
  49691. /** @hidden */
  49692. 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;
  49693. /** @hidden */
  49694. 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;
  49695. /** @hidden */
  49696. 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;
  49697. /** @hidden */
  49698. 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;
  49699. /** @hidden */
  49700. 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;
  49701. }
  49702. }
  49703. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  49704. import { Nullable } from "babylonjs/types";
  49705. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49706. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49707. /**
  49708. * Implementation of the TGA Texture Loader.
  49709. * @hidden
  49710. */
  49711. export class _TGATextureLoader implements IInternalTextureLoader {
  49712. /**
  49713. * Defines wether the loader supports cascade loading the different faces.
  49714. */
  49715. readonly supportCascades: boolean;
  49716. /**
  49717. * This returns if the loader support the current file information.
  49718. * @param extension defines the file extension of the file being loaded
  49719. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49720. * @param fallback defines the fallback internal texture if any
  49721. * @param isBase64 defines whether the texture is encoded as a base64
  49722. * @param isBuffer defines whether the texture data are stored as a buffer
  49723. * @returns true if the loader can load the specified file
  49724. */
  49725. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49726. /**
  49727. * Transform the url before loading if required.
  49728. * @param rootUrl the url of the texture
  49729. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49730. * @returns the transformed texture
  49731. */
  49732. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49733. /**
  49734. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49735. * @param rootUrl the url of the texture
  49736. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49737. * @returns the fallback texture
  49738. */
  49739. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49740. /**
  49741. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49742. * @param data contains the texture data
  49743. * @param texture defines the BabylonJS internal texture
  49744. * @param createPolynomials will be true if polynomials have been requested
  49745. * @param onLoad defines the callback to trigger once the texture is ready
  49746. * @param onError defines the callback to trigger in case of error
  49747. */
  49748. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49749. /**
  49750. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49751. * @param data contains the texture data
  49752. * @param texture defines the BabylonJS internal texture
  49753. * @param callback defines the method to call once ready to upload
  49754. */
  49755. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49756. }
  49757. }
  49758. declare module "babylonjs/Materials/Textures/Loaders/index" {
  49759. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49760. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49761. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49762. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  49763. }
  49764. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  49765. import { Scene } from "babylonjs/scene";
  49766. import { Texture } from "babylonjs/Materials/Textures/texture";
  49767. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49768. /**
  49769. * 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.
  49770. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49771. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49772. */
  49773. export class CustomProceduralTexture extends ProceduralTexture {
  49774. private _animate;
  49775. private _time;
  49776. private _config;
  49777. private _texturePath;
  49778. /**
  49779. * Instantiates a new Custom Procedural Texture.
  49780. * 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.
  49781. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49782. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49783. * @param name Define the name of the texture
  49784. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49785. * @param size Define the size of the texture to create
  49786. * @param scene Define the scene the texture belongs to
  49787. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49788. * @param generateMipMaps Define if the texture should creates mip maps or not
  49789. */
  49790. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49791. private _loadJson;
  49792. /**
  49793. * Is the texture ready to be used ? (rendered at least once)
  49794. * @returns true if ready, otherwise, false.
  49795. */
  49796. isReady(): boolean;
  49797. /**
  49798. * Render the texture to its associated render target.
  49799. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49800. */
  49801. render(useCameraPostProcess?: boolean): void;
  49802. /**
  49803. * Update the list of dependant textures samplers in the shader.
  49804. */
  49805. updateTextures(): void;
  49806. /**
  49807. * Update the uniform values of the procedural texture in the shader.
  49808. */
  49809. updateShaderUniforms(): void;
  49810. /**
  49811. * Define if the texture animates or not.
  49812. */
  49813. animate: boolean;
  49814. }
  49815. }
  49816. declare module "babylonjs/Shaders/noise.fragment" {
  49817. /** @hidden */
  49818. export var noisePixelShader: {
  49819. name: string;
  49820. shader: string;
  49821. };
  49822. }
  49823. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  49824. import { Nullable } from "babylonjs/types";
  49825. import { Scene } from "babylonjs/scene";
  49826. import { Texture } from "babylonjs/Materials/Textures/texture";
  49827. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49828. import "babylonjs/Shaders/noise.fragment";
  49829. /**
  49830. * Class used to generate noise procedural textures
  49831. */
  49832. export class NoiseProceduralTexture extends ProceduralTexture {
  49833. private _time;
  49834. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49835. brightness: number;
  49836. /** Defines the number of octaves to process */
  49837. octaves: number;
  49838. /** Defines the level of persistence (0.8 by default) */
  49839. persistence: number;
  49840. /** Gets or sets animation speed factor (default is 1) */
  49841. animationSpeedFactor: number;
  49842. /**
  49843. * Creates a new NoiseProceduralTexture
  49844. * @param name defines the name fo the texture
  49845. * @param size defines the size of the texture (default is 256)
  49846. * @param scene defines the hosting scene
  49847. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49848. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49849. */
  49850. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49851. private _updateShaderUniforms;
  49852. protected _getDefines(): string;
  49853. /** Generate the current state of the procedural texture */
  49854. render(useCameraPostProcess?: boolean): void;
  49855. /**
  49856. * Serializes this noise procedural texture
  49857. * @returns a serialized noise procedural texture object
  49858. */
  49859. serialize(): any;
  49860. /**
  49861. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49862. * @param parsedTexture defines parsed texture data
  49863. * @param scene defines the current scene
  49864. * @param rootUrl defines the root URL containing noise procedural texture information
  49865. * @returns a parsed NoiseProceduralTexture
  49866. */
  49867. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49868. }
  49869. }
  49870. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  49871. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  49872. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  49873. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  49874. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  49875. }
  49876. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  49877. import { Nullable } from "babylonjs/types";
  49878. import { Scene } from "babylonjs/scene";
  49879. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49880. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49881. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49882. /**
  49883. * Raw cube texture where the raw buffers are passed in
  49884. */
  49885. export class RawCubeTexture extends CubeTexture {
  49886. /**
  49887. * Creates a cube texture where the raw buffers are passed in.
  49888. * @param scene defines the scene the texture is attached to
  49889. * @param data defines the array of data to use to create each face
  49890. * @param size defines the size of the textures
  49891. * @param format defines the format of the data
  49892. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49893. * @param generateMipMaps defines if the engine should generate the mip levels
  49894. * @param invertY defines if data must be stored with Y axis inverted
  49895. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49896. * @param compression defines the compression used (null by default)
  49897. */
  49898. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49899. /**
  49900. * Updates the raw cube texture.
  49901. * @param data defines the data to store
  49902. * @param format defines the data format
  49903. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49904. * @param invertY defines if data must be stored with Y axis inverted
  49905. * @param compression defines the compression used (null by default)
  49906. * @param level defines which level of the texture to update
  49907. */
  49908. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49909. /**
  49910. * Updates a raw cube texture with RGBD encoded data.
  49911. * @param data defines the array of data [mipmap][face] to use to create each face
  49912. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49913. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49914. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49915. * @returns a promsie that resolves when the operation is complete
  49916. */
  49917. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49918. /**
  49919. * Clones the raw cube texture.
  49920. * @return a new cube texture
  49921. */
  49922. clone(): CubeTexture;
  49923. /** @hidden */
  49924. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49925. }
  49926. }
  49927. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  49928. import { Scene } from "babylonjs/scene";
  49929. import { Texture } from "babylonjs/Materials/Textures/texture";
  49930. /**
  49931. * Class used to store 3D textures containing user data
  49932. */
  49933. export class RawTexture3D extends Texture {
  49934. /** Gets or sets the texture format to use */
  49935. format: number;
  49936. private _engine;
  49937. /**
  49938. * Create a new RawTexture3D
  49939. * @param data defines the data of the texture
  49940. * @param width defines the width of the texture
  49941. * @param height defines the height of the texture
  49942. * @param depth defines the depth of the texture
  49943. * @param format defines the texture format to use
  49944. * @param scene defines the hosting scene
  49945. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49946. * @param invertY defines if texture must be stored with Y axis inverted
  49947. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49948. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49949. */
  49950. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49951. /** Gets or sets the texture format to use */
  49952. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49953. /**
  49954. * Update the texture with new data
  49955. * @param data defines the data to store in the texture
  49956. */
  49957. update(data: ArrayBufferView): void;
  49958. }
  49959. }
  49960. declare module "babylonjs/Materials/Textures/refractionTexture" {
  49961. import { Scene } from "babylonjs/scene";
  49962. import { Plane } from "babylonjs/Maths/math";
  49963. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49964. /**
  49965. * Creates a refraction texture used by refraction channel of the standard material.
  49966. * It is like a mirror but to see through a material.
  49967. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49968. */
  49969. export class RefractionTexture extends RenderTargetTexture {
  49970. /**
  49971. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49972. * 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.
  49973. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49974. */
  49975. refractionPlane: Plane;
  49976. /**
  49977. * Define how deep under the surface we should see.
  49978. */
  49979. depth: number;
  49980. /**
  49981. * Creates a refraction texture used by refraction channel of the standard material.
  49982. * It is like a mirror but to see through a material.
  49983. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49984. * @param name Define the texture name
  49985. * @param size Define the size of the underlying texture
  49986. * @param scene Define the scene the refraction belongs to
  49987. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49988. */
  49989. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49990. /**
  49991. * Clone the refraction texture.
  49992. * @returns the cloned texture
  49993. */
  49994. clone(): RefractionTexture;
  49995. /**
  49996. * Serialize the texture to a JSON representation you could use in Parse later on
  49997. * @returns the serialized JSON representation
  49998. */
  49999. serialize(): any;
  50000. }
  50001. }
  50002. declare module "babylonjs/Materials/Textures/index" {
  50003. export * from "babylonjs/Materials/Textures/baseTexture";
  50004. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  50005. export * from "babylonjs/Materials/Textures/cubeTexture";
  50006. export * from "babylonjs/Materials/Textures/dynamicTexture";
  50007. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  50008. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  50009. export * from "babylonjs/Materials/Textures/internalTexture";
  50010. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  50011. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  50012. export * from "babylonjs/Materials/Textures/Loaders/index";
  50013. export * from "babylonjs/Materials/Textures/mirrorTexture";
  50014. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  50015. export * from "babylonjs/Materials/Textures/Procedurals/index";
  50016. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  50017. export * from "babylonjs/Materials/Textures/rawTexture";
  50018. export * from "babylonjs/Materials/Textures/rawTexture3D";
  50019. export * from "babylonjs/Materials/Textures/refractionTexture";
  50020. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  50021. export * from "babylonjs/Materials/Textures/texture";
  50022. export * from "babylonjs/Materials/Textures/videoTexture";
  50023. }
  50024. declare module "babylonjs/Materials/index" {
  50025. export * from "babylonjs/Materials/Background/index";
  50026. export * from "babylonjs/Materials/colorCurves";
  50027. export * from "babylonjs/Materials/effect";
  50028. export * from "babylonjs/Materials/fresnelParameters";
  50029. export * from "babylonjs/Materials/imageProcessingConfiguration";
  50030. export * from "babylonjs/Materials/material";
  50031. export * from "babylonjs/Materials/materialDefines";
  50032. export * from "babylonjs/Materials/materialHelper";
  50033. export * from "babylonjs/Materials/multiMaterial";
  50034. export * from "babylonjs/Materials/PBR/index";
  50035. export * from "babylonjs/Materials/pushMaterial";
  50036. export * from "babylonjs/Materials/shaderMaterial";
  50037. export * from "babylonjs/Materials/standardMaterial";
  50038. export * from "babylonjs/Materials/Textures/index";
  50039. export * from "babylonjs/Materials/uniformBuffer";
  50040. export * from "babylonjs/Materials/materialFlags";
  50041. }
  50042. declare module "babylonjs/Maths/index" {
  50043. export * from "babylonjs/Maths/math.scalar";
  50044. export * from "babylonjs/Maths/math";
  50045. export * from "babylonjs/Maths/sphericalPolynomial";
  50046. }
  50047. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  50048. import { IDisposable } from "babylonjs/scene";
  50049. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  50050. /**
  50051. * Configuration for Draco compression
  50052. */
  50053. export interface IDracoCompressionConfiguration {
  50054. /**
  50055. * Configuration for the decoder.
  50056. */
  50057. decoder?: {
  50058. /**
  50059. * The url to the WebAssembly module.
  50060. */
  50061. wasmUrl?: string;
  50062. /**
  50063. * The url to the WebAssembly binary.
  50064. */
  50065. wasmBinaryUrl?: string;
  50066. /**
  50067. * The url to the fallback JavaScript module.
  50068. */
  50069. fallbackUrl?: string;
  50070. };
  50071. }
  50072. /**
  50073. * Draco compression (https://google.github.io/draco/)
  50074. *
  50075. * This class wraps the Draco module.
  50076. *
  50077. * **Encoder**
  50078. *
  50079. * The encoder is not currently implemented.
  50080. *
  50081. * **Decoder**
  50082. *
  50083. * 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.
  50084. *
  50085. * To update the configuration, use the following code:
  50086. * ```javascript
  50087. * DracoCompression.Configuration = {
  50088. * decoder: {
  50089. * wasmUrl: "<url to the WebAssembly library>",
  50090. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  50091. * fallbackUrl: "<url to the fallback JavaScript library>",
  50092. * }
  50093. * };
  50094. * ```
  50095. *
  50096. * 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.
  50097. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  50098. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  50099. *
  50100. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  50101. * ```javascript
  50102. * var dracoCompression = new DracoCompression();
  50103. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  50104. * [VertexBuffer.PositionKind]: 0
  50105. * });
  50106. * ```
  50107. *
  50108. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  50109. */
  50110. export class DracoCompression implements IDisposable {
  50111. private static _DecoderModulePromise;
  50112. /**
  50113. * The configuration. Defaults to the following urls:
  50114. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  50115. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  50116. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  50117. */
  50118. static Configuration: IDracoCompressionConfiguration;
  50119. /**
  50120. * Returns true if the decoder is available.
  50121. */
  50122. static readonly DecoderAvailable: boolean;
  50123. /**
  50124. * Constructor
  50125. */
  50126. constructor();
  50127. /**
  50128. * Stop all async operations and release resources.
  50129. */
  50130. dispose(): void;
  50131. /**
  50132. * Decode Draco compressed mesh data to vertex data.
  50133. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  50134. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  50135. * @returns A promise that resolves with the decoded vertex data
  50136. */
  50137. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  50138. [kind: string]: number;
  50139. }): Promise<VertexData>;
  50140. private static _GetDecoderModule;
  50141. private static _LoadScriptAsync;
  50142. private static _LoadFileAsync;
  50143. }
  50144. }
  50145. declare module "babylonjs/Meshes/Compression/index" {
  50146. export * from "babylonjs/Meshes/Compression/dracoCompression";
  50147. }
  50148. declare module "babylonjs/Meshes/csg" {
  50149. import { Nullable } from "babylonjs/types";
  50150. import { Scene } from "babylonjs/scene";
  50151. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  50152. import { Mesh } from "babylonjs/Meshes/mesh";
  50153. import { Material } from "babylonjs/Materials/material";
  50154. /**
  50155. * Class for building Constructive Solid Geometry
  50156. */
  50157. export class CSG {
  50158. private polygons;
  50159. /**
  50160. * The world matrix
  50161. */
  50162. matrix: Matrix;
  50163. /**
  50164. * Stores the position
  50165. */
  50166. position: Vector3;
  50167. /**
  50168. * Stores the rotation
  50169. */
  50170. rotation: Vector3;
  50171. /**
  50172. * Stores the rotation quaternion
  50173. */
  50174. rotationQuaternion: Nullable<Quaternion>;
  50175. /**
  50176. * Stores the scaling vector
  50177. */
  50178. scaling: Vector3;
  50179. /**
  50180. * Convert the Mesh to CSG
  50181. * @param mesh The Mesh to convert to CSG
  50182. * @returns A new CSG from the Mesh
  50183. */
  50184. static FromMesh(mesh: Mesh): CSG;
  50185. /**
  50186. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  50187. * @param polygons Polygons used to construct a CSG solid
  50188. */
  50189. private static FromPolygons;
  50190. /**
  50191. * Clones, or makes a deep copy, of the CSG
  50192. * @returns A new CSG
  50193. */
  50194. clone(): CSG;
  50195. /**
  50196. * Unions this CSG with another CSG
  50197. * @param csg The CSG to union against this CSG
  50198. * @returns The unioned CSG
  50199. */
  50200. union(csg: CSG): CSG;
  50201. /**
  50202. * Unions this CSG with another CSG in place
  50203. * @param csg The CSG to union against this CSG
  50204. */
  50205. unionInPlace(csg: CSG): void;
  50206. /**
  50207. * Subtracts this CSG with another CSG
  50208. * @param csg The CSG to subtract against this CSG
  50209. * @returns A new CSG
  50210. */
  50211. subtract(csg: CSG): CSG;
  50212. /**
  50213. * Subtracts this CSG with another CSG in place
  50214. * @param csg The CSG to subtact against this CSG
  50215. */
  50216. subtractInPlace(csg: CSG): void;
  50217. /**
  50218. * Intersect this CSG with another CSG
  50219. * @param csg The CSG to intersect against this CSG
  50220. * @returns A new CSG
  50221. */
  50222. intersect(csg: CSG): CSG;
  50223. /**
  50224. * Intersects this CSG with another CSG in place
  50225. * @param csg The CSG to intersect against this CSG
  50226. */
  50227. intersectInPlace(csg: CSG): void;
  50228. /**
  50229. * Return a new CSG solid with solid and empty space switched. This solid is
  50230. * not modified.
  50231. * @returns A new CSG solid with solid and empty space switched
  50232. */
  50233. inverse(): CSG;
  50234. /**
  50235. * Inverses the CSG in place
  50236. */
  50237. inverseInPlace(): void;
  50238. /**
  50239. * This is used to keep meshes transformations so they can be restored
  50240. * when we build back a Babylon Mesh
  50241. * NB : All CSG operations are performed in world coordinates
  50242. * @param csg The CSG to copy the transform attributes from
  50243. * @returns This CSG
  50244. */
  50245. copyTransformAttributes(csg: CSG): CSG;
  50246. /**
  50247. * Build Raw mesh from CSG
  50248. * Coordinates here are in world space
  50249. * @param name The name of the mesh geometry
  50250. * @param scene The Scene
  50251. * @param keepSubMeshes Specifies if the submeshes should be kept
  50252. * @returns A new Mesh
  50253. */
  50254. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  50255. /**
  50256. * Build Mesh from CSG taking material and transforms into account
  50257. * @param name The name of the Mesh
  50258. * @param material The material of the Mesh
  50259. * @param scene The Scene
  50260. * @param keepSubMeshes Specifies if submeshes should be kept
  50261. * @returns The new Mesh
  50262. */
  50263. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  50264. }
  50265. }
  50266. declare module "babylonjs/Meshes/trailMesh" {
  50267. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50268. import { Mesh } from "babylonjs/Meshes/mesh";
  50269. import { Scene } from "babylonjs/scene";
  50270. /**
  50271. * Class used to create a trail following a mesh
  50272. */
  50273. export class TrailMesh extends Mesh {
  50274. private _generator;
  50275. private _autoStart;
  50276. private _running;
  50277. private _diameter;
  50278. private _length;
  50279. private _sectionPolygonPointsCount;
  50280. private _sectionVectors;
  50281. private _sectionNormalVectors;
  50282. private _beforeRenderObserver;
  50283. /**
  50284. * @constructor
  50285. * @param name The value used by scene.getMeshByName() to do a lookup.
  50286. * @param generator The mesh to generate a trail.
  50287. * @param scene The scene to add this mesh to.
  50288. * @param diameter Diameter of trailing mesh. Default is 1.
  50289. * @param length Length of trailing mesh. Default is 60.
  50290. * @param autoStart Automatically start trailing mesh. Default true.
  50291. */
  50292. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  50293. /**
  50294. * "TrailMesh"
  50295. * @returns "TrailMesh"
  50296. */
  50297. getClassName(): string;
  50298. private _createMesh;
  50299. /**
  50300. * Start trailing mesh.
  50301. */
  50302. start(): void;
  50303. /**
  50304. * Stop trailing mesh.
  50305. */
  50306. stop(): void;
  50307. /**
  50308. * Update trailing mesh geometry.
  50309. */
  50310. update(): void;
  50311. /**
  50312. * Returns a new TrailMesh object.
  50313. * @param name is a string, the name given to the new mesh
  50314. * @param newGenerator use new generator object for cloned trail mesh
  50315. * @returns a new mesh
  50316. */
  50317. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  50318. /**
  50319. * Serializes this trail mesh
  50320. * @param serializationObject object to write serialization to
  50321. */
  50322. serialize(serializationObject: any): void;
  50323. /**
  50324. * Parses a serialized trail mesh
  50325. * @param parsedMesh the serialized mesh
  50326. * @param scene the scene to create the trail mesh in
  50327. * @returns the created trail mesh
  50328. */
  50329. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  50330. }
  50331. }
  50332. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50333. import { Nullable } from "babylonjs/types";
  50334. import { Scene } from "babylonjs/scene";
  50335. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50336. import { Mesh } from "babylonjs/Meshes/mesh";
  50337. /**
  50338. * Class containing static functions to help procedurally build meshes
  50339. */
  50340. export class RibbonBuilder {
  50341. /**
  50342. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50343. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50344. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50345. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50346. * * 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
  50347. * * 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
  50348. * * 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
  50349. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50350. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50351. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50352. * * 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
  50353. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50354. * * 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
  50355. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50357. * @param name defines the name of the mesh
  50358. * @param options defines the options used to create the mesh
  50359. * @param scene defines the hosting scene
  50360. * @returns the ribbon mesh
  50361. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50362. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50363. */
  50364. static CreateRibbon(name: string, options: {
  50365. pathArray: Vector3[][];
  50366. closeArray?: boolean;
  50367. closePath?: boolean;
  50368. offset?: number;
  50369. updatable?: boolean;
  50370. sideOrientation?: number;
  50371. frontUVs?: Vector4;
  50372. backUVs?: Vector4;
  50373. instance?: Mesh;
  50374. invertUV?: boolean;
  50375. uvs?: Vector2[];
  50376. colors?: Color4[];
  50377. }, scene?: Nullable<Scene>): Mesh;
  50378. }
  50379. }
  50380. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  50381. import { Vector4 } from "babylonjs/Maths/math";
  50382. import { Mesh } from "babylonjs/Meshes/mesh";
  50383. /**
  50384. * Class containing static functions to help procedurally build meshes
  50385. */
  50386. export class TorusKnotBuilder {
  50387. /**
  50388. * Creates a torus knot mesh
  50389. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50390. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50391. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50392. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50393. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50394. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50396. * @param name defines the name of the mesh
  50397. * @param options defines the options used to create the mesh
  50398. * @param scene defines the hosting scene
  50399. * @returns the torus knot mesh
  50400. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50401. */
  50402. static CreateTorusKnot(name: string, options: {
  50403. radius?: number;
  50404. tube?: number;
  50405. radialSegments?: number;
  50406. tubularSegments?: number;
  50407. p?: number;
  50408. q?: number;
  50409. updatable?: boolean;
  50410. sideOrientation?: number;
  50411. frontUVs?: Vector4;
  50412. backUVs?: Vector4;
  50413. }, scene: any): Mesh;
  50414. }
  50415. }
  50416. declare module "babylonjs/Meshes/polygonMesh" {
  50417. import { Scene } from "babylonjs/scene";
  50418. import { Vector2, Path2 } from "babylonjs/Maths/math";
  50419. import { Mesh } from "babylonjs/Meshes/mesh";
  50420. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  50421. /**
  50422. * Polygon
  50423. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  50424. */
  50425. export class Polygon {
  50426. /**
  50427. * Creates a rectangle
  50428. * @param xmin bottom X coord
  50429. * @param ymin bottom Y coord
  50430. * @param xmax top X coord
  50431. * @param ymax top Y coord
  50432. * @returns points that make the resulting rectation
  50433. */
  50434. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  50435. /**
  50436. * Creates a circle
  50437. * @param radius radius of circle
  50438. * @param cx scale in x
  50439. * @param cy scale in y
  50440. * @param numberOfSides number of sides that make up the circle
  50441. * @returns points that make the resulting circle
  50442. */
  50443. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  50444. /**
  50445. * Creates a polygon from input string
  50446. * @param input Input polygon data
  50447. * @returns the parsed points
  50448. */
  50449. static Parse(input: string): Vector2[];
  50450. /**
  50451. * Starts building a polygon from x and y coordinates
  50452. * @param x x coordinate
  50453. * @param y y coordinate
  50454. * @returns the started path2
  50455. */
  50456. static StartingAt(x: number, y: number): Path2;
  50457. }
  50458. /**
  50459. * Builds a polygon
  50460. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  50461. */
  50462. export class PolygonMeshBuilder {
  50463. private _points;
  50464. private _outlinepoints;
  50465. private _holes;
  50466. private _name;
  50467. private _scene;
  50468. private _epoints;
  50469. private _eholes;
  50470. private _addToepoint;
  50471. /**
  50472. * Babylon reference to the earcut plugin.
  50473. */
  50474. bjsEarcut: any;
  50475. /**
  50476. * Creates a PolygonMeshBuilder
  50477. * @param name name of the builder
  50478. * @param contours Path of the polygon
  50479. * @param scene scene to add to when creating the mesh
  50480. * @param earcutInjection can be used to inject your own earcut reference
  50481. */
  50482. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  50483. /**
  50484. * Adds a whole within the polygon
  50485. * @param hole Array of points defining the hole
  50486. * @returns this
  50487. */
  50488. addHole(hole: Vector2[]): PolygonMeshBuilder;
  50489. /**
  50490. * Creates the polygon
  50491. * @param updatable If the mesh should be updatable
  50492. * @param depth The depth of the mesh created
  50493. * @returns the created mesh
  50494. */
  50495. build(updatable?: boolean, depth?: number): Mesh;
  50496. /**
  50497. * Creates the polygon
  50498. * @param depth The depth of the mesh created
  50499. * @returns the created VertexData
  50500. */
  50501. buildVertexData(depth?: number): VertexData;
  50502. /**
  50503. * Adds a side to the polygon
  50504. * @param positions points that make the polygon
  50505. * @param normals normals of the polygon
  50506. * @param uvs uvs of the polygon
  50507. * @param indices indices of the polygon
  50508. * @param bounds bounds of the polygon
  50509. * @param points points of the polygon
  50510. * @param depth depth of the polygon
  50511. * @param flip flip of the polygon
  50512. */
  50513. private addSide;
  50514. }
  50515. }
  50516. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  50517. import { Scene } from "babylonjs/scene";
  50518. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  50519. import { Mesh } from "babylonjs/Meshes/mesh";
  50520. /**
  50521. * Class containing static functions to help procedurally build meshes
  50522. */
  50523. export class PolygonBuilder {
  50524. /**
  50525. * Creates a polygon mesh
  50526. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50527. * * 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
  50528. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50530. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  50531. * * Remember you can only change the shape positions, not their number when updating a polygon
  50532. * @param name defines the name of the mesh
  50533. * @param options defines the options used to create the mesh
  50534. * @param scene defines the hosting scene
  50535. * @param earcutInjection can be used to inject your own earcut reference
  50536. * @returns the polygon mesh
  50537. */
  50538. static CreatePolygon(name: string, options: {
  50539. shape: Vector3[];
  50540. holes?: Vector3[][];
  50541. depth?: number;
  50542. faceUV?: Vector4[];
  50543. faceColors?: Color4[];
  50544. updatable?: boolean;
  50545. sideOrientation?: number;
  50546. frontUVs?: Vector4;
  50547. backUVs?: Vector4;
  50548. }, scene: Scene, earcutInjection?: any): Mesh;
  50549. /**
  50550. * Creates an extruded polygon mesh, with depth in the Y direction.
  50551. * * 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)
  50552. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50553. * @param name defines the name of the mesh
  50554. * @param options defines the options used to create the mesh
  50555. * @param scene defines the hosting scene
  50556. * @param earcutInjection can be used to inject your own earcut reference
  50557. * @returns the polygon mesh
  50558. */
  50559. static ExtrudePolygon(name: string, options: {
  50560. shape: Vector3[];
  50561. holes?: Vector3[][];
  50562. depth?: number;
  50563. faceUV?: Vector4[];
  50564. faceColors?: Color4[];
  50565. updatable?: boolean;
  50566. sideOrientation?: number;
  50567. frontUVs?: Vector4;
  50568. backUVs?: Vector4;
  50569. }, scene: Scene, earcutInjection?: any): Mesh;
  50570. }
  50571. }
  50572. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50573. import { Nullable } from "babylonjs/types";
  50574. import { Scene } from "babylonjs/scene";
  50575. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50576. import { Mesh } from "babylonjs/Meshes/mesh";
  50577. /**
  50578. * Class containing static functions to help procedurally build meshes
  50579. */
  50580. export class ShapeBuilder {
  50581. /**
  50582. * 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.
  50583. * * 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.
  50584. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50585. * * 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.
  50586. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50587. * * 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
  50588. * * 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
  50589. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50590. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50591. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50592. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50594. * @param name defines the name of the mesh
  50595. * @param options defines the options used to create the mesh
  50596. * @param scene defines the hosting scene
  50597. * @returns the extruded shape mesh
  50598. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50599. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50600. */
  50601. static ExtrudeShape(name: string, options: {
  50602. shape: Vector3[];
  50603. path: Vector3[];
  50604. scale?: number;
  50605. rotation?: number;
  50606. cap?: number;
  50607. updatable?: boolean;
  50608. sideOrientation?: number;
  50609. frontUVs?: Vector4;
  50610. backUVs?: Vector4;
  50611. instance?: Mesh;
  50612. invertUV?: boolean;
  50613. }, scene?: Nullable<Scene>): Mesh;
  50614. /**
  50615. * Creates an custom extruded shape mesh.
  50616. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50617. * * 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.
  50618. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50619. * * 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
  50620. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50621. * * 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
  50622. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50623. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50624. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50625. * * 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
  50626. * * 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
  50627. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50628. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50629. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50630. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50632. * @param name defines the name of the mesh
  50633. * @param options defines the options used to create the mesh
  50634. * @param scene defines the hosting scene
  50635. * @returns the custom extruded shape mesh
  50636. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50637. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50638. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50639. */
  50640. static ExtrudeShapeCustom(name: string, options: {
  50641. shape: Vector3[];
  50642. path: Vector3[];
  50643. scaleFunction?: any;
  50644. rotationFunction?: any;
  50645. ribbonCloseArray?: boolean;
  50646. ribbonClosePath?: boolean;
  50647. cap?: number;
  50648. updatable?: boolean;
  50649. sideOrientation?: number;
  50650. frontUVs?: Vector4;
  50651. backUVs?: Vector4;
  50652. instance?: Mesh;
  50653. invertUV?: boolean;
  50654. }, scene: Scene): Mesh;
  50655. private static _ExtrudeShapeGeneric;
  50656. }
  50657. }
  50658. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  50659. import { Scene } from "babylonjs/scene";
  50660. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50661. import { Mesh } from "babylonjs/Meshes/mesh";
  50662. /**
  50663. * Class containing static functions to help procedurally build meshes
  50664. */
  50665. export class LatheBuilder {
  50666. /**
  50667. * Creates lathe mesh.
  50668. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50669. * * 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
  50670. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50671. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50672. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50673. * * 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
  50674. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50675. * * 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
  50676. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50677. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50678. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50680. * @param name defines the name of the mesh
  50681. * @param options defines the options used to create the mesh
  50682. * @param scene defines the hosting scene
  50683. * @returns the lathe mesh
  50684. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50685. */
  50686. static CreateLathe(name: string, options: {
  50687. shape: Vector3[];
  50688. radius?: number;
  50689. tessellation?: number;
  50690. clip?: number;
  50691. arc?: number;
  50692. closed?: boolean;
  50693. updatable?: boolean;
  50694. sideOrientation?: number;
  50695. frontUVs?: Vector4;
  50696. backUVs?: Vector4;
  50697. cap?: number;
  50698. invertUV?: boolean;
  50699. }, scene: Scene): Mesh;
  50700. }
  50701. }
  50702. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  50703. import { Scene } from "babylonjs/scene";
  50704. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50705. import { Mesh } from "babylonjs/Meshes/mesh";
  50706. /**
  50707. * Class containing static functions to help procedurally build meshes
  50708. */
  50709. export class TubeBuilder {
  50710. /**
  50711. * Creates a tube mesh.
  50712. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50713. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50714. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50715. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50716. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50717. * * 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)
  50718. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50719. * * 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
  50720. * * 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
  50721. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50722. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50723. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50725. * @param name defines the name of the mesh
  50726. * @param options defines the options used to create the mesh
  50727. * @param scene defines the hosting scene
  50728. * @returns the tube mesh
  50729. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50730. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50731. */
  50732. static CreateTube(name: string, options: {
  50733. path: Vector3[];
  50734. radius?: number;
  50735. tessellation?: number;
  50736. radiusFunction?: {
  50737. (i: number, distance: number): number;
  50738. };
  50739. cap?: number;
  50740. arc?: number;
  50741. updatable?: boolean;
  50742. sideOrientation?: number;
  50743. frontUVs?: Vector4;
  50744. backUVs?: Vector4;
  50745. instance?: Mesh;
  50746. invertUV?: boolean;
  50747. }, scene: Scene): Mesh;
  50748. }
  50749. }
  50750. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  50751. import { Scene } from "babylonjs/scene";
  50752. import { Vector4 } from "babylonjs/Maths/math";
  50753. import { Mesh } from "babylonjs/Meshes/mesh";
  50754. /**
  50755. * Class containing static functions to help procedurally build meshes
  50756. */
  50757. export class IcoSphereBuilder {
  50758. /**
  50759. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50760. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50761. * * 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`)
  50762. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50763. * * 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
  50764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50767. * @param name defines the name of the mesh
  50768. * @param options defines the options used to create the mesh
  50769. * @param scene defines the hosting scene
  50770. * @returns the icosahedron mesh
  50771. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50772. */
  50773. static CreateIcoSphere(name: string, options: {
  50774. radius?: number;
  50775. radiusX?: number;
  50776. radiusY?: number;
  50777. radiusZ?: number;
  50778. flat?: boolean;
  50779. subdivisions?: number;
  50780. sideOrientation?: number;
  50781. frontUVs?: Vector4;
  50782. backUVs?: Vector4;
  50783. updatable?: boolean;
  50784. }, scene: Scene): Mesh;
  50785. }
  50786. }
  50787. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  50788. import { Vector3 } from "babylonjs/Maths/math";
  50789. import { Mesh } from "babylonjs/Meshes/mesh";
  50790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50791. /**
  50792. * Class containing static functions to help procedurally build meshes
  50793. */
  50794. export class DecalBuilder {
  50795. /**
  50796. * Creates a decal mesh.
  50797. * 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
  50798. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50799. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50800. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50801. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50802. * @param name defines the name of the mesh
  50803. * @param sourceMesh defines the mesh where the decal must be applied
  50804. * @param options defines the options used to create the mesh
  50805. * @param scene defines the hosting scene
  50806. * @returns the decal mesh
  50807. * @see https://doc.babylonjs.com/how_to/decals
  50808. */
  50809. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50810. position?: Vector3;
  50811. normal?: Vector3;
  50812. size?: Vector3;
  50813. angle?: number;
  50814. }): Mesh;
  50815. }
  50816. }
  50817. declare module "babylonjs/Meshes/meshBuilder" {
  50818. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  50819. import { Nullable } from "babylonjs/types";
  50820. import { Scene } from "babylonjs/scene";
  50821. import { Mesh } from "babylonjs/Meshes/mesh";
  50822. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50823. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  50824. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50825. /**
  50826. * Class containing static functions to help procedurally build meshes
  50827. */
  50828. export class MeshBuilder {
  50829. /**
  50830. * Creates a box mesh
  50831. * * The parameter `size` sets the size (float) of each box side (default 1)
  50832. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50833. * * 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)
  50834. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50835. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50836. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50838. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50839. * @param name defines the name of the mesh
  50840. * @param options defines the options used to create the mesh
  50841. * @param scene defines the hosting scene
  50842. * @returns the box mesh
  50843. */
  50844. static CreateBox(name: string, options: {
  50845. size?: number;
  50846. width?: number;
  50847. height?: number;
  50848. depth?: number;
  50849. faceUV?: Vector4[];
  50850. faceColors?: Color4[];
  50851. sideOrientation?: number;
  50852. frontUVs?: Vector4;
  50853. backUVs?: Vector4;
  50854. updatable?: boolean;
  50855. }, scene?: Nullable<Scene>): Mesh;
  50856. /**
  50857. * Creates a sphere mesh
  50858. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50859. * * 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`)
  50860. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50861. * * 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
  50862. * * 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)
  50863. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50864. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50866. * @param name defines the name of the mesh
  50867. * @param options defines the options used to create the mesh
  50868. * @param scene defines the hosting scene
  50869. * @returns the sphere mesh
  50870. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50871. */
  50872. static CreateSphere(name: string, options: {
  50873. segments?: number;
  50874. diameter?: number;
  50875. diameterX?: number;
  50876. diameterY?: number;
  50877. diameterZ?: number;
  50878. arc?: number;
  50879. slice?: number;
  50880. sideOrientation?: number;
  50881. frontUVs?: Vector4;
  50882. backUVs?: Vector4;
  50883. updatable?: boolean;
  50884. }, scene: any): Mesh;
  50885. /**
  50886. * Creates a plane polygonal mesh. By default, this is a disc
  50887. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50888. * * 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
  50889. * * 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
  50890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50891. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50893. * @param name defines the name of the mesh
  50894. * @param options defines the options used to create the mesh
  50895. * @param scene defines the hosting scene
  50896. * @returns the plane polygonal mesh
  50897. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  50898. */
  50899. static CreateDisc(name: string, options: {
  50900. radius?: number;
  50901. tessellation?: number;
  50902. arc?: number;
  50903. updatable?: boolean;
  50904. sideOrientation?: number;
  50905. frontUVs?: Vector4;
  50906. backUVs?: Vector4;
  50907. }, scene?: Nullable<Scene>): Mesh;
  50908. /**
  50909. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50910. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50911. * * 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`)
  50912. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50913. * * 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
  50914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50915. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50917. * @param name defines the name of the mesh
  50918. * @param options defines the options used to create the mesh
  50919. * @param scene defines the hosting scene
  50920. * @returns the icosahedron mesh
  50921. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50922. */
  50923. static CreateIcoSphere(name: string, options: {
  50924. radius?: number;
  50925. radiusX?: number;
  50926. radiusY?: number;
  50927. radiusZ?: number;
  50928. flat?: boolean;
  50929. subdivisions?: number;
  50930. sideOrientation?: number;
  50931. frontUVs?: Vector4;
  50932. backUVs?: Vector4;
  50933. updatable?: boolean;
  50934. }, scene: Scene): Mesh;
  50935. /**
  50936. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50937. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50938. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50939. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50940. * * 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
  50941. * * 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
  50942. * * 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
  50943. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50944. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50945. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50946. * * 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
  50947. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50948. * * 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
  50949. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50951. * @param name defines the name of the mesh
  50952. * @param options defines the options used to create the mesh
  50953. * @param scene defines the hosting scene
  50954. * @returns the ribbon mesh
  50955. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50956. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50957. */
  50958. static CreateRibbon(name: string, options: {
  50959. pathArray: Vector3[][];
  50960. closeArray?: boolean;
  50961. closePath?: boolean;
  50962. offset?: number;
  50963. updatable?: boolean;
  50964. sideOrientation?: number;
  50965. frontUVs?: Vector4;
  50966. backUVs?: Vector4;
  50967. instance?: Mesh;
  50968. invertUV?: boolean;
  50969. uvs?: Vector2[];
  50970. colors?: Color4[];
  50971. }, scene?: Nullable<Scene>): Mesh;
  50972. /**
  50973. * Creates a cylinder or a cone mesh
  50974. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50975. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50976. * * 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.
  50977. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50978. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50979. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50980. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50981. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50982. * * 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).
  50983. * * 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
  50984. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50985. * * 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
  50986. * * 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.
  50987. * * If `enclose` is false, a ring surface is one element.
  50988. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50989. * * 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
  50990. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50991. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50992. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50993. * @param name defines the name of the mesh
  50994. * @param options defines the options used to create the mesh
  50995. * @param scene defines the hosting scene
  50996. * @returns the cylinder mesh
  50997. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50998. */
  50999. static CreateCylinder(name: string, options: {
  51000. height?: number;
  51001. diameterTop?: number;
  51002. diameterBottom?: number;
  51003. diameter?: number;
  51004. tessellation?: number;
  51005. subdivisions?: number;
  51006. arc?: number;
  51007. faceColors?: Color4[];
  51008. faceUV?: Vector4[];
  51009. updatable?: boolean;
  51010. hasRings?: boolean;
  51011. enclose?: boolean;
  51012. sideOrientation?: number;
  51013. frontUVs?: Vector4;
  51014. backUVs?: Vector4;
  51015. }, scene: any): Mesh;
  51016. /**
  51017. * Creates a torus mesh
  51018. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  51019. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  51020. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  51021. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51022. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51024. * @param name defines the name of the mesh
  51025. * @param options defines the options used to create the mesh
  51026. * @param scene defines the hosting scene
  51027. * @returns the torus mesh
  51028. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  51029. */
  51030. static CreateTorus(name: string, options: {
  51031. diameter?: number;
  51032. thickness?: number;
  51033. tessellation?: number;
  51034. updatable?: boolean;
  51035. sideOrientation?: number;
  51036. frontUVs?: Vector4;
  51037. backUVs?: Vector4;
  51038. }, scene: any): Mesh;
  51039. /**
  51040. * Creates a torus knot mesh
  51041. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51042. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51043. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51044. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51045. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51046. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51048. * @param name defines the name of the mesh
  51049. * @param options defines the options used to create the mesh
  51050. * @param scene defines the hosting scene
  51051. * @returns the torus knot mesh
  51052. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51053. */
  51054. static CreateTorusKnot(name: string, options: {
  51055. radius?: number;
  51056. tube?: number;
  51057. radialSegments?: number;
  51058. tubularSegments?: number;
  51059. p?: number;
  51060. q?: number;
  51061. updatable?: boolean;
  51062. sideOrientation?: number;
  51063. frontUVs?: Vector4;
  51064. backUVs?: Vector4;
  51065. }, scene: any): Mesh;
  51066. /**
  51067. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  51068. * * 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
  51069. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  51070. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  51071. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  51072. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  51073. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51074. * * 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
  51075. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  51076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51077. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  51078. * @param name defines the name of the new line system
  51079. * @param options defines the options used to create the line system
  51080. * @param scene defines the hosting scene
  51081. * @returns a new line system mesh
  51082. */
  51083. static CreateLineSystem(name: string, options: {
  51084. lines: Vector3[][];
  51085. updatable?: boolean;
  51086. instance?: Nullable<LinesMesh>;
  51087. colors?: Nullable<Color4[][]>;
  51088. useVertexAlpha?: boolean;
  51089. }, scene: Nullable<Scene>): LinesMesh;
  51090. /**
  51091. * Creates a line mesh
  51092. * 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
  51093. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51094. * * The parameter `points` is an array successive Vector3
  51095. * * 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
  51096. * * The optional parameter `colors` is an array of successive Color4, one per line point
  51097. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  51098. * * When updating an instance, remember that only point positions can change, not the number of points
  51099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51100. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  51101. * @param name defines the name of the new line system
  51102. * @param options defines the options used to create the line system
  51103. * @param scene defines the hosting scene
  51104. * @returns a new line mesh
  51105. */
  51106. static CreateLines(name: string, options: {
  51107. points: Vector3[];
  51108. updatable?: boolean;
  51109. instance?: Nullable<LinesMesh>;
  51110. colors?: Color4[];
  51111. useVertexAlpha?: boolean;
  51112. }, scene?: Nullable<Scene>): LinesMesh;
  51113. /**
  51114. * Creates a dashed line mesh
  51115. * * 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
  51116. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51117. * * The parameter `points` is an array successive Vector3
  51118. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  51119. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  51120. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  51121. * * 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
  51122. * * When updating an instance, remember that only point positions can change, not the number of points
  51123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51124. * @param name defines the name of the mesh
  51125. * @param options defines the options used to create the mesh
  51126. * @param scene defines the hosting scene
  51127. * @returns the dashed line mesh
  51128. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  51129. */
  51130. static CreateDashedLines(name: string, options: {
  51131. points: Vector3[];
  51132. dashSize?: number;
  51133. gapSize?: number;
  51134. dashNb?: number;
  51135. updatable?: boolean;
  51136. instance?: LinesMesh;
  51137. }, scene?: Nullable<Scene>): LinesMesh;
  51138. /**
  51139. * 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.
  51140. * * 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.
  51141. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51142. * * 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.
  51143. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51144. * * 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
  51145. * * 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
  51146. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51147. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51148. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51149. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51151. * @param name defines the name of the mesh
  51152. * @param options defines the options used to create the mesh
  51153. * @param scene defines the hosting scene
  51154. * @returns the extruded shape mesh
  51155. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51156. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51157. */
  51158. static ExtrudeShape(name: string, options: {
  51159. shape: Vector3[];
  51160. path: Vector3[];
  51161. scale?: number;
  51162. rotation?: number;
  51163. cap?: number;
  51164. updatable?: boolean;
  51165. sideOrientation?: number;
  51166. frontUVs?: Vector4;
  51167. backUVs?: Vector4;
  51168. instance?: Mesh;
  51169. invertUV?: boolean;
  51170. }, scene?: Nullable<Scene>): Mesh;
  51171. /**
  51172. * Creates an custom extruded shape mesh.
  51173. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51174. * * 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.
  51175. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51176. * * 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
  51177. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51178. * * 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
  51179. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51180. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51181. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51182. * * 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
  51183. * * 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
  51184. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51185. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51186. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51187. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51189. * @param name defines the name of the mesh
  51190. * @param options defines the options used to create the mesh
  51191. * @param scene defines the hosting scene
  51192. * @returns the custom extruded shape mesh
  51193. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51194. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51195. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51196. */
  51197. static ExtrudeShapeCustom(name: string, options: {
  51198. shape: Vector3[];
  51199. path: Vector3[];
  51200. scaleFunction?: any;
  51201. rotationFunction?: any;
  51202. ribbonCloseArray?: boolean;
  51203. ribbonClosePath?: boolean;
  51204. cap?: number;
  51205. updatable?: boolean;
  51206. sideOrientation?: number;
  51207. frontUVs?: Vector4;
  51208. backUVs?: Vector4;
  51209. instance?: Mesh;
  51210. invertUV?: boolean;
  51211. }, scene: Scene): Mesh;
  51212. /**
  51213. * Creates lathe mesh.
  51214. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  51215. * * 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
  51216. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  51217. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  51218. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  51219. * * 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
  51220. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  51221. * * 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
  51222. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51223. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51224. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51226. * @param name defines the name of the mesh
  51227. * @param options defines the options used to create the mesh
  51228. * @param scene defines the hosting scene
  51229. * @returns the lathe mesh
  51230. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  51231. */
  51232. static CreateLathe(name: string, options: {
  51233. shape: Vector3[];
  51234. radius?: number;
  51235. tessellation?: number;
  51236. clip?: number;
  51237. arc?: number;
  51238. closed?: boolean;
  51239. updatable?: boolean;
  51240. sideOrientation?: number;
  51241. frontUVs?: Vector4;
  51242. backUVs?: Vector4;
  51243. cap?: number;
  51244. invertUV?: boolean;
  51245. }, scene: Scene): Mesh;
  51246. /**
  51247. * Creates a plane mesh
  51248. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  51249. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  51250. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  51251. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51252. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51254. * @param name defines the name of the mesh
  51255. * @param options defines the options used to create the mesh
  51256. * @param scene defines the hosting scene
  51257. * @returns the plane mesh
  51258. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  51259. */
  51260. static CreatePlane(name: string, options: {
  51261. size?: number;
  51262. width?: number;
  51263. height?: number;
  51264. sideOrientation?: number;
  51265. frontUVs?: Vector4;
  51266. backUVs?: Vector4;
  51267. updatable?: boolean;
  51268. sourcePlane?: Plane;
  51269. }, scene: Scene): Mesh;
  51270. /**
  51271. * Creates a ground mesh
  51272. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  51273. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  51274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51275. * @param name defines the name of the mesh
  51276. * @param options defines the options used to create the mesh
  51277. * @param scene defines the hosting scene
  51278. * @returns the ground mesh
  51279. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  51280. */
  51281. static CreateGround(name: string, options: {
  51282. width?: number;
  51283. height?: number;
  51284. subdivisions?: number;
  51285. subdivisionsX?: number;
  51286. subdivisionsY?: number;
  51287. updatable?: boolean;
  51288. }, scene: any): Mesh;
  51289. /**
  51290. * Creates a tiled ground mesh
  51291. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  51292. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  51293. * * 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
  51294. * * 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
  51295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51296. * @param name defines the name of the mesh
  51297. * @param options defines the options used to create the mesh
  51298. * @param scene defines the hosting scene
  51299. * @returns the tiled ground mesh
  51300. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  51301. */
  51302. static CreateTiledGround(name: string, options: {
  51303. xmin: number;
  51304. zmin: number;
  51305. xmax: number;
  51306. zmax: number;
  51307. subdivisions?: {
  51308. w: number;
  51309. h: number;
  51310. };
  51311. precision?: {
  51312. w: number;
  51313. h: number;
  51314. };
  51315. updatable?: boolean;
  51316. }, scene: Scene): Mesh;
  51317. /**
  51318. * Creates a ground mesh from a height map
  51319. * * The parameter `url` sets the URL of the height map image resource.
  51320. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  51321. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  51322. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  51323. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  51324. * * 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.
  51325. * * 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).
  51326. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  51327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51328. * @param name defines the name of the mesh
  51329. * @param url defines the url to the height map
  51330. * @param options defines the options used to create the mesh
  51331. * @param scene defines the hosting scene
  51332. * @returns the ground mesh
  51333. * @see https://doc.babylonjs.com/babylon101/height_map
  51334. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  51335. */
  51336. static CreateGroundFromHeightMap(name: string, url: string, options: {
  51337. width?: number;
  51338. height?: number;
  51339. subdivisions?: number;
  51340. minHeight?: number;
  51341. maxHeight?: number;
  51342. colorFilter?: Color3;
  51343. alphaFilter?: number;
  51344. updatable?: boolean;
  51345. onReady?: (mesh: GroundMesh) => void;
  51346. }, scene: Scene): GroundMesh;
  51347. /**
  51348. * Creates a polygon mesh
  51349. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  51350. * * 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
  51351. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51353. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  51354. * * Remember you can only change the shape positions, not their number when updating a polygon
  51355. * @param name defines the name of the mesh
  51356. * @param options defines the options used to create the mesh
  51357. * @param scene defines the hosting scene
  51358. * @param earcutInjection can be used to inject your own earcut reference
  51359. * @returns the polygon mesh
  51360. */
  51361. static CreatePolygon(name: string, options: {
  51362. shape: Vector3[];
  51363. holes?: Vector3[][];
  51364. depth?: number;
  51365. faceUV?: Vector4[];
  51366. faceColors?: Color4[];
  51367. updatable?: boolean;
  51368. sideOrientation?: number;
  51369. frontUVs?: Vector4;
  51370. backUVs?: Vector4;
  51371. }, scene: Scene, earcutInjection?: any): Mesh;
  51372. /**
  51373. * Creates an extruded polygon mesh, with depth in the Y direction.
  51374. * * 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)
  51375. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51376. * @param name defines the name of the mesh
  51377. * @param options defines the options used to create the mesh
  51378. * @param scene defines the hosting scene
  51379. * @param earcutInjection can be used to inject your own earcut reference
  51380. * @returns the polygon mesh
  51381. */
  51382. static ExtrudePolygon(name: string, options: {
  51383. shape: Vector3[];
  51384. holes?: Vector3[][];
  51385. depth?: number;
  51386. faceUV?: Vector4[];
  51387. faceColors?: Color4[];
  51388. updatable?: boolean;
  51389. sideOrientation?: number;
  51390. frontUVs?: Vector4;
  51391. backUVs?: Vector4;
  51392. }, scene: Scene, earcutInjection?: any): Mesh;
  51393. /**
  51394. * Creates a tube mesh.
  51395. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51396. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51397. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51398. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51399. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51400. * * 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)
  51401. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51402. * * 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
  51403. * * 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
  51404. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51405. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51406. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51408. * @param name defines the name of the mesh
  51409. * @param options defines the options used to create the mesh
  51410. * @param scene defines the hosting scene
  51411. * @returns the tube mesh
  51412. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51413. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  51414. */
  51415. static CreateTube(name: string, options: {
  51416. path: Vector3[];
  51417. radius?: number;
  51418. tessellation?: number;
  51419. radiusFunction?: {
  51420. (i: number, distance: number): number;
  51421. };
  51422. cap?: number;
  51423. arc?: number;
  51424. updatable?: boolean;
  51425. sideOrientation?: number;
  51426. frontUVs?: Vector4;
  51427. backUVs?: Vector4;
  51428. instance?: Mesh;
  51429. invertUV?: boolean;
  51430. }, scene: Scene): Mesh;
  51431. /**
  51432. * Creates a polyhedron mesh
  51433. * * 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
  51434. * * The parameter `size` (positive float, default 1) sets the polygon size
  51435. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51436. * * 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`
  51437. * * 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
  51438. * * 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)`)
  51439. * * 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
  51440. * * 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
  51441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51442. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51444. * @param name defines the name of the mesh
  51445. * @param options defines the options used to create the mesh
  51446. * @param scene defines the hosting scene
  51447. * @returns the polyhedron mesh
  51448. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51449. */
  51450. static CreatePolyhedron(name: string, options: {
  51451. type?: number;
  51452. size?: number;
  51453. sizeX?: number;
  51454. sizeY?: number;
  51455. sizeZ?: number;
  51456. custom?: any;
  51457. faceUV?: Vector4[];
  51458. faceColors?: Color4[];
  51459. flat?: boolean;
  51460. updatable?: boolean;
  51461. sideOrientation?: number;
  51462. frontUVs?: Vector4;
  51463. backUVs?: Vector4;
  51464. }, scene: Scene): Mesh;
  51465. /**
  51466. * Creates a decal mesh.
  51467. * 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
  51468. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  51469. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  51470. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  51471. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  51472. * @param name defines the name of the mesh
  51473. * @param sourceMesh defines the mesh where the decal must be applied
  51474. * @param options defines the options used to create the mesh
  51475. * @param scene defines the hosting scene
  51476. * @returns the decal mesh
  51477. * @see https://doc.babylonjs.com/how_to/decals
  51478. */
  51479. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  51480. position?: Vector3;
  51481. normal?: Vector3;
  51482. size?: Vector3;
  51483. angle?: number;
  51484. }): Mesh;
  51485. }
  51486. }
  51487. declare module "babylonjs/Meshes/meshSimplification" {
  51488. import { Mesh } from "babylonjs/Meshes/mesh";
  51489. /**
  51490. * A simplifier interface for future simplification implementations
  51491. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51492. */
  51493. export interface ISimplifier {
  51494. /**
  51495. * Simplification of a given mesh according to the given settings.
  51496. * Since this requires computation, it is assumed that the function runs async.
  51497. * @param settings The settings of the simplification, including quality and distance
  51498. * @param successCallback A callback that will be called after the mesh was simplified.
  51499. * @param errorCallback in case of an error, this callback will be called. optional.
  51500. */
  51501. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  51502. }
  51503. /**
  51504. * Expected simplification settings.
  51505. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  51506. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51507. */
  51508. export interface ISimplificationSettings {
  51509. /**
  51510. * Gets or sets the expected quality
  51511. */
  51512. quality: number;
  51513. /**
  51514. * Gets or sets the distance when this optimized version should be used
  51515. */
  51516. distance: number;
  51517. /**
  51518. * Gets an already optimized mesh
  51519. */
  51520. optimizeMesh?: boolean;
  51521. }
  51522. /**
  51523. * Class used to specify simplification options
  51524. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51525. */
  51526. export class SimplificationSettings implements ISimplificationSettings {
  51527. /** expected quality */
  51528. quality: number;
  51529. /** distance when this optimized version should be used */
  51530. distance: number;
  51531. /** already optimized mesh */
  51532. optimizeMesh?: boolean | undefined;
  51533. /**
  51534. * Creates a SimplificationSettings
  51535. * @param quality expected quality
  51536. * @param distance distance when this optimized version should be used
  51537. * @param optimizeMesh already optimized mesh
  51538. */
  51539. constructor(
  51540. /** expected quality */
  51541. quality: number,
  51542. /** distance when this optimized version should be used */
  51543. distance: number,
  51544. /** already optimized mesh */
  51545. optimizeMesh?: boolean | undefined);
  51546. }
  51547. /**
  51548. * Interface used to define a simplification task
  51549. */
  51550. export interface ISimplificationTask {
  51551. /**
  51552. * Array of settings
  51553. */
  51554. settings: Array<ISimplificationSettings>;
  51555. /**
  51556. * Simplification type
  51557. */
  51558. simplificationType: SimplificationType;
  51559. /**
  51560. * Mesh to simplify
  51561. */
  51562. mesh: Mesh;
  51563. /**
  51564. * Callback called on success
  51565. */
  51566. successCallback?: () => void;
  51567. /**
  51568. * Defines if parallel processing can be used
  51569. */
  51570. parallelProcessing: boolean;
  51571. }
  51572. /**
  51573. * Queue used to order the simplification tasks
  51574. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51575. */
  51576. export class SimplificationQueue {
  51577. private _simplificationArray;
  51578. /**
  51579. * Gets a boolean indicating that the process is still running
  51580. */
  51581. running: boolean;
  51582. /**
  51583. * Creates a new queue
  51584. */
  51585. constructor();
  51586. /**
  51587. * Adds a new simplification task
  51588. * @param task defines a task to add
  51589. */
  51590. addTask(task: ISimplificationTask): void;
  51591. /**
  51592. * Execute next task
  51593. */
  51594. executeNext(): void;
  51595. /**
  51596. * Execute a simplification task
  51597. * @param task defines the task to run
  51598. */
  51599. runSimplification(task: ISimplificationTask): void;
  51600. private getSimplifier;
  51601. }
  51602. /**
  51603. * The implemented types of simplification
  51604. * At the moment only Quadratic Error Decimation is implemented
  51605. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51606. */
  51607. export enum SimplificationType {
  51608. /** Quadratic error decimation */
  51609. QUADRATIC = 0
  51610. }
  51611. }
  51612. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  51613. import { Scene } from "babylonjs/scene";
  51614. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  51615. import { ISceneComponent } from "babylonjs/sceneComponent";
  51616. module "babylonjs/scene" {
  51617. interface Scene {
  51618. /** @hidden (Backing field) */
  51619. _simplificationQueue: SimplificationQueue;
  51620. /**
  51621. * Gets or sets the simplification queue attached to the scene
  51622. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51623. */
  51624. simplificationQueue: SimplificationQueue;
  51625. }
  51626. }
  51627. module "babylonjs/Meshes/mesh" {
  51628. interface Mesh {
  51629. /**
  51630. * Simplify the mesh according to the given array of settings.
  51631. * Function will return immediately and will simplify async
  51632. * @param settings a collection of simplification settings
  51633. * @param parallelProcessing should all levels calculate parallel or one after the other
  51634. * @param simplificationType the type of simplification to run
  51635. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  51636. * @returns the current mesh
  51637. */
  51638. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  51639. }
  51640. }
  51641. /**
  51642. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  51643. * created in a scene
  51644. */
  51645. export class SimplicationQueueSceneComponent implements ISceneComponent {
  51646. /**
  51647. * The component name helpfull to identify the component in the list of scene components.
  51648. */
  51649. readonly name: string;
  51650. /**
  51651. * The scene the component belongs to.
  51652. */
  51653. scene: Scene;
  51654. /**
  51655. * Creates a new instance of the component for the given scene
  51656. * @param scene Defines the scene to register the component in
  51657. */
  51658. constructor(scene: Scene);
  51659. /**
  51660. * Registers the component in a given scene
  51661. */
  51662. register(): void;
  51663. /**
  51664. * Rebuilds the elements related to this component in case of
  51665. * context lost for instance.
  51666. */
  51667. rebuild(): void;
  51668. /**
  51669. * Disposes the component and the associated ressources
  51670. */
  51671. dispose(): void;
  51672. private _beforeCameraUpdate;
  51673. }
  51674. }
  51675. declare module "babylonjs/Meshes/Builders/index" {
  51676. export * from "babylonjs/Meshes/Builders/boxBuilder";
  51677. export * from "babylonjs/Meshes/Builders/discBuilder";
  51678. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  51679. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  51680. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  51681. export * from "babylonjs/Meshes/Builders/torusBuilder";
  51682. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  51683. export * from "babylonjs/Meshes/Builders/linesBuilder";
  51684. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  51685. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  51686. export * from "babylonjs/Meshes/Builders/latheBuilder";
  51687. export * from "babylonjs/Meshes/Builders/planeBuilder";
  51688. export * from "babylonjs/Meshes/Builders/groundBuilder";
  51689. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  51690. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  51691. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  51692. export * from "babylonjs/Meshes/Builders/decalBuilder";
  51693. }
  51694. declare module "babylonjs/Meshes/index" {
  51695. export * from "babylonjs/Meshes/abstractMesh";
  51696. export * from "babylonjs/Meshes/buffer";
  51697. export * from "babylonjs/Meshes/Compression/index";
  51698. export * from "babylonjs/Meshes/csg";
  51699. export * from "babylonjs/Meshes/geometry";
  51700. export * from "babylonjs/Meshes/groundMesh";
  51701. export * from "babylonjs/Meshes/trailMesh";
  51702. export * from "babylonjs/Meshes/instancedMesh";
  51703. export * from "babylonjs/Meshes/linesMesh";
  51704. export * from "babylonjs/Meshes/mesh";
  51705. export * from "babylonjs/Meshes/mesh.vertexData";
  51706. export * from "babylonjs/Meshes/meshBuilder";
  51707. export * from "babylonjs/Meshes/meshSimplification";
  51708. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  51709. export * from "babylonjs/Meshes/polygonMesh";
  51710. export * from "babylonjs/Meshes/subMesh";
  51711. export * from "babylonjs/Meshes/transformNode";
  51712. export * from "babylonjs/Meshes/Builders/index";
  51713. }
  51714. declare module "babylonjs/Morph/index" {
  51715. export * from "babylonjs/Morph/morphTarget";
  51716. export * from "babylonjs/Morph/morphTargetManager";
  51717. }
  51718. declare module "babylonjs/Offline/database" {
  51719. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  51720. /**
  51721. * Class used to enable access to IndexedDB
  51722. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  51723. */
  51724. export class Database implements IOfflineProvider {
  51725. private _callbackManifestChecked;
  51726. private _currentSceneUrl;
  51727. private _db;
  51728. private _enableSceneOffline;
  51729. private _enableTexturesOffline;
  51730. private _manifestVersionFound;
  51731. private _mustUpdateRessources;
  51732. private _hasReachedQuota;
  51733. private _isSupported;
  51734. private _idbFactory;
  51735. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51736. private static IsUASupportingBlobStorage;
  51737. /**
  51738. * Gets a boolean indicating if Database storate is enabled (off by default)
  51739. */
  51740. static IDBStorageEnabled: boolean;
  51741. /**
  51742. * Gets a boolean indicating if scene must be saved in the database
  51743. */
  51744. readonly enableSceneOffline: boolean;
  51745. /**
  51746. * Gets a boolean indicating if textures must be saved in the database
  51747. */
  51748. readonly enableTexturesOffline: boolean;
  51749. /**
  51750. * Creates a new Database
  51751. * @param urlToScene defines the url to load the scene
  51752. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51753. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51754. */
  51755. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51756. private static _ParseURL;
  51757. private static _ReturnFullUrlLocation;
  51758. private _checkManifestFile;
  51759. /**
  51760. * Open the database and make it available
  51761. * @param successCallback defines the callback to call on success
  51762. * @param errorCallback defines the callback to call on error
  51763. */
  51764. open(successCallback: () => void, errorCallback: () => void): void;
  51765. /**
  51766. * Loads an image from the database
  51767. * @param url defines the url to load from
  51768. * @param image defines the target DOM image
  51769. */
  51770. loadImage(url: string, image: HTMLImageElement): void;
  51771. private _loadImageFromDBAsync;
  51772. private _saveImageIntoDBAsync;
  51773. private _checkVersionFromDB;
  51774. private _loadVersionFromDBAsync;
  51775. private _saveVersionIntoDBAsync;
  51776. /**
  51777. * Loads a file from database
  51778. * @param url defines the URL to load from
  51779. * @param sceneLoaded defines a callback to call on success
  51780. * @param progressCallBack defines a callback to call when progress changed
  51781. * @param errorCallback defines a callback to call on error
  51782. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  51783. */
  51784. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  51785. private _loadFileAsync;
  51786. private _saveFileAsync;
  51787. /**
  51788. * Validates if xhr data is correct
  51789. * @param xhr defines the request to validate
  51790. * @param dataType defines the expected data type
  51791. * @returns true if data is correct
  51792. */
  51793. private static _ValidateXHRData;
  51794. }
  51795. }
  51796. declare module "babylonjs/Offline/index" {
  51797. export * from "babylonjs/Offline/database";
  51798. export * from "babylonjs/Offline/IOfflineProvider";
  51799. }
  51800. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  51801. /** @hidden */
  51802. export var gpuUpdateParticlesPixelShader: {
  51803. name: string;
  51804. shader: string;
  51805. };
  51806. }
  51807. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  51808. /** @hidden */
  51809. export var gpuUpdateParticlesVertexShader: {
  51810. name: string;
  51811. shader: string;
  51812. };
  51813. }
  51814. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  51815. /** @hidden */
  51816. export var clipPlaneFragmentDeclaration2: {
  51817. name: string;
  51818. shader: string;
  51819. };
  51820. }
  51821. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  51822. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  51823. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51824. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51825. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51826. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51827. /** @hidden */
  51828. export var gpuRenderParticlesPixelShader: {
  51829. name: string;
  51830. shader: string;
  51831. };
  51832. }
  51833. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  51834. /** @hidden */
  51835. export var clipPlaneVertexDeclaration2: {
  51836. name: string;
  51837. shader: string;
  51838. };
  51839. }
  51840. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  51841. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  51842. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51843. /** @hidden */
  51844. export var gpuRenderParticlesVertexShader: {
  51845. name: string;
  51846. shader: string;
  51847. };
  51848. }
  51849. declare module "babylonjs/Particles/gpuParticleSystem" {
  51850. import { Nullable } from "babylonjs/types";
  51851. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  51852. import { Observable } from "babylonjs/Misc/observable";
  51853. import { Color4, Color3 } from "babylonjs/Maths/math";
  51854. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  51855. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  51856. import { Scene, IDisposable } from "babylonjs/scene";
  51857. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  51858. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  51859. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  51860. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  51861. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  51862. /**
  51863. * This represents a GPU particle system in Babylon
  51864. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51865. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51866. */
  51867. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51868. /**
  51869. * The layer mask we are rendering the particles through.
  51870. */
  51871. layerMask: number;
  51872. private _capacity;
  51873. private _activeCount;
  51874. private _currentActiveCount;
  51875. private _accumulatedCount;
  51876. private _renderEffect;
  51877. private _updateEffect;
  51878. private _buffer0;
  51879. private _buffer1;
  51880. private _spriteBuffer;
  51881. private _updateVAO;
  51882. private _renderVAO;
  51883. private _targetIndex;
  51884. private _sourceBuffer;
  51885. private _targetBuffer;
  51886. private _engine;
  51887. private _currentRenderId;
  51888. private _started;
  51889. private _stopped;
  51890. private _timeDelta;
  51891. private _randomTexture;
  51892. private _randomTexture2;
  51893. private _attributesStrideSize;
  51894. private _updateEffectOptions;
  51895. private _randomTextureSize;
  51896. private _actualFrame;
  51897. private readonly _rawTextureWidth;
  51898. /**
  51899. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  51900. */
  51901. static readonly IsSupported: boolean;
  51902. /**
  51903. * An event triggered when the system is disposed.
  51904. */
  51905. onDisposeObservable: Observable<GPUParticleSystem>;
  51906. /**
  51907. * Gets the maximum number of particles active at the same time.
  51908. * @returns The max number of active particles.
  51909. */
  51910. getCapacity(): number;
  51911. /**
  51912. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  51913. * to override the particles.
  51914. */
  51915. forceDepthWrite: boolean;
  51916. /**
  51917. * Gets or set the number of active particles
  51918. */
  51919. activeParticleCount: number;
  51920. private _preWarmDone;
  51921. /**
  51922. * Is this system ready to be used/rendered
  51923. * @return true if the system is ready
  51924. */
  51925. isReady(): boolean;
  51926. /**
  51927. * Gets if the system has been started. (Note: this will still be true after stop is called)
  51928. * @returns True if it has been started, otherwise false.
  51929. */
  51930. isStarted(): boolean;
  51931. /**
  51932. * Starts the particle system and begins to emit
  51933. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  51934. */
  51935. start(delay?: number): void;
  51936. /**
  51937. * Stops the particle system.
  51938. */
  51939. stop(): void;
  51940. /**
  51941. * Remove all active particles
  51942. */
  51943. reset(): void;
  51944. /**
  51945. * Returns the string "GPUParticleSystem"
  51946. * @returns a string containing the class name
  51947. */
  51948. getClassName(): string;
  51949. private _colorGradientsTexture;
  51950. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  51951. /**
  51952. * Adds a new color gradient
  51953. * @param gradient defines the gradient to use (between 0 and 1)
  51954. * @param color1 defines the color to affect to the specified gradient
  51955. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  51956. * @returns the current particle system
  51957. */
  51958. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  51959. /**
  51960. * Remove a specific color gradient
  51961. * @param gradient defines the gradient to remove
  51962. * @returns the current particle system
  51963. */
  51964. removeColorGradient(gradient: number): GPUParticleSystem;
  51965. private _angularSpeedGradientsTexture;
  51966. private _sizeGradientsTexture;
  51967. private _velocityGradientsTexture;
  51968. private _limitVelocityGradientsTexture;
  51969. private _dragGradientsTexture;
  51970. private _addFactorGradient;
  51971. /**
  51972. * Adds a new size gradient
  51973. * @param gradient defines the gradient to use (between 0 and 1)
  51974. * @param factor defines the size factor to affect to the specified gradient
  51975. * @returns the current particle system
  51976. */
  51977. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  51978. /**
  51979. * Remove a specific size gradient
  51980. * @param gradient defines the gradient to remove
  51981. * @returns the current particle system
  51982. */
  51983. removeSizeGradient(gradient: number): GPUParticleSystem;
  51984. /**
  51985. * Adds a new angular speed gradient
  51986. * @param gradient defines the gradient to use (between 0 and 1)
  51987. * @param factor defines the angular speed to affect to the specified gradient
  51988. * @returns the current particle system
  51989. */
  51990. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  51991. /**
  51992. * Remove a specific angular speed gradient
  51993. * @param gradient defines the gradient to remove
  51994. * @returns the current particle system
  51995. */
  51996. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  51997. /**
  51998. * Adds a new velocity gradient
  51999. * @param gradient defines the gradient to use (between 0 and 1)
  52000. * @param factor defines the velocity to affect to the specified gradient
  52001. * @returns the current particle system
  52002. */
  52003. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  52004. /**
  52005. * Remove a specific velocity gradient
  52006. * @param gradient defines the gradient to remove
  52007. * @returns the current particle system
  52008. */
  52009. removeVelocityGradient(gradient: number): GPUParticleSystem;
  52010. /**
  52011. * Adds a new limit velocity gradient
  52012. * @param gradient defines the gradient to use (between 0 and 1)
  52013. * @param factor defines the limit velocity value to affect to the specified gradient
  52014. * @returns the current particle system
  52015. */
  52016. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  52017. /**
  52018. * Remove a specific limit velocity gradient
  52019. * @param gradient defines the gradient to remove
  52020. * @returns the current particle system
  52021. */
  52022. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  52023. /**
  52024. * Adds a new drag gradient
  52025. * @param gradient defines the gradient to use (between 0 and 1)
  52026. * @param factor defines the drag value to affect to the specified gradient
  52027. * @returns the current particle system
  52028. */
  52029. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  52030. /**
  52031. * Remove a specific drag gradient
  52032. * @param gradient defines the gradient to remove
  52033. * @returns the current particle system
  52034. */
  52035. removeDragGradient(gradient: number): GPUParticleSystem;
  52036. /**
  52037. * Not supported by GPUParticleSystem
  52038. * @param gradient defines the gradient to use (between 0 and 1)
  52039. * @param factor defines the emit rate value to affect to the specified gradient
  52040. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52041. * @returns the current particle system
  52042. */
  52043. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52044. /**
  52045. * Not supported by GPUParticleSystem
  52046. * @param gradient defines the gradient to remove
  52047. * @returns the current particle system
  52048. */
  52049. removeEmitRateGradient(gradient: number): IParticleSystem;
  52050. /**
  52051. * Not supported by GPUParticleSystem
  52052. * @param gradient defines the gradient to use (between 0 and 1)
  52053. * @param factor defines the start size value to affect to the specified gradient
  52054. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52055. * @returns the current particle system
  52056. */
  52057. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52058. /**
  52059. * Not supported by GPUParticleSystem
  52060. * @param gradient defines the gradient to remove
  52061. * @returns the current particle system
  52062. */
  52063. removeStartSizeGradient(gradient: number): IParticleSystem;
  52064. /**
  52065. * Not supported by GPUParticleSystem
  52066. * @param gradient defines the gradient to use (between 0 and 1)
  52067. * @param min defines the color remap minimal range
  52068. * @param max defines the color remap maximal range
  52069. * @returns the current particle system
  52070. */
  52071. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  52072. /**
  52073. * Not supported by GPUParticleSystem
  52074. * @param gradient defines the gradient to remove
  52075. * @returns the current particle system
  52076. */
  52077. removeColorRemapGradient(): IParticleSystem;
  52078. /**
  52079. * Not supported by GPUParticleSystem
  52080. * @param gradient defines the gradient to use (between 0 and 1)
  52081. * @param min defines the alpha remap minimal range
  52082. * @param max defines the alpha remap maximal range
  52083. * @returns the current particle system
  52084. */
  52085. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  52086. /**
  52087. * Not supported by GPUParticleSystem
  52088. * @param gradient defines the gradient to remove
  52089. * @returns the current particle system
  52090. */
  52091. removeAlphaRemapGradient(): IParticleSystem;
  52092. /**
  52093. * Not supported by GPUParticleSystem
  52094. * @param gradient defines the gradient to use (between 0 and 1)
  52095. * @param color defines the color to affect to the specified gradient
  52096. * @returns the current particle system
  52097. */
  52098. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  52099. /**
  52100. * Not supported by GPUParticleSystem
  52101. * @param gradient defines the gradient to remove
  52102. * @returns the current particle system
  52103. */
  52104. removeRampGradient(): IParticleSystem;
  52105. /**
  52106. * Not supported by GPUParticleSystem
  52107. * @returns the list of ramp gradients
  52108. */
  52109. getRampGradients(): Nullable<Array<Color3Gradient>>;
  52110. /**
  52111. * Not supported by GPUParticleSystem
  52112. * Gets or sets a boolean indicating that ramp gradients must be used
  52113. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  52114. */
  52115. useRampGradients: boolean;
  52116. /**
  52117. * Not supported by GPUParticleSystem
  52118. * @param gradient defines the gradient to use (between 0 and 1)
  52119. * @param factor defines the life time factor to affect to the specified gradient
  52120. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52121. * @returns the current particle system
  52122. */
  52123. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52124. /**
  52125. * Not supported by GPUParticleSystem
  52126. * @param gradient defines the gradient to remove
  52127. * @returns the current particle system
  52128. */
  52129. removeLifeTimeGradient(gradient: number): IParticleSystem;
  52130. /**
  52131. * Instantiates a GPU particle system.
  52132. * 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.
  52133. * @param name The name of the particle system
  52134. * @param options The options used to create the system
  52135. * @param scene The scene the particle system belongs to
  52136. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  52137. */
  52138. constructor(name: string, options: Partial<{
  52139. capacity: number;
  52140. randomTextureSize: number;
  52141. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  52142. protected _reset(): void;
  52143. private _createUpdateVAO;
  52144. private _createRenderVAO;
  52145. private _initialize;
  52146. /** @hidden */
  52147. _recreateUpdateEffect(): void;
  52148. /** @hidden */
  52149. _recreateRenderEffect(): void;
  52150. /**
  52151. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  52152. * @param preWarm defines if we are in the pre-warmimg phase
  52153. */
  52154. animate(preWarm?: boolean): void;
  52155. private _createFactorGradientTexture;
  52156. private _createSizeGradientTexture;
  52157. private _createAngularSpeedGradientTexture;
  52158. private _createVelocityGradientTexture;
  52159. private _createLimitVelocityGradientTexture;
  52160. private _createDragGradientTexture;
  52161. private _createColorGradientTexture;
  52162. /**
  52163. * Renders the particle system in its current state
  52164. * @param preWarm defines if the system should only update the particles but not render them
  52165. * @returns the current number of particles
  52166. */
  52167. render(preWarm?: boolean): number;
  52168. /**
  52169. * Rebuilds the particle system
  52170. */
  52171. rebuild(): void;
  52172. private _releaseBuffers;
  52173. private _releaseVAOs;
  52174. /**
  52175. * Disposes the particle system and free the associated resources
  52176. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  52177. */
  52178. dispose(disposeTexture?: boolean): void;
  52179. /**
  52180. * Clones the particle system.
  52181. * @param name The name of the cloned object
  52182. * @param newEmitter The new emitter to use
  52183. * @returns the cloned particle system
  52184. */
  52185. clone(name: string, newEmitter: any): GPUParticleSystem;
  52186. /**
  52187. * Serializes the particle system to a JSON object.
  52188. * @returns the JSON object
  52189. */
  52190. serialize(): any;
  52191. /**
  52192. * Parses a JSON object to create a GPU particle system.
  52193. * @param parsedParticleSystem The JSON object to parse
  52194. * @param scene The scene to create the particle system in
  52195. * @param rootUrl The root url to use to load external dependencies like texture
  52196. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  52197. * @returns the parsed GPU particle system
  52198. */
  52199. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  52200. }
  52201. }
  52202. declare module "babylonjs/Particles/particleSystemSet" {
  52203. import { Nullable } from "babylonjs/types";
  52204. import { Color3 } from "babylonjs/Maths/math";
  52205. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52207. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52208. import { Scene, IDisposable } from "babylonjs/scene";
  52209. /**
  52210. * Represents a set of particle systems working together to create a specific effect
  52211. */
  52212. export class ParticleSystemSet implements IDisposable {
  52213. private _emitterCreationOptions;
  52214. private _emitterNode;
  52215. /**
  52216. * Gets the particle system list
  52217. */
  52218. systems: IParticleSystem[];
  52219. /**
  52220. * Gets the emitter node used with this set
  52221. */
  52222. readonly emitterNode: Nullable<TransformNode>;
  52223. /**
  52224. * Creates a new emitter mesh as a sphere
  52225. * @param options defines the options used to create the sphere
  52226. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  52227. * @param scene defines the hosting scene
  52228. */
  52229. setEmitterAsSphere(options: {
  52230. diameter: number;
  52231. segments: number;
  52232. color: Color3;
  52233. }, renderingGroupId: number, scene: Scene): void;
  52234. /**
  52235. * Starts all particle systems of the set
  52236. * @param emitter defines an optional mesh to use as emitter for the particle systems
  52237. */
  52238. start(emitter?: AbstractMesh): void;
  52239. /**
  52240. * Release all associated resources
  52241. */
  52242. dispose(): void;
  52243. /**
  52244. * Serialize the set into a JSON compatible object
  52245. * @returns a JSON compatible representation of the set
  52246. */
  52247. serialize(): any;
  52248. /**
  52249. * Parse a new ParticleSystemSet from a serialized source
  52250. * @param data defines a JSON compatible representation of the set
  52251. * @param scene defines the hosting scene
  52252. * @param gpu defines if we want GPU particles or CPU particles
  52253. * @returns a new ParticleSystemSet
  52254. */
  52255. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  52256. }
  52257. }
  52258. declare module "babylonjs/Particles/particleHelper" {
  52259. import { Nullable } from "babylonjs/types";
  52260. import { Scene } from "babylonjs/scene";
  52261. import { Vector3 } from "babylonjs/Maths/math";
  52262. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52263. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52264. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  52265. /**
  52266. * This class is made for on one-liner static method to help creating particle system set.
  52267. */
  52268. export class ParticleHelper {
  52269. /**
  52270. * Gets or sets base Assets URL
  52271. */
  52272. static BaseAssetsUrl: string;
  52273. /**
  52274. * Create a default particle system that you can tweak
  52275. * @param emitter defines the emitter to use
  52276. * @param capacity defines the system capacity (default is 500 particles)
  52277. * @param scene defines the hosting scene
  52278. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  52279. * @returns the new Particle system
  52280. */
  52281. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  52282. /**
  52283. * This is the main static method (one-liner) of this helper to create different particle systems
  52284. * @param type This string represents the type to the particle system to create
  52285. * @param scene The scene where the particle system should live
  52286. * @param gpu If the system will use gpu
  52287. * @returns the ParticleSystemSet created
  52288. */
  52289. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  52290. /**
  52291. * Static function used to export a particle system to a ParticleSystemSet variable.
  52292. * Please note that the emitter shape is not exported
  52293. * @param systems defines the particle systems to export
  52294. * @returns the created particle system set
  52295. */
  52296. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  52297. }
  52298. }
  52299. declare module "babylonjs/Particles/particleSystemComponent" {
  52300. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52301. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  52302. import "babylonjs/Shaders/particles.vertex";
  52303. module "babylonjs/Engines/engine" {
  52304. interface Engine {
  52305. /**
  52306. * Create an effect to use with particle systems.
  52307. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  52308. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  52309. * @param uniformsNames defines a list of attribute names
  52310. * @param samplers defines an array of string used to represent textures
  52311. * @param defines defines the string containing the defines to use to compile the shaders
  52312. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  52313. * @param onCompiled defines a function to call when the effect creation is successful
  52314. * @param onError defines a function to call when the effect creation has failed
  52315. * @returns the new Effect
  52316. */
  52317. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  52318. }
  52319. }
  52320. module "babylonjs/Meshes/mesh" {
  52321. interface Mesh {
  52322. /**
  52323. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  52324. * @returns an array of IParticleSystem
  52325. */
  52326. getEmittedParticleSystems(): IParticleSystem[];
  52327. /**
  52328. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  52329. * @returns an array of IParticleSystem
  52330. */
  52331. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  52332. }
  52333. }
  52334. /**
  52335. * @hidden
  52336. */
  52337. export var _IDoNeedToBeInTheBuild: number;
  52338. }
  52339. declare module "babylonjs/Particles/index" {
  52340. export * from "babylonjs/Particles/baseParticleSystem";
  52341. export * from "babylonjs/Particles/EmitterTypes/index";
  52342. export * from "babylonjs/Particles/gpuParticleSystem";
  52343. export * from "babylonjs/Particles/IParticleSystem";
  52344. export * from "babylonjs/Particles/particle";
  52345. export * from "babylonjs/Particles/particleHelper";
  52346. export * from "babylonjs/Particles/particleSystem";
  52347. export * from "babylonjs/Particles/particleSystemComponent";
  52348. export * from "babylonjs/Particles/particleSystemSet";
  52349. export * from "babylonjs/Particles/solidParticle";
  52350. export * from "babylonjs/Particles/solidParticleSystem";
  52351. export * from "babylonjs/Particles/subEmitter";
  52352. }
  52353. declare module "babylonjs/Physics/physicsEngineComponent" {
  52354. import { Nullable } from "babylonjs/types";
  52355. import { Observable, Observer } from "babylonjs/Misc/observable";
  52356. import { Vector3 } from "babylonjs/Maths/math";
  52357. import { Mesh } from "babylonjs/Meshes/mesh";
  52358. import { ISceneComponent } from "babylonjs/sceneComponent";
  52359. import { Scene } from "babylonjs/scene";
  52360. import { Node } from "babylonjs/node";
  52361. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52362. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52363. module "babylonjs/scene" {
  52364. interface Scene {
  52365. /** @hidden (Backing field) */
  52366. _physicsEngine: Nullable<IPhysicsEngine>;
  52367. /**
  52368. * Gets the current physics engine
  52369. * @returns a IPhysicsEngine or null if none attached
  52370. */
  52371. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  52372. /**
  52373. * Enables physics to the current scene
  52374. * @param gravity defines the scene's gravity for the physics engine
  52375. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  52376. * @return a boolean indicating if the physics engine was initialized
  52377. */
  52378. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  52379. /**
  52380. * Disables and disposes the physics engine associated with the scene
  52381. */
  52382. disablePhysicsEngine(): void;
  52383. /**
  52384. * Gets a boolean indicating if there is an active physics engine
  52385. * @returns a boolean indicating if there is an active physics engine
  52386. */
  52387. isPhysicsEnabled(): boolean;
  52388. /**
  52389. * Deletes a physics compound impostor
  52390. * @param compound defines the compound to delete
  52391. */
  52392. deleteCompoundImpostor(compound: any): void;
  52393. /**
  52394. * An event triggered when physic simulation is about to be run
  52395. */
  52396. onBeforePhysicsObservable: Observable<Scene>;
  52397. /**
  52398. * An event triggered when physic simulation has been done
  52399. */
  52400. onAfterPhysicsObservable: Observable<Scene>;
  52401. }
  52402. }
  52403. module "babylonjs/Meshes/abstractMesh" {
  52404. interface AbstractMesh {
  52405. /** @hidden */
  52406. _physicsImpostor: Nullable<PhysicsImpostor>;
  52407. /**
  52408. * Gets or sets impostor used for physic simulation
  52409. * @see http://doc.babylonjs.com/features/physics_engine
  52410. */
  52411. physicsImpostor: Nullable<PhysicsImpostor>;
  52412. /**
  52413. * Gets the current physics impostor
  52414. * @see http://doc.babylonjs.com/features/physics_engine
  52415. * @returns a physics impostor or null
  52416. */
  52417. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  52418. /** Apply a physic impulse to the mesh
  52419. * @param force defines the force to apply
  52420. * @param contactPoint defines where to apply the force
  52421. * @returns the current mesh
  52422. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52423. */
  52424. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  52425. /**
  52426. * Creates a physic joint between two meshes
  52427. * @param otherMesh defines the other mesh to use
  52428. * @param pivot1 defines the pivot to use on this mesh
  52429. * @param pivot2 defines the pivot to use on the other mesh
  52430. * @param options defines additional options (can be plugin dependent)
  52431. * @returns the current mesh
  52432. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  52433. */
  52434. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  52435. /** @hidden */
  52436. _disposePhysicsObserver: Nullable<Observer<Node>>;
  52437. }
  52438. }
  52439. /**
  52440. * Defines the physics engine scene component responsible to manage a physics engine
  52441. */
  52442. export class PhysicsEngineSceneComponent implements ISceneComponent {
  52443. /**
  52444. * The component name helpful to identify the component in the list of scene components.
  52445. */
  52446. readonly name: string;
  52447. /**
  52448. * The scene the component belongs to.
  52449. */
  52450. scene: Scene;
  52451. /**
  52452. * Creates a new instance of the component for the given scene
  52453. * @param scene Defines the scene to register the component in
  52454. */
  52455. constructor(scene: Scene);
  52456. /**
  52457. * Registers the component in a given scene
  52458. */
  52459. register(): void;
  52460. /**
  52461. * Rebuilds the elements related to this component in case of
  52462. * context lost for instance.
  52463. */
  52464. rebuild(): void;
  52465. /**
  52466. * Disposes the component and the associated ressources
  52467. */
  52468. dispose(): void;
  52469. }
  52470. }
  52471. declare module "babylonjs/Physics/physicsHelper" {
  52472. import { Nullable } from "babylonjs/types";
  52473. import { Vector3 } from "babylonjs/Maths/math";
  52474. import { Mesh } from "babylonjs/Meshes/mesh";
  52475. import { Scene } from "babylonjs/scene";
  52476. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52477. /**
  52478. * A helper for physics simulations
  52479. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52480. */
  52481. export class PhysicsHelper {
  52482. private _scene;
  52483. private _physicsEngine;
  52484. /**
  52485. * Initializes the Physics helper
  52486. * @param scene Babylon.js scene
  52487. */
  52488. constructor(scene: Scene);
  52489. /**
  52490. * Applies a radial explosion impulse
  52491. * @param origin the origin of the explosion
  52492. * @param radiusOrEventOptions the radius or the options of radial explosion
  52493. * @param strength the explosion strength
  52494. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52495. * @returns A physics radial explosion event, or null
  52496. */
  52497. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52498. /**
  52499. * Applies a radial explosion force
  52500. * @param origin the origin of the explosion
  52501. * @param radiusOrEventOptions the radius or the options of radial explosion
  52502. * @param strength the explosion strength
  52503. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52504. * @returns A physics radial explosion event, or null
  52505. */
  52506. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52507. /**
  52508. * Creates a gravitational field
  52509. * @param origin the origin of the explosion
  52510. * @param radiusOrEventOptions the radius or the options of radial explosion
  52511. * @param strength the explosion strength
  52512. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52513. * @returns A physics gravitational field event, or null
  52514. */
  52515. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  52516. /**
  52517. * Creates a physics updraft event
  52518. * @param origin the origin of the updraft
  52519. * @param radiusOrEventOptions the radius or the options of the updraft
  52520. * @param strength the strength of the updraft
  52521. * @param height the height of the updraft
  52522. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  52523. * @returns A physics updraft event, or null
  52524. */
  52525. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  52526. /**
  52527. * Creates a physics vortex event
  52528. * @param origin the of the vortex
  52529. * @param radiusOrEventOptions the radius or the options of the vortex
  52530. * @param strength the strength of the vortex
  52531. * @param height the height of the vortex
  52532. * @returns a Physics vortex event, or null
  52533. * A physics vortex event or null
  52534. */
  52535. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  52536. }
  52537. /**
  52538. * Represents a physics radial explosion event
  52539. */
  52540. class PhysicsRadialExplosionEvent {
  52541. private _scene;
  52542. private _options;
  52543. private _sphere;
  52544. private _dataFetched;
  52545. /**
  52546. * Initializes a radial explosioin event
  52547. * @param _scene BabylonJS scene
  52548. * @param _options The options for the vortex event
  52549. */
  52550. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  52551. /**
  52552. * Returns the data related to the radial explosion event (sphere).
  52553. * @returns The radial explosion event data
  52554. */
  52555. getData(): PhysicsRadialExplosionEventData;
  52556. /**
  52557. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  52558. * @param impostor A physics imposter
  52559. * @param origin the origin of the explosion
  52560. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  52561. */
  52562. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsForceAndContactPoint>;
  52563. /**
  52564. * Disposes the sphere.
  52565. * @param force Specifies if the sphere should be disposed by force
  52566. */
  52567. dispose(force?: boolean): void;
  52568. /*** Helpers ***/
  52569. private _prepareSphere;
  52570. private _intersectsWithSphere;
  52571. }
  52572. /**
  52573. * Represents a gravitational field event
  52574. */
  52575. class PhysicsGravitationalFieldEvent {
  52576. private _physicsHelper;
  52577. private _scene;
  52578. private _origin;
  52579. private _options;
  52580. private _tickCallback;
  52581. private _sphere;
  52582. private _dataFetched;
  52583. /**
  52584. * Initializes the physics gravitational field event
  52585. * @param _physicsHelper A physics helper
  52586. * @param _scene BabylonJS scene
  52587. * @param _origin The origin position of the gravitational field event
  52588. * @param _options The options for the vortex event
  52589. */
  52590. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  52591. /**
  52592. * Returns the data related to the gravitational field event (sphere).
  52593. * @returns A gravitational field event
  52594. */
  52595. getData(): PhysicsGravitationalFieldEventData;
  52596. /**
  52597. * Enables the gravitational field.
  52598. */
  52599. enable(): void;
  52600. /**
  52601. * Disables the gravitational field.
  52602. */
  52603. disable(): void;
  52604. /**
  52605. * Disposes the sphere.
  52606. * @param force The force to dispose from the gravitational field event
  52607. */
  52608. dispose(force?: boolean): void;
  52609. private _tick;
  52610. }
  52611. /**
  52612. * Represents a physics updraft event
  52613. */
  52614. class PhysicsUpdraftEvent {
  52615. private _scene;
  52616. private _origin;
  52617. private _options;
  52618. private _physicsEngine;
  52619. private _originTop;
  52620. private _originDirection;
  52621. private _tickCallback;
  52622. private _cylinder;
  52623. private _cylinderPosition;
  52624. private _dataFetched;
  52625. /**
  52626. * Initializes the physics updraft event
  52627. * @param _scene BabylonJS scene
  52628. * @param _origin The origin position of the updraft
  52629. * @param _options The options for the updraft event
  52630. */
  52631. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  52632. /**
  52633. * Returns the data related to the updraft event (cylinder).
  52634. * @returns A physics updraft event
  52635. */
  52636. getData(): PhysicsUpdraftEventData;
  52637. /**
  52638. * Enables the updraft.
  52639. */
  52640. enable(): void;
  52641. /**
  52642. * Disables the updraft.
  52643. */
  52644. disable(): void;
  52645. /**
  52646. * Disposes the cylinder.
  52647. * @param force Specifies if the updraft should be disposed by force
  52648. */
  52649. dispose(force?: boolean): void;
  52650. private getImpostorForceAndContactPoint;
  52651. private _tick;
  52652. /*** Helpers ***/
  52653. private _prepareCylinder;
  52654. private _intersectsWithCylinder;
  52655. }
  52656. /**
  52657. * Represents a physics vortex event
  52658. */
  52659. class PhysicsVortexEvent {
  52660. private _scene;
  52661. private _origin;
  52662. private _options;
  52663. private _physicsEngine;
  52664. private _originTop;
  52665. private _tickCallback;
  52666. private _cylinder;
  52667. private _cylinderPosition;
  52668. private _dataFetched;
  52669. /**
  52670. * Initializes the physics vortex event
  52671. * @param _scene The BabylonJS scene
  52672. * @param _origin The origin position of the vortex
  52673. * @param _options The options for the vortex event
  52674. */
  52675. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  52676. /**
  52677. * Returns the data related to the vortex event (cylinder).
  52678. * @returns The physics vortex event data
  52679. */
  52680. getData(): PhysicsVortexEventData;
  52681. /**
  52682. * Enables the vortex.
  52683. */
  52684. enable(): void;
  52685. /**
  52686. * Disables the cortex.
  52687. */
  52688. disable(): void;
  52689. /**
  52690. * Disposes the sphere.
  52691. * @param force
  52692. */
  52693. dispose(force?: boolean): void;
  52694. private getImpostorForceAndContactPoint;
  52695. private _tick;
  52696. /*** Helpers ***/
  52697. private _prepareCylinder;
  52698. private _intersectsWithCylinder;
  52699. }
  52700. /**
  52701. * Options fot the radial explosion event
  52702. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52703. */
  52704. export class PhysicsRadialExplosionEventOptions {
  52705. /**
  52706. * The radius of the sphere for the radial explosion.
  52707. */
  52708. radius: number;
  52709. /**
  52710. * The strenth of the explosion.
  52711. */
  52712. strength: number;
  52713. /**
  52714. * The strenght of the force in correspondence to the distance of the affected object
  52715. */
  52716. falloff: PhysicsRadialImpulseFalloff;
  52717. /**
  52718. * Sphere options for the radial explosion.
  52719. */
  52720. sphere: {
  52721. segments: number;
  52722. diameter: number;
  52723. };
  52724. }
  52725. /**
  52726. * Options fot the updraft event
  52727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52728. */
  52729. export class PhysicsUpdraftEventOptions {
  52730. /**
  52731. * The radius of the cylinder for the vortex
  52732. */
  52733. radius: number;
  52734. /**
  52735. * The strenth of the updraft.
  52736. */
  52737. strength: number;
  52738. /**
  52739. * The height of the cylinder for the updraft.
  52740. */
  52741. height: number;
  52742. /**
  52743. * The mode for the the updraft.
  52744. */
  52745. updraftMode: PhysicsUpdraftMode;
  52746. }
  52747. /**
  52748. * Options fot the vortex event
  52749. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52750. */
  52751. export class PhysicsVortexEventOptions {
  52752. /**
  52753. * The radius of the cylinder for the vortex
  52754. */
  52755. radius: number;
  52756. /**
  52757. * The strenth of the vortex.
  52758. */
  52759. strength: number;
  52760. /**
  52761. * The height of the cylinder for the vortex.
  52762. */
  52763. height: number;
  52764. /**
  52765. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  52766. */
  52767. centripetalForceThreshold: number;
  52768. /**
  52769. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  52770. */
  52771. centripetalForceMultiplier: number;
  52772. /**
  52773. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  52774. */
  52775. centrifugalForceMultiplier: number;
  52776. /**
  52777. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  52778. */
  52779. updraftForceMultiplier: number;
  52780. }
  52781. /**
  52782. * The strenght of the force in correspondence to the distance of the affected object
  52783. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52784. */
  52785. export enum PhysicsRadialImpulseFalloff {
  52786. /** Defines that impulse is constant in strength across it's whole radius */
  52787. Constant = 0,
  52788. /** Defines that impulse gets weaker if it's further from the origin */
  52789. Linear = 1
  52790. }
  52791. /**
  52792. * The strength of the force in correspondence to the distance of the affected object
  52793. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52794. */
  52795. export enum PhysicsUpdraftMode {
  52796. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  52797. Center = 0,
  52798. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  52799. Perpendicular = 1
  52800. }
  52801. /**
  52802. * Interface for a physics force and contact point
  52803. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52804. */
  52805. export interface PhysicsForceAndContactPoint {
  52806. /**
  52807. * The force applied at the contact point
  52808. */
  52809. force: Vector3;
  52810. /**
  52811. * The contact point
  52812. */
  52813. contactPoint: Vector3;
  52814. }
  52815. /**
  52816. * Interface for radial explosion event data
  52817. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52818. */
  52819. export interface PhysicsRadialExplosionEventData {
  52820. /**
  52821. * A sphere used for the radial explosion event
  52822. */
  52823. sphere: Mesh;
  52824. }
  52825. /**
  52826. * Interface for gravitational field event data
  52827. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52828. */
  52829. export interface PhysicsGravitationalFieldEventData {
  52830. /**
  52831. * A sphere mesh used for the gravitational field event
  52832. */
  52833. sphere: Mesh;
  52834. }
  52835. /**
  52836. * Interface for updraft event data
  52837. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52838. */
  52839. export interface PhysicsUpdraftEventData {
  52840. /**
  52841. * A cylinder used for the updraft event
  52842. */
  52843. cylinder: Mesh;
  52844. }
  52845. /**
  52846. * Interface for vortex event data
  52847. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52848. */
  52849. export interface PhysicsVortexEventData {
  52850. /**
  52851. * A cylinder used for the vortex event
  52852. */
  52853. cylinder: Mesh;
  52854. }
  52855. }
  52856. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52857. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  52858. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52859. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52860. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52861. import { Nullable } from "babylonjs/types";
  52862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52863. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52864. /**
  52865. * AmmoJS Physics plugin
  52866. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52867. * @see https://github.com/kripken/ammo.js/
  52868. */
  52869. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52870. private _useDeltaForWorldStep;
  52871. /**
  52872. * Reference to the Ammo library
  52873. */
  52874. bjsAMMO: any;
  52875. /**
  52876. * Created ammoJS world which physics bodies are added to
  52877. */
  52878. world: any;
  52879. /**
  52880. * Name of the plugin
  52881. */
  52882. name: string;
  52883. private _timeStep;
  52884. private _fixedTimeStep;
  52885. private _maxSteps;
  52886. private _tmpQuaternion;
  52887. private _tmpAmmoTransform;
  52888. private _tmpAmmoQuaternion;
  52889. private _tmpAmmoConcreteContactResultCallback;
  52890. private _collisionConfiguration;
  52891. private _dispatcher;
  52892. private _overlappingPairCache;
  52893. private _solver;
  52894. private _softBodySolver;
  52895. private _tmpAmmoVectorA;
  52896. private _tmpAmmoVectorB;
  52897. private _tmpAmmoVectorC;
  52898. private _tmpAmmoVectorD;
  52899. private _tmpContactCallbackResult;
  52900. private _tmpAmmoVectorRCA;
  52901. private _tmpAmmoVectorRCB;
  52902. private _raycastResult;
  52903. private static readonly DISABLE_COLLISION_FLAG;
  52904. private static readonly KINEMATIC_FLAG;
  52905. private static readonly DISABLE_DEACTIVATION_FLAG;
  52906. /**
  52907. * Initializes the ammoJS plugin
  52908. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52909. * @param ammoInjection can be used to inject your own ammo reference
  52910. */
  52911. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  52912. /**
  52913. * Sets the gravity of the physics world (m/(s^2))
  52914. * @param gravity Gravity to set
  52915. */
  52916. setGravity(gravity: Vector3): void;
  52917. /**
  52918. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52919. * @param timeStep timestep to use in seconds
  52920. */
  52921. setTimeStep(timeStep: number): void;
  52922. /**
  52923. * 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)
  52924. * @param fixedTimeStep fixedTimeStep to use in seconds
  52925. */
  52926. setFixedTimeStep(fixedTimeStep: number): void;
  52927. /**
  52928. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52929. * @param maxSteps the maximum number of steps by the physics engine per frame
  52930. */
  52931. setMaxSteps(maxSteps: number): void;
  52932. /**
  52933. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52934. * @returns the current timestep in seconds
  52935. */
  52936. getTimeStep(): number;
  52937. private _isImpostorInContact;
  52938. private _isImpostorPairInContact;
  52939. private _stepSimulation;
  52940. /**
  52941. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52942. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52943. * After the step the babylon meshes are set to the position of the physics imposters
  52944. * @param delta amount of time to step forward
  52945. * @param impostors array of imposters to update before/after the step
  52946. */
  52947. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52948. /**
  52949. * Update babylon mesh vertices vertices to match physics world object
  52950. * @param impostor imposter to match
  52951. */
  52952. afterSoftStep(impostor: PhysicsImpostor): void;
  52953. private _tmpVector;
  52954. private _tmpMatrix;
  52955. /**
  52956. * Applies an impulse on the imposter
  52957. * @param impostor imposter to apply impulse to
  52958. * @param force amount of force to be applied to the imposter
  52959. * @param contactPoint the location to apply the impulse on the imposter
  52960. */
  52961. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52962. /**
  52963. * Applies a force on the imposter
  52964. * @param impostor imposter to apply force
  52965. * @param force amount of force to be applied to the imposter
  52966. * @param contactPoint the location to apply the force on the imposter
  52967. */
  52968. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52969. /**
  52970. * Creates a physics body using the plugin
  52971. * @param impostor the imposter to create the physics body on
  52972. */
  52973. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52974. /**
  52975. * Removes the physics body from the imposter and disposes of the body's memory
  52976. * @param impostor imposter to remove the physics body from
  52977. */
  52978. removePhysicsBody(impostor: PhysicsImpostor): void;
  52979. /**
  52980. * Generates a joint
  52981. * @param impostorJoint the imposter joint to create the joint with
  52982. */
  52983. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52984. /**
  52985. * Removes a joint
  52986. * @param impostorJoint the imposter joint to remove the joint from
  52987. */
  52988. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52989. private _addMeshVerts;
  52990. /**
  52991. * Initialise the soft body vertices to match its object's (mesh) vertices
  52992. * Softbody vertices (nodes) are in world space and to match this
  52993. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  52994. * @param impostor to create the softbody for
  52995. */
  52996. private _softVertexData;
  52997. /**
  52998. * Create an impostor's soft body
  52999. * @param impostor to create the softbody for
  53000. */
  53001. private _createSoftbody;
  53002. /**
  53003. * Create cloth for an impostor
  53004. * @param impostor to create the softbody for
  53005. */
  53006. private _createCloth;
  53007. private _addHullVerts;
  53008. private _createShape;
  53009. /**
  53010. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53011. * @param impostor imposter containing the physics body and babylon object
  53012. */
  53013. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53014. /**
  53015. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53016. * @param impostor imposter containing the physics body and babylon object
  53017. * @param newPosition new position
  53018. * @param newRotation new rotation
  53019. */
  53020. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53021. /**
  53022. * If this plugin is supported
  53023. * @returns true if its supported
  53024. */
  53025. isSupported(): boolean;
  53026. /**
  53027. * Sets the linear velocity of the physics body
  53028. * @param impostor imposter to set the velocity on
  53029. * @param velocity velocity to set
  53030. */
  53031. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53032. /**
  53033. * Sets the angular velocity of the physics body
  53034. * @param impostor imposter to set the velocity on
  53035. * @param velocity velocity to set
  53036. */
  53037. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53038. /**
  53039. * gets the linear velocity
  53040. * @param impostor imposter to get linear velocity from
  53041. * @returns linear velocity
  53042. */
  53043. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53044. /**
  53045. * gets the angular velocity
  53046. * @param impostor imposter to get angular velocity from
  53047. * @returns angular velocity
  53048. */
  53049. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53050. /**
  53051. * Sets the mass of physics body
  53052. * @param impostor imposter to set the mass on
  53053. * @param mass mass to set
  53054. */
  53055. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53056. /**
  53057. * Gets the mass of the physics body
  53058. * @param impostor imposter to get the mass from
  53059. * @returns mass
  53060. */
  53061. getBodyMass(impostor: PhysicsImpostor): number;
  53062. /**
  53063. * Gets friction of the impostor
  53064. * @param impostor impostor to get friction from
  53065. * @returns friction value
  53066. */
  53067. getBodyFriction(impostor: PhysicsImpostor): number;
  53068. /**
  53069. * Sets friction of the impostor
  53070. * @param impostor impostor to set friction on
  53071. * @param friction friction value
  53072. */
  53073. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53074. /**
  53075. * Gets restitution of the impostor
  53076. * @param impostor impostor to get restitution from
  53077. * @returns restitution value
  53078. */
  53079. getBodyRestitution(impostor: PhysicsImpostor): number;
  53080. /**
  53081. * Sets resitution of the impostor
  53082. * @param impostor impostor to set resitution on
  53083. * @param restitution resitution value
  53084. */
  53085. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53086. /**
  53087. * Gets pressure inside the impostor
  53088. * @param impostor impostor to get pressure from
  53089. * @returns pressure value
  53090. */
  53091. getBodyPressure(impostor: PhysicsImpostor): number;
  53092. /**
  53093. * Sets pressure inside a soft body impostor
  53094. * Cloth and rope must remain 0 pressure
  53095. * @param impostor impostor to set pressure on
  53096. * @param pressure pressure value
  53097. */
  53098. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53099. /**
  53100. * Gets stiffness of the impostor
  53101. * @param impostor impostor to get stiffness from
  53102. * @returns pressure value
  53103. */
  53104. getBodyStiffness(impostor: PhysicsImpostor): number;
  53105. /**
  53106. * Sets stiffness of the impostor
  53107. * @param impostor impostor to set stiffness on
  53108. * @param stiffness stiffness value from 0 to 1
  53109. */
  53110. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53111. /**
  53112. * Gets velocityIterations of the impostor
  53113. * @param impostor impostor to get velocity iterations from
  53114. * @returns velocityIterations value
  53115. */
  53116. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53117. /**
  53118. * Sets velocityIterations of the impostor
  53119. * @param impostor impostor to set velocity iterations on
  53120. * @param velocityIterations velocityIterations value
  53121. */
  53122. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53123. /**
  53124. * Gets positionIterations of the impostor
  53125. * @param impostor impostor to get position iterations from
  53126. * @returns positionIterations value
  53127. */
  53128. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53129. /**
  53130. * Sets positionIterations of the impostor
  53131. * @param impostor impostor to set position on
  53132. * @param positionIterations positionIterations value
  53133. */
  53134. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53135. /**
  53136. * Sleeps the physics body and stops it from being active
  53137. * @param impostor impostor to sleep
  53138. */
  53139. sleepBody(impostor: PhysicsImpostor): void;
  53140. /**
  53141. * Activates the physics body
  53142. * @param impostor impostor to activate
  53143. */
  53144. wakeUpBody(impostor: PhysicsImpostor): void;
  53145. /**
  53146. * Updates the distance parameters of the joint
  53147. * @param joint joint to update
  53148. * @param maxDistance maximum distance of the joint
  53149. * @param minDistance minimum distance of the joint
  53150. */
  53151. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53152. /**
  53153. * Sets a motor on the joint
  53154. * @param joint joint to set motor on
  53155. * @param speed speed of the motor
  53156. * @param maxForce maximum force of the motor
  53157. * @param motorIndex index of the motor
  53158. */
  53159. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53160. /**
  53161. * Sets the motors limit
  53162. * @param joint joint to set limit on
  53163. * @param upperLimit upper limit
  53164. * @param lowerLimit lower limit
  53165. */
  53166. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53167. /**
  53168. * Syncs the position and rotation of a mesh with the impostor
  53169. * @param mesh mesh to sync
  53170. * @param impostor impostor to update the mesh with
  53171. */
  53172. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53173. /**
  53174. * Gets the radius of the impostor
  53175. * @param impostor impostor to get radius from
  53176. * @returns the radius
  53177. */
  53178. getRadius(impostor: PhysicsImpostor): number;
  53179. /**
  53180. * Gets the box size of the impostor
  53181. * @param impostor impostor to get box size from
  53182. * @param result the resulting box size
  53183. */
  53184. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53185. /**
  53186. * Disposes of the impostor
  53187. */
  53188. dispose(): void;
  53189. /**
  53190. * Does a raycast in the physics world
  53191. * @param from when should the ray start?
  53192. * @param to when should the ray end?
  53193. * @returns PhysicsRaycastResult
  53194. */
  53195. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53196. }
  53197. }
  53198. declare module "babylonjs/Physics/Plugins/index" {
  53199. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  53200. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  53201. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  53202. }
  53203. declare module "babylonjs/Physics/index" {
  53204. export * from "babylonjs/Physics/IPhysicsEngine";
  53205. export * from "babylonjs/Physics/physicsEngine";
  53206. export * from "babylonjs/Physics/physicsEngineComponent";
  53207. export * from "babylonjs/Physics/physicsHelper";
  53208. export * from "babylonjs/Physics/physicsImpostor";
  53209. export * from "babylonjs/Physics/physicsJoint";
  53210. export * from "babylonjs/Physics/Plugins/index";
  53211. }
  53212. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  53213. /** @hidden */
  53214. export var blackAndWhitePixelShader: {
  53215. name: string;
  53216. shader: string;
  53217. };
  53218. }
  53219. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  53220. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53221. import { Camera } from "babylonjs/Cameras/camera";
  53222. import { Engine } from "babylonjs/Engines/engine";
  53223. import "babylonjs/Shaders/blackAndWhite.fragment";
  53224. /**
  53225. * Post process used to render in black and white
  53226. */
  53227. export class BlackAndWhitePostProcess extends PostProcess {
  53228. /**
  53229. * Linear about to convert he result to black and white (default: 1)
  53230. */
  53231. degree: number;
  53232. /**
  53233. * Creates a black and white post process
  53234. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  53235. * @param name The name of the effect.
  53236. * @param options The required width/height ratio to downsize to before computing the render pass.
  53237. * @param camera The camera to apply the render pass to.
  53238. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53239. * @param engine The engine which the post process will be applied. (default: current engine)
  53240. * @param reusable If the post process can be reused on the same frame. (default: false)
  53241. */
  53242. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53243. }
  53244. }
  53245. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  53246. import { Nullable } from "babylonjs/types";
  53247. import { Camera } from "babylonjs/Cameras/camera";
  53248. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53249. import { Engine } from "babylonjs/Engines/engine";
  53250. /**
  53251. * This represents a set of one or more post processes in Babylon.
  53252. * A post process can be used to apply a shader to a texture after it is rendered.
  53253. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53254. */
  53255. export class PostProcessRenderEffect {
  53256. private _postProcesses;
  53257. private _getPostProcesses;
  53258. private _singleInstance;
  53259. private _cameras;
  53260. private _indicesForCamera;
  53261. /**
  53262. * Name of the effect
  53263. * @hidden
  53264. */
  53265. _name: string;
  53266. /**
  53267. * Instantiates a post process render effect.
  53268. * A post process can be used to apply a shader to a texture after it is rendered.
  53269. * @param engine The engine the effect is tied to
  53270. * @param name The name of the effect
  53271. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  53272. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  53273. */
  53274. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  53275. /**
  53276. * Checks if all the post processes in the effect are supported.
  53277. */
  53278. readonly isSupported: boolean;
  53279. /**
  53280. * Updates the current state of the effect
  53281. * @hidden
  53282. */
  53283. _update(): void;
  53284. /**
  53285. * Attaches the effect on cameras
  53286. * @param cameras The camera to attach to.
  53287. * @hidden
  53288. */
  53289. _attachCameras(cameras: Camera): void;
  53290. /**
  53291. * Attaches the effect on cameras
  53292. * @param cameras The camera to attach to.
  53293. * @hidden
  53294. */
  53295. _attachCameras(cameras: Camera[]): void;
  53296. /**
  53297. * Detatches the effect on cameras
  53298. * @param cameras The camera to detatch from.
  53299. * @hidden
  53300. */
  53301. _detachCameras(cameras: Camera): void;
  53302. /**
  53303. * Detatches the effect on cameras
  53304. * @param cameras The camera to detatch from.
  53305. * @hidden
  53306. */
  53307. _detachCameras(cameras: Camera[]): void;
  53308. /**
  53309. * Enables the effect on given cameras
  53310. * @param cameras The camera to enable.
  53311. * @hidden
  53312. */
  53313. _enable(cameras: Camera): void;
  53314. /**
  53315. * Enables the effect on given cameras
  53316. * @param cameras The camera to enable.
  53317. * @hidden
  53318. */
  53319. _enable(cameras: Nullable<Camera[]>): void;
  53320. /**
  53321. * Disables the effect on the given cameras
  53322. * @param cameras The camera to disable.
  53323. * @hidden
  53324. */
  53325. _disable(cameras: Camera): void;
  53326. /**
  53327. * Disables the effect on the given cameras
  53328. * @param cameras The camera to disable.
  53329. * @hidden
  53330. */
  53331. _disable(cameras: Nullable<Camera[]>): void;
  53332. /**
  53333. * Gets a list of the post processes contained in the effect.
  53334. * @param camera The camera to get the post processes on.
  53335. * @returns The list of the post processes in the effect.
  53336. */
  53337. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  53338. }
  53339. }
  53340. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  53341. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53342. /** @hidden */
  53343. export var extractHighlightsPixelShader: {
  53344. name: string;
  53345. shader: string;
  53346. };
  53347. }
  53348. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  53349. import { Nullable } from "babylonjs/types";
  53350. import { Camera } from "babylonjs/Cameras/camera";
  53351. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53352. import { Engine } from "babylonjs/Engines/engine";
  53353. import "babylonjs/Shaders/extractHighlights.fragment";
  53354. /**
  53355. * 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.
  53356. */
  53357. export class ExtractHighlightsPostProcess extends PostProcess {
  53358. /**
  53359. * The luminance threshold, pixels below this value will be set to black.
  53360. */
  53361. threshold: number;
  53362. /** @hidden */
  53363. _exposure: number;
  53364. /**
  53365. * Post process which has the input texture to be used when performing highlight extraction
  53366. * @hidden
  53367. */
  53368. _inputPostProcess: Nullable<PostProcess>;
  53369. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53370. }
  53371. }
  53372. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  53373. /** @hidden */
  53374. export var bloomMergePixelShader: {
  53375. name: string;
  53376. shader: string;
  53377. };
  53378. }
  53379. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  53380. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53381. import { Nullable } from "babylonjs/types";
  53382. import { Engine } from "babylonjs/Engines/engine";
  53383. import { Camera } from "babylonjs/Cameras/camera";
  53384. import "babylonjs/Shaders/bloomMerge.fragment";
  53385. /**
  53386. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53387. */
  53388. export class BloomMergePostProcess extends PostProcess {
  53389. /** Weight of the bloom to be added to the original input. */
  53390. weight: number;
  53391. /**
  53392. * Creates a new instance of @see BloomMergePostProcess
  53393. * @param name The name of the effect.
  53394. * @param originalFromInput Post process which's input will be used for the merge.
  53395. * @param blurred Blurred highlights post process which's output will be used.
  53396. * @param weight Weight of the bloom to be added to the original input.
  53397. * @param options The required width/height ratio to downsize to before computing the render pass.
  53398. * @param camera The camera to apply the render pass to.
  53399. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53400. * @param engine The engine which the post process will be applied. (default: current engine)
  53401. * @param reusable If the post process can be reused on the same frame. (default: false)
  53402. * @param textureType Type of textures used when performing the post process. (default: 0)
  53403. * @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)
  53404. */
  53405. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  53406. /** Weight of the bloom to be added to the original input. */
  53407. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53408. }
  53409. }
  53410. declare module "babylonjs/PostProcesses/bloomEffect" {
  53411. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53412. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53413. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  53414. import { Camera } from "babylonjs/Cameras/camera";
  53415. import { Scene } from "babylonjs/scene";
  53416. /**
  53417. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  53418. */
  53419. export class BloomEffect extends PostProcessRenderEffect {
  53420. private bloomScale;
  53421. /**
  53422. * @hidden Internal
  53423. */
  53424. _effects: Array<PostProcess>;
  53425. /**
  53426. * @hidden Internal
  53427. */
  53428. _downscale: ExtractHighlightsPostProcess;
  53429. private _blurX;
  53430. private _blurY;
  53431. private _merge;
  53432. /**
  53433. * The luminance threshold to find bright areas of the image to bloom.
  53434. */
  53435. threshold: number;
  53436. /**
  53437. * The strength of the bloom.
  53438. */
  53439. weight: number;
  53440. /**
  53441. * Specifies the size of the bloom blur kernel, relative to the final output size
  53442. */
  53443. kernel: number;
  53444. /**
  53445. * Creates a new instance of @see BloomEffect
  53446. * @param scene The scene the effect belongs to.
  53447. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  53448. * @param bloomKernel The size of the kernel to be used when applying the blur.
  53449. * @param bloomWeight The the strength of bloom.
  53450. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  53451. * @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)
  53452. */
  53453. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  53454. /**
  53455. * Disposes each of the internal effects for a given camera.
  53456. * @param camera The camera to dispose the effect on.
  53457. */
  53458. disposeEffects(camera: Camera): void;
  53459. /**
  53460. * @hidden Internal
  53461. */
  53462. _updateEffects(): void;
  53463. /**
  53464. * Internal
  53465. * @returns if all the contained post processes are ready.
  53466. * @hidden
  53467. */
  53468. _isReady(): boolean;
  53469. }
  53470. }
  53471. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  53472. /** @hidden */
  53473. export var chromaticAberrationPixelShader: {
  53474. name: string;
  53475. shader: string;
  53476. };
  53477. }
  53478. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  53479. import { Vector2 } from "babylonjs/Maths/math";
  53480. import { Nullable } from "babylonjs/types";
  53481. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53482. import { Camera } from "babylonjs/Cameras/camera";
  53483. import { Engine } from "babylonjs/Engines/engine";
  53484. import "babylonjs/Shaders/chromaticAberration.fragment";
  53485. /**
  53486. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  53487. */
  53488. export class ChromaticAberrationPostProcess extends PostProcess {
  53489. /**
  53490. * The amount of seperation of rgb channels (default: 30)
  53491. */
  53492. aberrationAmount: number;
  53493. /**
  53494. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  53495. */
  53496. radialIntensity: number;
  53497. /**
  53498. * 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))
  53499. */
  53500. direction: Vector2;
  53501. /**
  53502. * 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))
  53503. */
  53504. centerPosition: Vector2;
  53505. /**
  53506. * Creates a new instance ChromaticAberrationPostProcess
  53507. * @param name The name of the effect.
  53508. * @param screenWidth The width of the screen to apply the effect on.
  53509. * @param screenHeight The height of the screen to apply the effect on.
  53510. * @param options The required width/height ratio to downsize to before computing the render pass.
  53511. * @param camera The camera to apply the render pass to.
  53512. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53513. * @param engine The engine which the post process will be applied. (default: current engine)
  53514. * @param reusable If the post process can be reused on the same frame. (default: false)
  53515. * @param textureType Type of textures used when performing the post process. (default: 0)
  53516. * @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)
  53517. */
  53518. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53519. }
  53520. }
  53521. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  53522. /** @hidden */
  53523. export var circleOfConfusionPixelShader: {
  53524. name: string;
  53525. shader: string;
  53526. };
  53527. }
  53528. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  53529. import { Nullable } from "babylonjs/types";
  53530. import { Engine } from "babylonjs/Engines/engine";
  53531. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53532. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53533. import { Camera } from "babylonjs/Cameras/camera";
  53534. import "babylonjs/Shaders/circleOfConfusion.fragment";
  53535. /**
  53536. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  53537. */
  53538. export class CircleOfConfusionPostProcess extends PostProcess {
  53539. /**
  53540. * 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.
  53541. */
  53542. lensSize: number;
  53543. /**
  53544. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53545. */
  53546. fStop: number;
  53547. /**
  53548. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53549. */
  53550. focusDistance: number;
  53551. /**
  53552. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  53553. */
  53554. focalLength: number;
  53555. private _depthTexture;
  53556. /**
  53557. * Creates a new instance CircleOfConfusionPostProcess
  53558. * @param name The name of the effect.
  53559. * @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.
  53560. * @param options The required width/height ratio to downsize to before computing the render pass.
  53561. * @param camera The camera to apply the render pass to.
  53562. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53563. * @param engine The engine which the post process will be applied. (default: current engine)
  53564. * @param reusable If the post process can be reused on the same frame. (default: false)
  53565. * @param textureType Type of textures used when performing the post process. (default: 0)
  53566. * @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)
  53567. */
  53568. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53569. /**
  53570. * 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.
  53571. */
  53572. depthTexture: RenderTargetTexture;
  53573. }
  53574. }
  53575. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  53576. /** @hidden */
  53577. export var colorCorrectionPixelShader: {
  53578. name: string;
  53579. shader: string;
  53580. };
  53581. }
  53582. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  53583. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53584. import { Engine } from "babylonjs/Engines/engine";
  53585. import { Camera } from "babylonjs/Cameras/camera";
  53586. import "babylonjs/Shaders/colorCorrection.fragment";
  53587. /**
  53588. *
  53589. * This post-process allows the modification of rendered colors by using
  53590. * a 'look-up table' (LUT). This effect is also called Color Grading.
  53591. *
  53592. * The object needs to be provided an url to a texture containing the color
  53593. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  53594. * Use an image editing software to tweak the LUT to match your needs.
  53595. *
  53596. * For an example of a color LUT, see here:
  53597. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  53598. * For explanations on color grading, see here:
  53599. * @see http://udn.epicgames.com/Three/ColorGrading.html
  53600. *
  53601. */
  53602. export class ColorCorrectionPostProcess extends PostProcess {
  53603. private _colorTableTexture;
  53604. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53605. }
  53606. }
  53607. declare module "babylonjs/Shaders/convolution.fragment" {
  53608. /** @hidden */
  53609. export var convolutionPixelShader: {
  53610. name: string;
  53611. shader: string;
  53612. };
  53613. }
  53614. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  53615. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53616. import { Nullable } from "babylonjs/types";
  53617. import { Camera } from "babylonjs/Cameras/camera";
  53618. import { Engine } from "babylonjs/Engines/engine";
  53619. import "babylonjs/Shaders/convolution.fragment";
  53620. /**
  53621. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  53622. * input texture to perform effects such as edge detection or sharpening
  53623. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53624. */
  53625. export class ConvolutionPostProcess extends PostProcess {
  53626. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53627. kernel: number[];
  53628. /**
  53629. * Creates a new instance ConvolutionPostProcess
  53630. * @param name The name of the effect.
  53631. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  53632. * @param options The required width/height ratio to downsize to before computing the render pass.
  53633. * @param camera The camera to apply the render pass to.
  53634. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53635. * @param engine The engine which the post process will be applied. (default: current engine)
  53636. * @param reusable If the post process can be reused on the same frame. (default: false)
  53637. * @param textureType Type of textures used when performing the post process. (default: 0)
  53638. */
  53639. constructor(name: string,
  53640. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53641. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53642. /**
  53643. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53644. */
  53645. static EdgeDetect0Kernel: number[];
  53646. /**
  53647. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53648. */
  53649. static EdgeDetect1Kernel: number[];
  53650. /**
  53651. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53652. */
  53653. static EdgeDetect2Kernel: number[];
  53654. /**
  53655. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53656. */
  53657. static SharpenKernel: number[];
  53658. /**
  53659. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53660. */
  53661. static EmbossKernel: number[];
  53662. /**
  53663. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53664. */
  53665. static GaussianKernel: number[];
  53666. }
  53667. }
  53668. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  53669. import { Nullable } from "babylonjs/types";
  53670. import { Vector2 } from "babylonjs/Maths/math";
  53671. import { Camera } from "babylonjs/Cameras/camera";
  53672. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53673. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  53674. import { Engine } from "babylonjs/Engines/engine";
  53675. import { Scene } from "babylonjs/scene";
  53676. /**
  53677. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  53678. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  53679. * based on samples that have a large difference in distance than the center pixel.
  53680. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  53681. */
  53682. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  53683. direction: Vector2;
  53684. /**
  53685. * Creates a new instance CircleOfConfusionPostProcess
  53686. * @param name The name of the effect.
  53687. * @param scene The scene the effect belongs to.
  53688. * @param direction The direction the blur should be applied.
  53689. * @param kernel The size of the kernel used to blur.
  53690. * @param options The required width/height ratio to downsize to before computing the render pass.
  53691. * @param camera The camera to apply the render pass to.
  53692. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  53693. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  53694. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53695. * @param engine The engine which the post process will be applied. (default: current engine)
  53696. * @param reusable If the post process can be reused on the same frame. (default: false)
  53697. * @param textureType Type of textures used when performing the post process. (default: 0)
  53698. * @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)
  53699. */
  53700. 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);
  53701. }
  53702. }
  53703. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  53704. /** @hidden */
  53705. export var depthOfFieldMergePixelShader: {
  53706. name: string;
  53707. shader: string;
  53708. };
  53709. }
  53710. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  53711. import { Nullable } from "babylonjs/types";
  53712. import { Camera } from "babylonjs/Cameras/camera";
  53713. import { Effect } from "babylonjs/Materials/effect";
  53714. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53715. import { Engine } from "babylonjs/Engines/engine";
  53716. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  53717. /**
  53718. * Options to be set when merging outputs from the default pipeline.
  53719. */
  53720. export class DepthOfFieldMergePostProcessOptions {
  53721. /**
  53722. * The original image to merge on top of
  53723. */
  53724. originalFromInput: PostProcess;
  53725. /**
  53726. * Parameters to perform the merge of the depth of field effect
  53727. */
  53728. depthOfField?: {
  53729. circleOfConfusion: PostProcess;
  53730. blurSteps: Array<PostProcess>;
  53731. };
  53732. /**
  53733. * Parameters to perform the merge of bloom effect
  53734. */
  53735. bloom?: {
  53736. blurred: PostProcess;
  53737. weight: number;
  53738. };
  53739. }
  53740. /**
  53741. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53742. */
  53743. export class DepthOfFieldMergePostProcess extends PostProcess {
  53744. private blurSteps;
  53745. /**
  53746. * Creates a new instance of DepthOfFieldMergePostProcess
  53747. * @param name The name of the effect.
  53748. * @param originalFromInput Post process which's input will be used for the merge.
  53749. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  53750. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  53751. * @param options The required width/height ratio to downsize to before computing the render pass.
  53752. * @param camera The camera to apply the render pass to.
  53753. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53754. * @param engine The engine which the post process will be applied. (default: current engine)
  53755. * @param reusable If the post process can be reused on the same frame. (default: false)
  53756. * @param textureType Type of textures used when performing the post process. (default: 0)
  53757. * @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)
  53758. */
  53759. 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);
  53760. /**
  53761. * Updates the effect with the current post process compile time values and recompiles the shader.
  53762. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  53763. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  53764. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  53765. * @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
  53766. * @param onCompiled Called when the shader has been compiled.
  53767. * @param onError Called if there is an error when compiling a shader.
  53768. */
  53769. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  53770. }
  53771. }
  53772. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  53773. import { Nullable } from "babylonjs/types";
  53774. import { Camera } from "babylonjs/Cameras/camera";
  53775. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53776. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53777. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53778. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  53779. import { Scene } from "babylonjs/scene";
  53780. /**
  53781. * Specifies the level of max blur that should be applied when using the depth of field effect
  53782. */
  53783. export enum DepthOfFieldEffectBlurLevel {
  53784. /**
  53785. * Subtle blur
  53786. */
  53787. Low = 0,
  53788. /**
  53789. * Medium blur
  53790. */
  53791. Medium = 1,
  53792. /**
  53793. * Large blur
  53794. */
  53795. High = 2
  53796. }
  53797. /**
  53798. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  53799. */
  53800. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  53801. private _circleOfConfusion;
  53802. /**
  53803. * @hidden Internal, blurs from high to low
  53804. */
  53805. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  53806. private _depthOfFieldBlurY;
  53807. private _dofMerge;
  53808. /**
  53809. * @hidden Internal post processes in depth of field effect
  53810. */
  53811. _effects: Array<PostProcess>;
  53812. /**
  53813. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  53814. */
  53815. focalLength: number;
  53816. /**
  53817. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53818. */
  53819. fStop: number;
  53820. /**
  53821. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53822. */
  53823. focusDistance: number;
  53824. /**
  53825. * 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.
  53826. */
  53827. lensSize: number;
  53828. /**
  53829. * Creates a new instance DepthOfFieldEffect
  53830. * @param scene The scene the effect belongs to.
  53831. * @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.
  53832. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  53833. * @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)
  53834. */
  53835. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  53836. /**
  53837. * 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.
  53838. */
  53839. depthTexture: RenderTargetTexture;
  53840. /**
  53841. * Disposes each of the internal effects for a given camera.
  53842. * @param camera The camera to dispose the effect on.
  53843. */
  53844. disposeEffects(camera: Camera): void;
  53845. /**
  53846. * @hidden Internal
  53847. */
  53848. _updateEffects(): void;
  53849. /**
  53850. * Internal
  53851. * @returns if all the contained post processes are ready.
  53852. * @hidden
  53853. */
  53854. _isReady(): boolean;
  53855. }
  53856. }
  53857. declare module "babylonjs/Shaders/displayPass.fragment" {
  53858. /** @hidden */
  53859. export var displayPassPixelShader: {
  53860. name: string;
  53861. shader: string;
  53862. };
  53863. }
  53864. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  53865. import { Nullable } from "babylonjs/types";
  53866. import { Camera } from "babylonjs/Cameras/camera";
  53867. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53868. import { Engine } from "babylonjs/Engines/engine";
  53869. import "babylonjs/Shaders/displayPass.fragment";
  53870. /**
  53871. * DisplayPassPostProcess which produces an output the same as it's input
  53872. */
  53873. export class DisplayPassPostProcess extends PostProcess {
  53874. /**
  53875. * Creates the DisplayPassPostProcess
  53876. * @param name The name of the effect.
  53877. * @param options The required width/height ratio to downsize to before computing the render pass.
  53878. * @param camera The camera to apply the render pass to.
  53879. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53880. * @param engine The engine which the post process will be applied. (default: current engine)
  53881. * @param reusable If the post process can be reused on the same frame. (default: false)
  53882. */
  53883. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53884. }
  53885. }
  53886. declare module "babylonjs/Shaders/filter.fragment" {
  53887. /** @hidden */
  53888. export var filterPixelShader: {
  53889. name: string;
  53890. shader: string;
  53891. };
  53892. }
  53893. declare module "babylonjs/PostProcesses/filterPostProcess" {
  53894. import { Nullable } from "babylonjs/types";
  53895. import { Matrix } from "babylonjs/Maths/math";
  53896. import { Camera } from "babylonjs/Cameras/camera";
  53897. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53898. import { Engine } from "babylonjs/Engines/engine";
  53899. import "babylonjs/Shaders/filter.fragment";
  53900. /**
  53901. * Applies a kernel filter to the image
  53902. */
  53903. export class FilterPostProcess extends PostProcess {
  53904. /** The matrix to be applied to the image */
  53905. kernelMatrix: Matrix;
  53906. /**
  53907. *
  53908. * @param name The name of the effect.
  53909. * @param kernelMatrix The matrix to be applied to the image
  53910. * @param options The required width/height ratio to downsize to before computing the render pass.
  53911. * @param camera The camera to apply the render pass to.
  53912. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53913. * @param engine The engine which the post process will be applied. (default: current engine)
  53914. * @param reusable If the post process can be reused on the same frame. (default: false)
  53915. */
  53916. constructor(name: string,
  53917. /** The matrix to be applied to the image */
  53918. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53919. }
  53920. }
  53921. declare module "babylonjs/Shaders/fxaa.fragment" {
  53922. /** @hidden */
  53923. export var fxaaPixelShader: {
  53924. name: string;
  53925. shader: string;
  53926. };
  53927. }
  53928. declare module "babylonjs/Shaders/fxaa.vertex" {
  53929. /** @hidden */
  53930. export var fxaaVertexShader: {
  53931. name: string;
  53932. shader: string;
  53933. };
  53934. }
  53935. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  53936. import { Nullable } from "babylonjs/types";
  53937. import { Camera } from "babylonjs/Cameras/camera";
  53938. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53939. import { Engine } from "babylonjs/Engines/engine";
  53940. import "babylonjs/Shaders/fxaa.fragment";
  53941. import "babylonjs/Shaders/fxaa.vertex";
  53942. /**
  53943. * Fxaa post process
  53944. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  53945. */
  53946. export class FxaaPostProcess extends PostProcess {
  53947. /** @hidden */
  53948. texelWidth: number;
  53949. /** @hidden */
  53950. texelHeight: number;
  53951. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53952. private _getDefines;
  53953. }
  53954. }
  53955. declare module "babylonjs/Shaders/grain.fragment" {
  53956. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53957. /** @hidden */
  53958. export var grainPixelShader: {
  53959. name: string;
  53960. shader: string;
  53961. };
  53962. }
  53963. declare module "babylonjs/PostProcesses/grainPostProcess" {
  53964. import { Nullable } from "babylonjs/types";
  53965. import { Camera } from "babylonjs/Cameras/camera";
  53966. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  53967. import { Engine } from "babylonjs/Engines/engine";
  53968. import "babylonjs/Shaders/grain.fragment";
  53969. /**
  53970. * The GrainPostProcess adds noise to the image at mid luminance levels
  53971. */
  53972. export class GrainPostProcess extends PostProcess {
  53973. /**
  53974. * The intensity of the grain added (default: 30)
  53975. */
  53976. intensity: number;
  53977. /**
  53978. * If the grain should be randomized on every frame
  53979. */
  53980. animated: boolean;
  53981. /**
  53982. * Creates a new instance of @see GrainPostProcess
  53983. * @param name The name of the effect.
  53984. * @param options The required width/height ratio to downsize to before computing the render pass.
  53985. * @param camera The camera to apply the render pass to.
  53986. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53987. * @param engine The engine which the post process will be applied. (default: current engine)
  53988. * @param reusable If the post process can be reused on the same frame. (default: false)
  53989. * @param textureType Type of textures used when performing the post process. (default: 0)
  53990. * @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)
  53991. */
  53992. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53993. }
  53994. }
  53995. declare module "babylonjs/Shaders/highlights.fragment" {
  53996. /** @hidden */
  53997. export var highlightsPixelShader: {
  53998. name: string;
  53999. shader: string;
  54000. };
  54001. }
  54002. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  54003. import { Nullable } from "babylonjs/types";
  54004. import { Camera } from "babylonjs/Cameras/camera";
  54005. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54006. import { Engine } from "babylonjs/Engines/engine";
  54007. import "babylonjs/Shaders/highlights.fragment";
  54008. /**
  54009. * Extracts highlights from the image
  54010. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54011. */
  54012. export class HighlightsPostProcess extends PostProcess {
  54013. /**
  54014. * Extracts highlights from the image
  54015. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54016. * @param name The name of the effect.
  54017. * @param options The required width/height ratio to downsize to before computing the render pass.
  54018. * @param camera The camera to apply the render pass to.
  54019. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54020. * @param engine The engine which the post process will be applied. (default: current engine)
  54021. * @param reusable If the post process can be reused on the same frame. (default: false)
  54022. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  54023. */
  54024. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54025. }
  54026. }
  54027. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  54028. /** @hidden */
  54029. export var mrtFragmentDeclaration: {
  54030. name: string;
  54031. shader: string;
  54032. };
  54033. }
  54034. declare module "babylonjs/Shaders/geometry.fragment" {
  54035. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  54036. /** @hidden */
  54037. export var geometryPixelShader: {
  54038. name: string;
  54039. shader: string;
  54040. };
  54041. }
  54042. declare module "babylonjs/Shaders/geometry.vertex" {
  54043. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54044. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54045. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54046. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54047. /** @hidden */
  54048. export var geometryVertexShader: {
  54049. name: string;
  54050. shader: string;
  54051. };
  54052. }
  54053. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  54054. import { Matrix } from "babylonjs/Maths/math";
  54055. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54056. import { Mesh } from "babylonjs/Meshes/mesh";
  54057. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  54058. import { Effect } from "babylonjs/Materials/effect";
  54059. import { Scene } from "babylonjs/scene";
  54060. import "babylonjs/Shaders/geometry.fragment";
  54061. import "babylonjs/Shaders/geometry.vertex";
  54062. /**
  54063. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  54064. */
  54065. export class GeometryBufferRenderer {
  54066. /**
  54067. * Constant used to retrieve the position texture index in the G-Buffer textures array
  54068. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  54069. */
  54070. static readonly POSITION_TEXTURE_TYPE: number;
  54071. /**
  54072. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  54073. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  54074. */
  54075. static readonly VELOCITY_TEXTURE_TYPE: number;
  54076. /**
  54077. * Dictionary used to store the previous transformation matrices of each rendered mesh
  54078. * in order to compute objects velocities when enableVelocity is set to "true"
  54079. * @hidden
  54080. */
  54081. _previousTransformationMatrices: {
  54082. [index: number]: Matrix;
  54083. };
  54084. private _scene;
  54085. private _multiRenderTarget;
  54086. private _ratio;
  54087. private _enablePosition;
  54088. private _enableVelocity;
  54089. private _positionIndex;
  54090. private _velocityIndex;
  54091. protected _effect: Effect;
  54092. protected _cachedDefines: string;
  54093. /**
  54094. * Set the render list (meshes to be rendered) used in the G buffer.
  54095. */
  54096. renderList: Mesh[];
  54097. /**
  54098. * Gets wether or not G buffer are supported by the running hardware.
  54099. * This requires draw buffer supports
  54100. */
  54101. readonly isSupported: boolean;
  54102. /**
  54103. * Returns the index of the given texture type in the G-Buffer textures array
  54104. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  54105. * @returns the index of the given texture type in the G-Buffer textures array
  54106. */
  54107. getTextureIndex(textureType: number): number;
  54108. /**
  54109. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  54110. */
  54111. /**
  54112. * Sets whether or not objects positions are enabled for the G buffer.
  54113. */
  54114. enablePosition: boolean;
  54115. /**
  54116. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  54117. */
  54118. /**
  54119. * Sets wether or not objects velocities are enabled for the G buffer.
  54120. */
  54121. enableVelocity: boolean;
  54122. /**
  54123. * Gets the scene associated with the buffer.
  54124. */
  54125. readonly scene: Scene;
  54126. /**
  54127. * Gets the ratio used by the buffer during its creation.
  54128. * How big is the buffer related to the main canvas.
  54129. */
  54130. readonly ratio: number;
  54131. /** @hidden */
  54132. static _SceneComponentInitialization: (scene: Scene) => void;
  54133. /**
  54134. * Creates a new G Buffer for the scene
  54135. * @param scene The scene the buffer belongs to
  54136. * @param ratio How big is the buffer related to the main canvas.
  54137. */
  54138. constructor(scene: Scene, ratio?: number);
  54139. /**
  54140. * Checks wether everything is ready to render a submesh to the G buffer.
  54141. * @param subMesh the submesh to check readiness for
  54142. * @param useInstances is the mesh drawn using instance or not
  54143. * @returns true if ready otherwise false
  54144. */
  54145. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54146. /**
  54147. * Gets the current underlying G Buffer.
  54148. * @returns the buffer
  54149. */
  54150. getGBuffer(): MultiRenderTarget;
  54151. /**
  54152. * Gets the number of samples used to render the buffer (anti aliasing).
  54153. */
  54154. /**
  54155. * Sets the number of samples used to render the buffer (anti aliasing).
  54156. */
  54157. samples: number;
  54158. /**
  54159. * Disposes the renderer and frees up associated resources.
  54160. */
  54161. dispose(): void;
  54162. protected _createRenderTargets(): void;
  54163. }
  54164. }
  54165. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  54166. import { Nullable } from "babylonjs/types";
  54167. import { Scene } from "babylonjs/scene";
  54168. import { ISceneComponent } from "babylonjs/sceneComponent";
  54169. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  54170. module "babylonjs/scene" {
  54171. interface Scene {
  54172. /** @hidden (Backing field) */
  54173. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54174. /**
  54175. * Gets or Sets the current geometry buffer associated to the scene.
  54176. */
  54177. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54178. /**
  54179. * Enables a GeometryBufferRender and associates it with the scene
  54180. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  54181. * @returns the GeometryBufferRenderer
  54182. */
  54183. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  54184. /**
  54185. * Disables the GeometryBufferRender associated with the scene
  54186. */
  54187. disableGeometryBufferRenderer(): void;
  54188. }
  54189. }
  54190. /**
  54191. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  54192. * in several rendering techniques.
  54193. */
  54194. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  54195. /**
  54196. * The component name helpful to identify the component in the list of scene components.
  54197. */
  54198. readonly name: string;
  54199. /**
  54200. * The scene the component belongs to.
  54201. */
  54202. scene: Scene;
  54203. /**
  54204. * Creates a new instance of the component for the given scene
  54205. * @param scene Defines the scene to register the component in
  54206. */
  54207. constructor(scene: Scene);
  54208. /**
  54209. * Registers the component in a given scene
  54210. */
  54211. register(): void;
  54212. /**
  54213. * Rebuilds the elements related to this component in case of
  54214. * context lost for instance.
  54215. */
  54216. rebuild(): void;
  54217. /**
  54218. * Disposes the component and the associated ressources
  54219. */
  54220. dispose(): void;
  54221. private _gatherRenderTargets;
  54222. }
  54223. }
  54224. declare module "babylonjs/Shaders/motionBlur.fragment" {
  54225. /** @hidden */
  54226. export var motionBlurPixelShader: {
  54227. name: string;
  54228. shader: string;
  54229. };
  54230. }
  54231. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  54232. import { Nullable } from "babylonjs/types";
  54233. import { Camera } from "babylonjs/Cameras/camera";
  54234. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54235. import { Scene } from "babylonjs/scene";
  54236. import "babylonjs/Animations/animatable";
  54237. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  54238. import "babylonjs/Shaders/motionBlur.fragment";
  54239. import { Engine } from "babylonjs/Engines/engine";
  54240. /**
  54241. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  54242. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  54243. * As an example, all you have to do is to create the post-process:
  54244. * var mb = new BABYLON.MotionBlurPostProcess(
  54245. * 'mb', // The name of the effect.
  54246. * scene, // The scene containing the objects to blur according to their velocity.
  54247. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  54248. * camera // The camera to apply the render pass to.
  54249. * );
  54250. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  54251. */
  54252. export class MotionBlurPostProcess extends PostProcess {
  54253. /**
  54254. * Defines how much the image is blurred by the movement. Default value is equal to 1
  54255. */
  54256. motionStrength: number;
  54257. /**
  54258. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  54259. */
  54260. /**
  54261. * Sets the number of iterations to be used for motion blur quality
  54262. */
  54263. motionBlurSamples: number;
  54264. private _motionBlurSamples;
  54265. private _geometryBufferRenderer;
  54266. /**
  54267. * Creates a new instance MotionBlurPostProcess
  54268. * @param name The name of the effect.
  54269. * @param scene The scene containing the objects to blur according to their velocity.
  54270. * @param options The required width/height ratio to downsize to before computing the render pass.
  54271. * @param camera The camera to apply the render pass to.
  54272. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54273. * @param engine The engine which the post process will be applied. (default: current engine)
  54274. * @param reusable If the post process can be reused on the same frame. (default: false)
  54275. * @param textureType Type of textures used when performing the post process. (default: 0)
  54276. * @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)
  54277. */
  54278. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54279. /**
  54280. * Disposes the post process.
  54281. * @param camera The camera to dispose the post process on.
  54282. */
  54283. dispose(camera?: Camera): void;
  54284. }
  54285. }
  54286. declare module "babylonjs/Shaders/refraction.fragment" {
  54287. /** @hidden */
  54288. export var refractionPixelShader: {
  54289. name: string;
  54290. shader: string;
  54291. };
  54292. }
  54293. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  54294. import { Color3 } from "babylonjs/Maths/math";
  54295. import { Camera } from "babylonjs/Cameras/camera";
  54296. import { Texture } from "babylonjs/Materials/Textures/texture";
  54297. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54298. import { Engine } from "babylonjs/Engines/engine";
  54299. import "babylonjs/Shaders/refraction.fragment";
  54300. /**
  54301. * Post process which applies a refractin texture
  54302. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  54303. */
  54304. export class RefractionPostProcess extends PostProcess {
  54305. /** the base color of the refraction (used to taint the rendering) */
  54306. color: Color3;
  54307. /** simulated refraction depth */
  54308. depth: number;
  54309. /** the coefficient of the base color (0 to remove base color tainting) */
  54310. colorLevel: number;
  54311. private _refTexture;
  54312. private _ownRefractionTexture;
  54313. /**
  54314. * Gets or sets the refraction texture
  54315. * Please note that you are responsible for disposing the texture if you set it manually
  54316. */
  54317. refractionTexture: Texture;
  54318. /**
  54319. * Initializes the RefractionPostProcess
  54320. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  54321. * @param name The name of the effect.
  54322. * @param refractionTextureUrl Url of the refraction texture to use
  54323. * @param color the base color of the refraction (used to taint the rendering)
  54324. * @param depth simulated refraction depth
  54325. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  54326. * @param camera The camera to apply the render pass to.
  54327. * @param options The required width/height ratio to downsize to before computing the render pass.
  54328. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54329. * @param engine The engine which the post process will be applied. (default: current engine)
  54330. * @param reusable If the post process can be reused on the same frame. (default: false)
  54331. */
  54332. constructor(name: string, refractionTextureUrl: string,
  54333. /** the base color of the refraction (used to taint the rendering) */
  54334. color: Color3,
  54335. /** simulated refraction depth */
  54336. depth: number,
  54337. /** the coefficient of the base color (0 to remove base color tainting) */
  54338. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54339. /**
  54340. * Disposes of the post process
  54341. * @param camera Camera to dispose post process on
  54342. */
  54343. dispose(camera: Camera): void;
  54344. }
  54345. }
  54346. declare module "babylonjs/Shaders/sharpen.fragment" {
  54347. /** @hidden */
  54348. export var sharpenPixelShader: {
  54349. name: string;
  54350. shader: string;
  54351. };
  54352. }
  54353. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  54354. import { Nullable } from "babylonjs/types";
  54355. import { Camera } from "babylonjs/Cameras/camera";
  54356. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54357. import "babylonjs/Shaders/sharpen.fragment";
  54358. import { Engine } from "babylonjs/Engines/engine";
  54359. /**
  54360. * The SharpenPostProcess applies a sharpen kernel to every pixel
  54361. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54362. */
  54363. export class SharpenPostProcess extends PostProcess {
  54364. /**
  54365. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  54366. */
  54367. colorAmount: number;
  54368. /**
  54369. * How much sharpness should be applied (default: 0.3)
  54370. */
  54371. edgeAmount: number;
  54372. /**
  54373. * Creates a new instance ConvolutionPostProcess
  54374. * @param name The name of the effect.
  54375. * @param options The required width/height ratio to downsize to before computing the render pass.
  54376. * @param camera The camera to apply the render pass to.
  54377. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54378. * @param engine The engine which the post process will be applied. (default: current engine)
  54379. * @param reusable If the post process can be reused on the same frame. (default: false)
  54380. * @param textureType Type of textures used when performing the post process. (default: 0)
  54381. * @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)
  54382. */
  54383. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54384. }
  54385. }
  54386. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  54387. import { Nullable } from "babylonjs/types";
  54388. import { Camera } from "babylonjs/Cameras/camera";
  54389. import { Engine } from "babylonjs/Engines/engine";
  54390. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54391. import { IInspectable } from "babylonjs/Misc/iInspectable";
  54392. /**
  54393. * PostProcessRenderPipeline
  54394. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54395. */
  54396. export class PostProcessRenderPipeline {
  54397. private engine;
  54398. private _renderEffects;
  54399. private _renderEffectsForIsolatedPass;
  54400. /**
  54401. * List of inspectable custom properties (used by the Inspector)
  54402. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  54403. */
  54404. inspectableCustomProperties: IInspectable[];
  54405. /**
  54406. * @hidden
  54407. */
  54408. protected _cameras: Camera[];
  54409. /** @hidden */
  54410. _name: string;
  54411. /**
  54412. * Gets pipeline name
  54413. */
  54414. readonly name: string;
  54415. /**
  54416. * Initializes a PostProcessRenderPipeline
  54417. * @param engine engine to add the pipeline to
  54418. * @param name name of the pipeline
  54419. */
  54420. constructor(engine: Engine, name: string);
  54421. /**
  54422. * Gets the class name
  54423. * @returns "PostProcessRenderPipeline"
  54424. */
  54425. getClassName(): string;
  54426. /**
  54427. * If all the render effects in the pipeline are supported
  54428. */
  54429. readonly isSupported: boolean;
  54430. /**
  54431. * Adds an effect to the pipeline
  54432. * @param renderEffect the effect to add
  54433. */
  54434. addEffect(renderEffect: PostProcessRenderEffect): void;
  54435. /** @hidden */
  54436. _rebuild(): void;
  54437. /** @hidden */
  54438. _enableEffect(renderEffectName: string, cameras: Camera): void;
  54439. /** @hidden */
  54440. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  54441. /** @hidden */
  54442. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  54443. /** @hidden */
  54444. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  54445. /** @hidden */
  54446. _attachCameras(cameras: Camera, unique: boolean): void;
  54447. /** @hidden */
  54448. _attachCameras(cameras: Camera[], unique: boolean): void;
  54449. /** @hidden */
  54450. _detachCameras(cameras: Camera): void;
  54451. /** @hidden */
  54452. _detachCameras(cameras: Nullable<Camera[]>): void;
  54453. /** @hidden */
  54454. _update(): void;
  54455. /** @hidden */
  54456. _reset(): void;
  54457. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  54458. /**
  54459. * Disposes of the pipeline
  54460. */
  54461. dispose(): void;
  54462. }
  54463. }
  54464. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  54465. import { Camera } from "babylonjs/Cameras/camera";
  54466. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54467. /**
  54468. * PostProcessRenderPipelineManager class
  54469. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54470. */
  54471. export class PostProcessRenderPipelineManager {
  54472. private _renderPipelines;
  54473. /**
  54474. * Initializes a PostProcessRenderPipelineManager
  54475. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54476. */
  54477. constructor();
  54478. /**
  54479. * Gets the list of supported render pipelines
  54480. */
  54481. readonly supportedPipelines: PostProcessRenderPipeline[];
  54482. /**
  54483. * Adds a pipeline to the manager
  54484. * @param renderPipeline The pipeline to add
  54485. */
  54486. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  54487. /**
  54488. * Attaches a camera to the pipeline
  54489. * @param renderPipelineName The name of the pipeline to attach to
  54490. * @param cameras the camera to attach
  54491. * @param unique if the camera can be attached multiple times to the pipeline
  54492. */
  54493. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  54494. /**
  54495. * Detaches a camera from the pipeline
  54496. * @param renderPipelineName The name of the pipeline to detach from
  54497. * @param cameras the camera to detach
  54498. */
  54499. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  54500. /**
  54501. * Enables an effect by name on a pipeline
  54502. * @param renderPipelineName the name of the pipeline to enable the effect in
  54503. * @param renderEffectName the name of the effect to enable
  54504. * @param cameras the cameras that the effect should be enabled on
  54505. */
  54506. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54507. /**
  54508. * Disables an effect by name on a pipeline
  54509. * @param renderPipelineName the name of the pipeline to disable the effect in
  54510. * @param renderEffectName the name of the effect to disable
  54511. * @param cameras the cameras that the effect should be disabled on
  54512. */
  54513. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54514. /**
  54515. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  54516. */
  54517. update(): void;
  54518. /** @hidden */
  54519. _rebuild(): void;
  54520. /**
  54521. * Disposes of the manager and pipelines
  54522. */
  54523. dispose(): void;
  54524. }
  54525. }
  54526. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  54527. import { ISceneComponent } from "babylonjs/sceneComponent";
  54528. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  54529. import { Scene } from "babylonjs/scene";
  54530. module "babylonjs/scene" {
  54531. interface Scene {
  54532. /** @hidden (Backing field) */
  54533. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54534. /**
  54535. * Gets the postprocess render pipeline manager
  54536. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54537. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54538. */
  54539. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54540. }
  54541. }
  54542. /**
  54543. * Defines the Render Pipeline scene component responsible to rendering pipelines
  54544. */
  54545. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  54546. /**
  54547. * The component name helpfull to identify the component in the list of scene components.
  54548. */
  54549. readonly name: string;
  54550. /**
  54551. * The scene the component belongs to.
  54552. */
  54553. scene: Scene;
  54554. /**
  54555. * Creates a new instance of the component for the given scene
  54556. * @param scene Defines the scene to register the component in
  54557. */
  54558. constructor(scene: Scene);
  54559. /**
  54560. * Registers the component in a given scene
  54561. */
  54562. register(): void;
  54563. /**
  54564. * Rebuilds the elements related to this component in case of
  54565. * context lost for instance.
  54566. */
  54567. rebuild(): void;
  54568. /**
  54569. * Disposes the component and the associated ressources
  54570. */
  54571. dispose(): void;
  54572. private _gatherRenderTargets;
  54573. }
  54574. }
  54575. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  54576. import { IAnimatable } from "babylonjs/Misc/tools";
  54577. import { Camera } from "babylonjs/Cameras/camera";
  54578. import { IDisposable } from "babylonjs/scene";
  54579. import { Scene } from "babylonjs/scene";
  54580. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  54581. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  54582. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  54583. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  54584. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  54585. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54586. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  54587. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  54588. import { Animation } from "babylonjs/Animations/animation";
  54589. /**
  54590. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  54591. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54592. */
  54593. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54594. private _scene;
  54595. private _camerasToBeAttached;
  54596. /**
  54597. * ID of the sharpen post process,
  54598. */
  54599. private readonly SharpenPostProcessId;
  54600. /**
  54601. * @ignore
  54602. * ID of the image processing post process;
  54603. */
  54604. readonly ImageProcessingPostProcessId: string;
  54605. /**
  54606. * @ignore
  54607. * ID of the Fast Approximate Anti-Aliasing post process;
  54608. */
  54609. readonly FxaaPostProcessId: string;
  54610. /**
  54611. * ID of the chromatic aberration post process,
  54612. */
  54613. private readonly ChromaticAberrationPostProcessId;
  54614. /**
  54615. * ID of the grain post process
  54616. */
  54617. private readonly GrainPostProcessId;
  54618. /**
  54619. * Sharpen post process which will apply a sharpen convolution to enhance edges
  54620. */
  54621. sharpen: SharpenPostProcess;
  54622. private _sharpenEffect;
  54623. private bloom;
  54624. /**
  54625. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  54626. */
  54627. depthOfField: DepthOfFieldEffect;
  54628. /**
  54629. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54630. */
  54631. fxaa: FxaaPostProcess;
  54632. /**
  54633. * Image post processing pass used to perform operations such as tone mapping or color grading.
  54634. */
  54635. imageProcessing: ImageProcessingPostProcess;
  54636. /**
  54637. * Chromatic aberration post process which will shift rgb colors in the image
  54638. */
  54639. chromaticAberration: ChromaticAberrationPostProcess;
  54640. private _chromaticAberrationEffect;
  54641. /**
  54642. * Grain post process which add noise to the image
  54643. */
  54644. grain: GrainPostProcess;
  54645. private _grainEffect;
  54646. /**
  54647. * Glow post process which adds a glow to emissive areas of the image
  54648. */
  54649. private _glowLayer;
  54650. /**
  54651. * Animations which can be used to tweak settings over a period of time
  54652. */
  54653. animations: Animation[];
  54654. private _imageProcessingConfigurationObserver;
  54655. private _sharpenEnabled;
  54656. private _bloomEnabled;
  54657. private _depthOfFieldEnabled;
  54658. private _depthOfFieldBlurLevel;
  54659. private _fxaaEnabled;
  54660. private _imageProcessingEnabled;
  54661. private _defaultPipelineTextureType;
  54662. private _bloomScale;
  54663. private _chromaticAberrationEnabled;
  54664. private _grainEnabled;
  54665. private _buildAllowed;
  54666. /**
  54667. * Gets active scene
  54668. */
  54669. readonly scene: Scene;
  54670. /**
  54671. * Enable or disable the sharpen process from the pipeline
  54672. */
  54673. sharpenEnabled: boolean;
  54674. private _resizeObserver;
  54675. private _hardwareScaleLevel;
  54676. private _bloomKernel;
  54677. /**
  54678. * Specifies the size of the bloom blur kernel, relative to the final output size
  54679. */
  54680. bloomKernel: number;
  54681. /**
  54682. * Specifies the weight of the bloom in the final rendering
  54683. */
  54684. private _bloomWeight;
  54685. /**
  54686. * Specifies the luma threshold for the area that will be blurred by the bloom
  54687. */
  54688. private _bloomThreshold;
  54689. private _hdr;
  54690. /**
  54691. * The strength of the bloom.
  54692. */
  54693. bloomWeight: number;
  54694. /**
  54695. * The strength of the bloom.
  54696. */
  54697. bloomThreshold: number;
  54698. /**
  54699. * The scale of the bloom, lower value will provide better performance.
  54700. */
  54701. bloomScale: number;
  54702. /**
  54703. * Enable or disable the bloom from the pipeline
  54704. */
  54705. bloomEnabled: boolean;
  54706. private _rebuildBloom;
  54707. /**
  54708. * If the depth of field is enabled.
  54709. */
  54710. depthOfFieldEnabled: boolean;
  54711. /**
  54712. * Blur level of the depth of field effect. (Higher blur will effect performance)
  54713. */
  54714. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  54715. /**
  54716. * If the anti aliasing is enabled.
  54717. */
  54718. fxaaEnabled: boolean;
  54719. private _samples;
  54720. /**
  54721. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54722. */
  54723. samples: number;
  54724. /**
  54725. * If image processing is enabled.
  54726. */
  54727. imageProcessingEnabled: boolean;
  54728. /**
  54729. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  54730. */
  54731. glowLayerEnabled: boolean;
  54732. /**
  54733. * Enable or disable the chromaticAberration process from the pipeline
  54734. */
  54735. chromaticAberrationEnabled: boolean;
  54736. /**
  54737. * Enable or disable the grain process from the pipeline
  54738. */
  54739. grainEnabled: boolean;
  54740. /**
  54741. * @constructor
  54742. * @param name - The rendering pipeline name (default: "")
  54743. * @param hdr - If high dynamic range textures should be used (default: true)
  54744. * @param scene - The scene linked to this pipeline (default: the last created scene)
  54745. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  54746. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  54747. */
  54748. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  54749. /**
  54750. * Get the class name
  54751. * @returns "DefaultRenderingPipeline"
  54752. */
  54753. getClassName(): string;
  54754. /**
  54755. * Force the compilation of the entire pipeline.
  54756. */
  54757. prepare(): void;
  54758. private _hasCleared;
  54759. private _prevPostProcess;
  54760. private _prevPrevPostProcess;
  54761. private _setAutoClearAndTextureSharing;
  54762. private _depthOfFieldSceneObserver;
  54763. private _buildPipeline;
  54764. private _disposePostProcesses;
  54765. /**
  54766. * Adds a camera to the pipeline
  54767. * @param camera the camera to be added
  54768. */
  54769. addCamera(camera: Camera): void;
  54770. /**
  54771. * Removes a camera from the pipeline
  54772. * @param camera the camera to remove
  54773. */
  54774. removeCamera(camera: Camera): void;
  54775. /**
  54776. * Dispose of the pipeline and stop all post processes
  54777. */
  54778. dispose(): void;
  54779. /**
  54780. * Serialize the rendering pipeline (Used when exporting)
  54781. * @returns the serialized object
  54782. */
  54783. serialize(): any;
  54784. /**
  54785. * Parse the serialized pipeline
  54786. * @param source Source pipeline.
  54787. * @param scene The scene to load the pipeline to.
  54788. * @param rootUrl The URL of the serialized pipeline.
  54789. * @returns An instantiated pipeline from the serialized object.
  54790. */
  54791. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  54792. }
  54793. }
  54794. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  54795. /** @hidden */
  54796. export var lensHighlightsPixelShader: {
  54797. name: string;
  54798. shader: string;
  54799. };
  54800. }
  54801. declare module "babylonjs/Shaders/depthOfField.fragment" {
  54802. /** @hidden */
  54803. export var depthOfFieldPixelShader: {
  54804. name: string;
  54805. shader: string;
  54806. };
  54807. }
  54808. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  54809. import { Camera } from "babylonjs/Cameras/camera";
  54810. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  54811. import { Scene } from "babylonjs/scene";
  54812. import "babylonjs/Shaders/chromaticAberration.fragment";
  54813. import "babylonjs/Shaders/lensHighlights.fragment";
  54814. import "babylonjs/Shaders/depthOfField.fragment";
  54815. /**
  54816. * BABYLON.JS Chromatic Aberration GLSL Shader
  54817. * Author: Olivier Guyot
  54818. * Separates very slightly R, G and B colors on the edges of the screen
  54819. * Inspired by Francois Tarlier & Martins Upitis
  54820. */
  54821. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  54822. /**
  54823. * @ignore
  54824. * The chromatic aberration PostProcess id in the pipeline
  54825. */
  54826. LensChromaticAberrationEffect: string;
  54827. /**
  54828. * @ignore
  54829. * The highlights enhancing PostProcess id in the pipeline
  54830. */
  54831. HighlightsEnhancingEffect: string;
  54832. /**
  54833. * @ignore
  54834. * The depth-of-field PostProcess id in the pipeline
  54835. */
  54836. LensDepthOfFieldEffect: string;
  54837. private _scene;
  54838. private _depthTexture;
  54839. private _grainTexture;
  54840. private _chromaticAberrationPostProcess;
  54841. private _highlightsPostProcess;
  54842. private _depthOfFieldPostProcess;
  54843. private _edgeBlur;
  54844. private _grainAmount;
  54845. private _chromaticAberration;
  54846. private _distortion;
  54847. private _highlightsGain;
  54848. private _highlightsThreshold;
  54849. private _dofDistance;
  54850. private _dofAperture;
  54851. private _dofDarken;
  54852. private _dofPentagon;
  54853. private _blurNoise;
  54854. /**
  54855. * @constructor
  54856. *
  54857. * Effect parameters are as follow:
  54858. * {
  54859. * chromatic_aberration: number; // from 0 to x (1 for realism)
  54860. * edge_blur: number; // from 0 to x (1 for realism)
  54861. * distortion: number; // from 0 to x (1 for realism)
  54862. * grain_amount: number; // from 0 to 1
  54863. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  54864. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  54865. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  54866. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  54867. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  54868. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  54869. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  54870. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  54871. * }
  54872. * Note: if an effect parameter is unset, effect is disabled
  54873. *
  54874. * @param name The rendering pipeline name
  54875. * @param parameters - An object containing all parameters (see above)
  54876. * @param scene The scene linked to this pipeline
  54877. * @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)
  54878. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54879. */
  54880. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  54881. /**
  54882. * Get the class name
  54883. * @returns "LensRenderingPipeline"
  54884. */
  54885. getClassName(): string;
  54886. /**
  54887. * Gets associated scene
  54888. */
  54889. readonly scene: Scene;
  54890. /**
  54891. * Gets or sets the edge blur
  54892. */
  54893. edgeBlur: number;
  54894. /**
  54895. * Gets or sets the grain amount
  54896. */
  54897. grainAmount: number;
  54898. /**
  54899. * Gets or sets the chromatic aberration amount
  54900. */
  54901. chromaticAberration: number;
  54902. /**
  54903. * Gets or sets the depth of field aperture
  54904. */
  54905. dofAperture: number;
  54906. /**
  54907. * Gets or sets the edge distortion
  54908. */
  54909. edgeDistortion: number;
  54910. /**
  54911. * Gets or sets the depth of field distortion
  54912. */
  54913. dofDistortion: number;
  54914. /**
  54915. * Gets or sets the darken out of focus amount
  54916. */
  54917. darkenOutOfFocus: number;
  54918. /**
  54919. * Gets or sets a boolean indicating if blur noise is enabled
  54920. */
  54921. blurNoise: boolean;
  54922. /**
  54923. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  54924. */
  54925. pentagonBokeh: boolean;
  54926. /**
  54927. * Gets or sets the highlight grain amount
  54928. */
  54929. highlightsGain: number;
  54930. /**
  54931. * Gets or sets the highlight threshold
  54932. */
  54933. highlightsThreshold: number;
  54934. /**
  54935. * Sets the amount of blur at the edges
  54936. * @param amount blur amount
  54937. */
  54938. setEdgeBlur(amount: number): void;
  54939. /**
  54940. * Sets edge blur to 0
  54941. */
  54942. disableEdgeBlur(): void;
  54943. /**
  54944. * Sets the amout of grain
  54945. * @param amount Amount of grain
  54946. */
  54947. setGrainAmount(amount: number): void;
  54948. /**
  54949. * Set grain amount to 0
  54950. */
  54951. disableGrain(): void;
  54952. /**
  54953. * Sets the chromatic aberration amount
  54954. * @param amount amount of chromatic aberration
  54955. */
  54956. setChromaticAberration(amount: number): void;
  54957. /**
  54958. * Sets chromatic aberration amount to 0
  54959. */
  54960. disableChromaticAberration(): void;
  54961. /**
  54962. * Sets the EdgeDistortion amount
  54963. * @param amount amount of EdgeDistortion
  54964. */
  54965. setEdgeDistortion(amount: number): void;
  54966. /**
  54967. * Sets edge distortion to 0
  54968. */
  54969. disableEdgeDistortion(): void;
  54970. /**
  54971. * Sets the FocusDistance amount
  54972. * @param amount amount of FocusDistance
  54973. */
  54974. setFocusDistance(amount: number): void;
  54975. /**
  54976. * Disables depth of field
  54977. */
  54978. disableDepthOfField(): void;
  54979. /**
  54980. * Sets the Aperture amount
  54981. * @param amount amount of Aperture
  54982. */
  54983. setAperture(amount: number): void;
  54984. /**
  54985. * Sets the DarkenOutOfFocus amount
  54986. * @param amount amount of DarkenOutOfFocus
  54987. */
  54988. setDarkenOutOfFocus(amount: number): void;
  54989. private _pentagonBokehIsEnabled;
  54990. /**
  54991. * Creates a pentagon bokeh effect
  54992. */
  54993. enablePentagonBokeh(): void;
  54994. /**
  54995. * Disables the pentagon bokeh effect
  54996. */
  54997. disablePentagonBokeh(): void;
  54998. /**
  54999. * Enables noise blur
  55000. */
  55001. enableNoiseBlur(): void;
  55002. /**
  55003. * Disables noise blur
  55004. */
  55005. disableNoiseBlur(): void;
  55006. /**
  55007. * Sets the HighlightsGain amount
  55008. * @param amount amount of HighlightsGain
  55009. */
  55010. setHighlightsGain(amount: number): void;
  55011. /**
  55012. * Sets the HighlightsThreshold amount
  55013. * @param amount amount of HighlightsThreshold
  55014. */
  55015. setHighlightsThreshold(amount: number): void;
  55016. /**
  55017. * Disables highlights
  55018. */
  55019. disableHighlights(): void;
  55020. /**
  55021. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  55022. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  55023. */
  55024. dispose(disableDepthRender?: boolean): void;
  55025. private _createChromaticAberrationPostProcess;
  55026. private _createHighlightsPostProcess;
  55027. private _createDepthOfFieldPostProcess;
  55028. private _createGrainTexture;
  55029. }
  55030. }
  55031. declare module "babylonjs/Shaders/ssao2.fragment" {
  55032. /** @hidden */
  55033. export var ssao2PixelShader: {
  55034. name: string;
  55035. shader: string;
  55036. };
  55037. }
  55038. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  55039. /** @hidden */
  55040. export var ssaoCombinePixelShader: {
  55041. name: string;
  55042. shader: string;
  55043. };
  55044. }
  55045. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  55046. import { Camera } from "babylonjs/Cameras/camera";
  55047. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55048. import { Scene } from "babylonjs/scene";
  55049. import "babylonjs/Shaders/ssao2.fragment";
  55050. import "babylonjs/Shaders/ssaoCombine.fragment";
  55051. /**
  55052. * Render pipeline to produce ssao effect
  55053. */
  55054. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  55055. /**
  55056. * @ignore
  55057. * The PassPostProcess id in the pipeline that contains the original scene color
  55058. */
  55059. SSAOOriginalSceneColorEffect: string;
  55060. /**
  55061. * @ignore
  55062. * The SSAO PostProcess id in the pipeline
  55063. */
  55064. SSAORenderEffect: string;
  55065. /**
  55066. * @ignore
  55067. * The horizontal blur PostProcess id in the pipeline
  55068. */
  55069. SSAOBlurHRenderEffect: string;
  55070. /**
  55071. * @ignore
  55072. * The vertical blur PostProcess id in the pipeline
  55073. */
  55074. SSAOBlurVRenderEffect: string;
  55075. /**
  55076. * @ignore
  55077. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55078. */
  55079. SSAOCombineRenderEffect: string;
  55080. /**
  55081. * The output strength of the SSAO post-process. Default value is 1.0.
  55082. */
  55083. totalStrength: number;
  55084. /**
  55085. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  55086. */
  55087. maxZ: number;
  55088. /**
  55089. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  55090. */
  55091. minZAspect: number;
  55092. private _samples;
  55093. /**
  55094. * Number of samples used for the SSAO calculations. Default value is 8
  55095. */
  55096. samples: number;
  55097. private _textureSamples;
  55098. /**
  55099. * Number of samples to use for antialiasing
  55100. */
  55101. textureSamples: number;
  55102. /**
  55103. * Ratio object used for SSAO ratio and blur ratio
  55104. */
  55105. private _ratio;
  55106. /**
  55107. * Dynamically generated sphere sampler.
  55108. */
  55109. private _sampleSphere;
  55110. /**
  55111. * Blur filter offsets
  55112. */
  55113. private _samplerOffsets;
  55114. private _expensiveBlur;
  55115. /**
  55116. * If bilateral blur should be used
  55117. */
  55118. expensiveBlur: boolean;
  55119. /**
  55120. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  55121. */
  55122. radius: number;
  55123. /**
  55124. * The base color of the SSAO post-process
  55125. * The final result is "base + ssao" between [0, 1]
  55126. */
  55127. base: number;
  55128. /**
  55129. * Support test.
  55130. */
  55131. static readonly IsSupported: boolean;
  55132. private _scene;
  55133. private _depthTexture;
  55134. private _normalTexture;
  55135. private _randomTexture;
  55136. private _originalColorPostProcess;
  55137. private _ssaoPostProcess;
  55138. private _blurHPostProcess;
  55139. private _blurVPostProcess;
  55140. private _ssaoCombinePostProcess;
  55141. private _firstUpdate;
  55142. /**
  55143. * Gets active scene
  55144. */
  55145. readonly scene: Scene;
  55146. /**
  55147. * @constructor
  55148. * @param name The rendering pipeline name
  55149. * @param scene The scene linked to this pipeline
  55150. * @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 }
  55151. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55152. */
  55153. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55154. /**
  55155. * Get the class name
  55156. * @returns "SSAO2RenderingPipeline"
  55157. */
  55158. getClassName(): string;
  55159. /**
  55160. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55161. */
  55162. dispose(disableGeometryBufferRenderer?: boolean): void;
  55163. private _createBlurPostProcess;
  55164. /** @hidden */
  55165. _rebuild(): void;
  55166. private _bits;
  55167. private _radicalInverse_VdC;
  55168. private _hammersley;
  55169. private _hemisphereSample_uniform;
  55170. private _generateHemisphere;
  55171. private _createSSAOPostProcess;
  55172. private _createSSAOCombinePostProcess;
  55173. private _createRandomTexture;
  55174. /**
  55175. * Serialize the rendering pipeline (Used when exporting)
  55176. * @returns the serialized object
  55177. */
  55178. serialize(): any;
  55179. /**
  55180. * Parse the serialized pipeline
  55181. * @param source Source pipeline.
  55182. * @param scene The scene to load the pipeline to.
  55183. * @param rootUrl The URL of the serialized pipeline.
  55184. * @returns An instantiated pipeline from the serialized object.
  55185. */
  55186. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  55187. }
  55188. }
  55189. declare module "babylonjs/Shaders/ssao.fragment" {
  55190. /** @hidden */
  55191. export var ssaoPixelShader: {
  55192. name: string;
  55193. shader: string;
  55194. };
  55195. }
  55196. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  55197. import { Camera } from "babylonjs/Cameras/camera";
  55198. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55199. import { Scene } from "babylonjs/scene";
  55200. import "babylonjs/Shaders/ssao.fragment";
  55201. import "babylonjs/Shaders/ssaoCombine.fragment";
  55202. /**
  55203. * Render pipeline to produce ssao effect
  55204. */
  55205. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  55206. /**
  55207. * @ignore
  55208. * The PassPostProcess id in the pipeline that contains the original scene color
  55209. */
  55210. SSAOOriginalSceneColorEffect: string;
  55211. /**
  55212. * @ignore
  55213. * The SSAO PostProcess id in the pipeline
  55214. */
  55215. SSAORenderEffect: string;
  55216. /**
  55217. * @ignore
  55218. * The horizontal blur PostProcess id in the pipeline
  55219. */
  55220. SSAOBlurHRenderEffect: string;
  55221. /**
  55222. * @ignore
  55223. * The vertical blur PostProcess id in the pipeline
  55224. */
  55225. SSAOBlurVRenderEffect: string;
  55226. /**
  55227. * @ignore
  55228. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55229. */
  55230. SSAOCombineRenderEffect: string;
  55231. /**
  55232. * The output strength of the SSAO post-process. Default value is 1.0.
  55233. */
  55234. totalStrength: number;
  55235. /**
  55236. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  55237. */
  55238. radius: number;
  55239. /**
  55240. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  55241. * Must not be equal to fallOff and superior to fallOff.
  55242. * Default value is 0.0075
  55243. */
  55244. area: number;
  55245. /**
  55246. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  55247. * Must not be equal to area and inferior to area.
  55248. * Default value is 0.000001
  55249. */
  55250. fallOff: number;
  55251. /**
  55252. * The base color of the SSAO post-process
  55253. * The final result is "base + ssao" between [0, 1]
  55254. */
  55255. base: number;
  55256. private _scene;
  55257. private _depthTexture;
  55258. private _randomTexture;
  55259. private _originalColorPostProcess;
  55260. private _ssaoPostProcess;
  55261. private _blurHPostProcess;
  55262. private _blurVPostProcess;
  55263. private _ssaoCombinePostProcess;
  55264. private _firstUpdate;
  55265. /**
  55266. * Gets active scene
  55267. */
  55268. readonly scene: Scene;
  55269. /**
  55270. * @constructor
  55271. * @param name - The rendering pipeline name
  55272. * @param scene - The scene linked to this pipeline
  55273. * @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 }
  55274. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  55275. */
  55276. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55277. /**
  55278. * Get the class name
  55279. * @returns "SSAORenderingPipeline"
  55280. */
  55281. getClassName(): string;
  55282. /**
  55283. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55284. */
  55285. dispose(disableDepthRender?: boolean): void;
  55286. private _createBlurPostProcess;
  55287. /** @hidden */
  55288. _rebuild(): void;
  55289. private _createSSAOPostProcess;
  55290. private _createSSAOCombinePostProcess;
  55291. private _createRandomTexture;
  55292. }
  55293. }
  55294. declare module "babylonjs/Shaders/standard.fragment" {
  55295. /** @hidden */
  55296. export var standardPixelShader: {
  55297. name: string;
  55298. shader: string;
  55299. };
  55300. }
  55301. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  55302. import { Nullable } from "babylonjs/types";
  55303. import { IAnimatable } from "babylonjs/Misc/tools";
  55304. import { Camera } from "babylonjs/Cameras/camera";
  55305. import { Texture } from "babylonjs/Materials/Textures/texture";
  55306. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55307. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55308. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  55309. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  55310. import { IDisposable } from "babylonjs/scene";
  55311. import { SpotLight } from "babylonjs/Lights/spotLight";
  55312. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  55313. import { Scene } from "babylonjs/scene";
  55314. import { Animation } from "babylonjs/Animations/animation";
  55315. import "babylonjs/Shaders/standard.fragment";
  55316. /**
  55317. * Standard rendering pipeline
  55318. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  55319. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  55320. */
  55321. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55322. /**
  55323. * Public members
  55324. */
  55325. /**
  55326. * Post-process which contains the original scene color before the pipeline applies all the effects
  55327. */
  55328. originalPostProcess: Nullable<PostProcess>;
  55329. /**
  55330. * Post-process used to down scale an image x4
  55331. */
  55332. downSampleX4PostProcess: Nullable<PostProcess>;
  55333. /**
  55334. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  55335. */
  55336. brightPassPostProcess: Nullable<PostProcess>;
  55337. /**
  55338. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  55339. */
  55340. blurHPostProcesses: PostProcess[];
  55341. /**
  55342. * Post-process array storing all the vertical blur post-processes used by the pipeline
  55343. */
  55344. blurVPostProcesses: PostProcess[];
  55345. /**
  55346. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  55347. */
  55348. textureAdderPostProcess: Nullable<PostProcess>;
  55349. /**
  55350. * Post-process used to create volumetric lighting effect
  55351. */
  55352. volumetricLightPostProcess: Nullable<PostProcess>;
  55353. /**
  55354. * Post-process used to smooth the previous volumetric light post-process on the X axis
  55355. */
  55356. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  55357. /**
  55358. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  55359. */
  55360. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  55361. /**
  55362. * Post-process used to merge the volumetric light effect and the real scene color
  55363. */
  55364. volumetricLightMergePostProces: Nullable<PostProcess>;
  55365. /**
  55366. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  55367. */
  55368. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  55369. /**
  55370. * Base post-process used to calculate the average luminance of the final image for HDR
  55371. */
  55372. luminancePostProcess: Nullable<PostProcess>;
  55373. /**
  55374. * Post-processes used to create down sample post-processes in order to get
  55375. * the average luminance of the final image for HDR
  55376. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  55377. */
  55378. luminanceDownSamplePostProcesses: PostProcess[];
  55379. /**
  55380. * Post-process used to create a HDR effect (light adaptation)
  55381. */
  55382. hdrPostProcess: Nullable<PostProcess>;
  55383. /**
  55384. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  55385. */
  55386. textureAdderFinalPostProcess: Nullable<PostProcess>;
  55387. /**
  55388. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  55389. */
  55390. lensFlareFinalPostProcess: Nullable<PostProcess>;
  55391. /**
  55392. * Post-process used to merge the final HDR post-process and the real scene color
  55393. */
  55394. hdrFinalPostProcess: Nullable<PostProcess>;
  55395. /**
  55396. * Post-process used to create a lens flare effect
  55397. */
  55398. lensFlarePostProcess: Nullable<PostProcess>;
  55399. /**
  55400. * Post-process that merges the result of the lens flare post-process and the real scene color
  55401. */
  55402. lensFlareComposePostProcess: Nullable<PostProcess>;
  55403. /**
  55404. * Post-process used to create a motion blur effect
  55405. */
  55406. motionBlurPostProcess: Nullable<PostProcess>;
  55407. /**
  55408. * Post-process used to create a depth of field effect
  55409. */
  55410. depthOfFieldPostProcess: Nullable<PostProcess>;
  55411. /**
  55412. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55413. */
  55414. fxaaPostProcess: Nullable<FxaaPostProcess>;
  55415. /**
  55416. * Represents the brightness threshold in order to configure the illuminated surfaces
  55417. */
  55418. brightThreshold: number;
  55419. /**
  55420. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  55421. */
  55422. blurWidth: number;
  55423. /**
  55424. * Sets if the blur for highlighted surfaces must be only horizontal
  55425. */
  55426. horizontalBlur: boolean;
  55427. /**
  55428. * Sets the overall exposure used by the pipeline
  55429. */
  55430. exposure: number;
  55431. /**
  55432. * Texture used typically to simulate "dirty" on camera lens
  55433. */
  55434. lensTexture: Nullable<Texture>;
  55435. /**
  55436. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  55437. */
  55438. volumetricLightCoefficient: number;
  55439. /**
  55440. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  55441. */
  55442. volumetricLightPower: number;
  55443. /**
  55444. * Used the set the blur intensity to smooth the volumetric lights
  55445. */
  55446. volumetricLightBlurScale: number;
  55447. /**
  55448. * Light (spot or directional) used to generate the volumetric lights rays
  55449. * The source light must have a shadow generate so the pipeline can get its
  55450. * depth map
  55451. */
  55452. sourceLight: Nullable<SpotLight | DirectionalLight>;
  55453. /**
  55454. * For eye adaptation, represents the minimum luminance the eye can see
  55455. */
  55456. hdrMinimumLuminance: number;
  55457. /**
  55458. * For eye adaptation, represents the decrease luminance speed
  55459. */
  55460. hdrDecreaseRate: number;
  55461. /**
  55462. * For eye adaptation, represents the increase luminance speed
  55463. */
  55464. hdrIncreaseRate: number;
  55465. /**
  55466. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  55467. */
  55468. lensColorTexture: Nullable<Texture>;
  55469. /**
  55470. * The overall strengh for the lens flare effect
  55471. */
  55472. lensFlareStrength: number;
  55473. /**
  55474. * Dispersion coefficient for lens flare ghosts
  55475. */
  55476. lensFlareGhostDispersal: number;
  55477. /**
  55478. * Main lens flare halo width
  55479. */
  55480. lensFlareHaloWidth: number;
  55481. /**
  55482. * Based on the lens distortion effect, defines how much the lens flare result
  55483. * is distorted
  55484. */
  55485. lensFlareDistortionStrength: number;
  55486. /**
  55487. * Lens star texture must be used to simulate rays on the flares and is available
  55488. * in the documentation
  55489. */
  55490. lensStarTexture: Nullable<Texture>;
  55491. /**
  55492. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  55493. * flare effect by taking account of the dirt texture
  55494. */
  55495. lensFlareDirtTexture: Nullable<Texture>;
  55496. /**
  55497. * Represents the focal length for the depth of field effect
  55498. */
  55499. depthOfFieldDistance: number;
  55500. /**
  55501. * Represents the blur intensity for the blurred part of the depth of field effect
  55502. */
  55503. depthOfFieldBlurWidth: number;
  55504. /**
  55505. * For motion blur, defines how much the image is blurred by the movement
  55506. */
  55507. motionStrength: number;
  55508. /**
  55509. * List of animations for the pipeline (IAnimatable implementation)
  55510. */
  55511. animations: Animation[];
  55512. /**
  55513. * Private members
  55514. */
  55515. private _scene;
  55516. private _currentDepthOfFieldSource;
  55517. private _basePostProcess;
  55518. private _hdrCurrentLuminance;
  55519. private _floatTextureType;
  55520. private _ratio;
  55521. private _bloomEnabled;
  55522. private _depthOfFieldEnabled;
  55523. private _vlsEnabled;
  55524. private _lensFlareEnabled;
  55525. private _hdrEnabled;
  55526. private _motionBlurEnabled;
  55527. private _fxaaEnabled;
  55528. private _motionBlurSamples;
  55529. private _volumetricLightStepsCount;
  55530. private _samples;
  55531. /**
  55532. * @ignore
  55533. * Specifies if the bloom pipeline is enabled
  55534. */
  55535. BloomEnabled: boolean;
  55536. /**
  55537. * @ignore
  55538. * Specifies if the depth of field pipeline is enabed
  55539. */
  55540. DepthOfFieldEnabled: boolean;
  55541. /**
  55542. * @ignore
  55543. * Specifies if the lens flare pipeline is enabed
  55544. */
  55545. LensFlareEnabled: boolean;
  55546. /**
  55547. * @ignore
  55548. * Specifies if the HDR pipeline is enabled
  55549. */
  55550. HDREnabled: boolean;
  55551. /**
  55552. * @ignore
  55553. * Specifies if the volumetric lights scattering effect is enabled
  55554. */
  55555. VLSEnabled: boolean;
  55556. /**
  55557. * @ignore
  55558. * Specifies if the motion blur effect is enabled
  55559. */
  55560. MotionBlurEnabled: boolean;
  55561. /**
  55562. * Specifies if anti-aliasing is enabled
  55563. */
  55564. fxaaEnabled: boolean;
  55565. /**
  55566. * Specifies the number of steps used to calculate the volumetric lights
  55567. * Typically in interval [50, 200]
  55568. */
  55569. volumetricLightStepsCount: number;
  55570. /**
  55571. * Specifies the number of samples used for the motion blur effect
  55572. * Typically in interval [16, 64]
  55573. */
  55574. motionBlurSamples: number;
  55575. /**
  55576. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55577. */
  55578. samples: number;
  55579. /**
  55580. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  55581. * @constructor
  55582. * @param name The rendering pipeline name
  55583. * @param scene The scene linked to this pipeline
  55584. * @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)
  55585. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  55586. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55587. */
  55588. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  55589. private _buildPipeline;
  55590. private _createDownSampleX4PostProcess;
  55591. private _createBrightPassPostProcess;
  55592. private _createBlurPostProcesses;
  55593. private _createTextureAdderPostProcess;
  55594. private _createVolumetricLightPostProcess;
  55595. private _createLuminancePostProcesses;
  55596. private _createHdrPostProcess;
  55597. private _createLensFlarePostProcess;
  55598. private _createDepthOfFieldPostProcess;
  55599. private _createMotionBlurPostProcess;
  55600. private _getDepthTexture;
  55601. private _disposePostProcesses;
  55602. /**
  55603. * Dispose of the pipeline and stop all post processes
  55604. */
  55605. dispose(): void;
  55606. /**
  55607. * Serialize the rendering pipeline (Used when exporting)
  55608. * @returns the serialized object
  55609. */
  55610. serialize(): any;
  55611. /**
  55612. * Parse the serialized pipeline
  55613. * @param source Source pipeline.
  55614. * @param scene The scene to load the pipeline to.
  55615. * @param rootUrl The URL of the serialized pipeline.
  55616. * @returns An instantiated pipeline from the serialized object.
  55617. */
  55618. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  55619. /**
  55620. * Luminance steps
  55621. */
  55622. static LuminanceSteps: number;
  55623. }
  55624. }
  55625. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  55626. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  55627. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  55628. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  55629. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  55630. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  55631. }
  55632. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  55633. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  55634. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55635. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55636. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  55637. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  55638. }
  55639. declare module "babylonjs/Shaders/tonemap.fragment" {
  55640. /** @hidden */
  55641. export var tonemapPixelShader: {
  55642. name: string;
  55643. shader: string;
  55644. };
  55645. }
  55646. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  55647. import { Camera } from "babylonjs/Cameras/camera";
  55648. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55649. import "babylonjs/Shaders/tonemap.fragment";
  55650. import { Engine } from "babylonjs/Engines/engine";
  55651. /** Defines operator used for tonemapping */
  55652. export enum TonemappingOperator {
  55653. /** Hable */
  55654. Hable = 0,
  55655. /** Reinhard */
  55656. Reinhard = 1,
  55657. /** HejiDawson */
  55658. HejiDawson = 2,
  55659. /** Photographic */
  55660. Photographic = 3
  55661. }
  55662. /**
  55663. * Defines a post process to apply tone mapping
  55664. */
  55665. export class TonemapPostProcess extends PostProcess {
  55666. private _operator;
  55667. /** Defines the required exposure adjustement */
  55668. exposureAdjustment: number;
  55669. /**
  55670. * Creates a new TonemapPostProcess
  55671. * @param name defines the name of the postprocess
  55672. * @param _operator defines the operator to use
  55673. * @param exposureAdjustment defines the required exposure adjustement
  55674. * @param camera defines the camera to use (can be null)
  55675. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  55676. * @param engine defines the hosting engine (can be ignore if camera is set)
  55677. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55678. */
  55679. constructor(name: string, _operator: TonemappingOperator,
  55680. /** Defines the required exposure adjustement */
  55681. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  55682. }
  55683. }
  55684. declare module "babylonjs/Shaders/depth.vertex" {
  55685. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55686. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55687. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55688. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55689. /** @hidden */
  55690. export var depthVertexShader: {
  55691. name: string;
  55692. shader: string;
  55693. };
  55694. }
  55695. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  55696. /** @hidden */
  55697. export var volumetricLightScatteringPixelShader: {
  55698. name: string;
  55699. shader: string;
  55700. };
  55701. }
  55702. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  55703. /** @hidden */
  55704. export var volumetricLightScatteringPassPixelShader: {
  55705. name: string;
  55706. shader: string;
  55707. };
  55708. }
  55709. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  55710. import { Vector3 } from "babylonjs/Maths/math";
  55711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55712. import { Mesh } from "babylonjs/Meshes/mesh";
  55713. import { Camera } from "babylonjs/Cameras/camera";
  55714. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55715. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55716. import { Scene } from "babylonjs/scene";
  55717. import "babylonjs/Meshes/Builders/planeBuilder";
  55718. import "babylonjs/Shaders/depth.vertex";
  55719. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  55720. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  55721. import { Engine } from "babylonjs/Engines/engine";
  55722. /**
  55723. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  55724. */
  55725. export class VolumetricLightScatteringPostProcess extends PostProcess {
  55726. private _volumetricLightScatteringPass;
  55727. private _volumetricLightScatteringRTT;
  55728. private _viewPort;
  55729. private _screenCoordinates;
  55730. private _cachedDefines;
  55731. /**
  55732. * If not undefined, the mesh position is computed from the attached node position
  55733. */
  55734. attachedNode: {
  55735. position: Vector3;
  55736. };
  55737. /**
  55738. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  55739. */
  55740. customMeshPosition: Vector3;
  55741. /**
  55742. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  55743. */
  55744. useCustomMeshPosition: boolean;
  55745. /**
  55746. * If the post-process should inverse the light scattering direction
  55747. */
  55748. invert: boolean;
  55749. /**
  55750. * The internal mesh used by the post-process
  55751. */
  55752. mesh: Mesh;
  55753. /**
  55754. * @hidden
  55755. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  55756. */
  55757. useDiffuseColor: boolean;
  55758. /**
  55759. * Array containing the excluded meshes not rendered in the internal pass
  55760. */
  55761. excludedMeshes: AbstractMesh[];
  55762. /**
  55763. * Controls the overall intensity of the post-process
  55764. */
  55765. exposure: number;
  55766. /**
  55767. * Dissipates each sample's contribution in range [0, 1]
  55768. */
  55769. decay: number;
  55770. /**
  55771. * Controls the overall intensity of each sample
  55772. */
  55773. weight: number;
  55774. /**
  55775. * Controls the density of each sample
  55776. */
  55777. density: number;
  55778. /**
  55779. * @constructor
  55780. * @param name The post-process name
  55781. * @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)
  55782. * @param camera The camera that the post-process will be attached to
  55783. * @param mesh The mesh used to create the light scattering
  55784. * @param samples The post-process quality, default 100
  55785. * @param samplingModeThe post-process filtering mode
  55786. * @param engine The babylon engine
  55787. * @param reusable If the post-process is reusable
  55788. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  55789. */
  55790. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  55791. /**
  55792. * Returns the string "VolumetricLightScatteringPostProcess"
  55793. * @returns "VolumetricLightScatteringPostProcess"
  55794. */
  55795. getClassName(): string;
  55796. private _isReady;
  55797. /**
  55798. * Sets the new light position for light scattering effect
  55799. * @param position The new custom light position
  55800. */
  55801. setCustomMeshPosition(position: Vector3): void;
  55802. /**
  55803. * Returns the light position for light scattering effect
  55804. * @return Vector3 The custom light position
  55805. */
  55806. getCustomMeshPosition(): Vector3;
  55807. /**
  55808. * Disposes the internal assets and detaches the post-process from the camera
  55809. */
  55810. dispose(camera: Camera): void;
  55811. /**
  55812. * Returns the render target texture used by the post-process
  55813. * @return the render target texture used by the post-process
  55814. */
  55815. getPass(): RenderTargetTexture;
  55816. private _meshExcluded;
  55817. private _createPass;
  55818. private _updateMeshScreenCoordinates;
  55819. /**
  55820. * Creates a default mesh for the Volumeric Light Scattering post-process
  55821. * @param name The mesh name
  55822. * @param scene The scene where to create the mesh
  55823. * @return the default mesh
  55824. */
  55825. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  55826. }
  55827. }
  55828. declare module "babylonjs/PostProcesses/index" {
  55829. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  55830. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  55831. export * from "babylonjs/PostProcesses/bloomEffect";
  55832. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  55833. export * from "babylonjs/PostProcesses/blurPostProcess";
  55834. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  55835. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  55836. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  55837. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  55838. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  55839. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  55840. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  55841. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  55842. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  55843. export * from "babylonjs/PostProcesses/filterPostProcess";
  55844. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  55845. export * from "babylonjs/PostProcesses/grainPostProcess";
  55846. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  55847. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  55848. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  55849. export * from "babylonjs/PostProcesses/passPostProcess";
  55850. export * from "babylonjs/PostProcesses/postProcess";
  55851. export * from "babylonjs/PostProcesses/postProcessManager";
  55852. export * from "babylonjs/PostProcesses/refractionPostProcess";
  55853. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  55854. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  55855. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  55856. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  55857. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  55858. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  55859. }
  55860. declare module "babylonjs/Probes/index" {
  55861. export * from "babylonjs/Probes/reflectionProbe";
  55862. }
  55863. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  55864. import { Scene } from "babylonjs/scene";
  55865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55866. import { Color3 } from "babylonjs/Maths/math";
  55867. import { SmartArray } from "babylonjs/Misc/smartArray";
  55868. import { ISceneComponent } from "babylonjs/sceneComponent";
  55869. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  55870. import "babylonjs/Meshes/Builders/boxBuilder";
  55871. import "babylonjs/Shaders/color.fragment";
  55872. import "babylonjs/Shaders/color.vertex";
  55873. module "babylonjs/scene" {
  55874. interface Scene {
  55875. /** @hidden (Backing field) */
  55876. _boundingBoxRenderer: BoundingBoxRenderer;
  55877. /** @hidden (Backing field) */
  55878. _forceShowBoundingBoxes: boolean;
  55879. /**
  55880. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  55881. */
  55882. forceShowBoundingBoxes: boolean;
  55883. /**
  55884. * Gets the bounding box renderer associated with the scene
  55885. * @returns a BoundingBoxRenderer
  55886. */
  55887. getBoundingBoxRenderer(): BoundingBoxRenderer;
  55888. }
  55889. }
  55890. module "babylonjs/Meshes/abstractMesh" {
  55891. interface AbstractMesh {
  55892. /** @hidden (Backing field) */
  55893. _showBoundingBox: boolean;
  55894. /**
  55895. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  55896. */
  55897. showBoundingBox: boolean;
  55898. }
  55899. }
  55900. /**
  55901. * Component responsible of rendering the bounding box of the meshes in a scene.
  55902. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  55903. */
  55904. export class BoundingBoxRenderer implements ISceneComponent {
  55905. /**
  55906. * The component name helpfull to identify the component in the list of scene components.
  55907. */
  55908. readonly name: string;
  55909. /**
  55910. * The scene the component belongs to.
  55911. */
  55912. scene: Scene;
  55913. /**
  55914. * Color of the bounding box lines placed in front of an object
  55915. */
  55916. frontColor: Color3;
  55917. /**
  55918. * Color of the bounding box lines placed behind an object
  55919. */
  55920. backColor: Color3;
  55921. /**
  55922. * Defines if the renderer should show the back lines or not
  55923. */
  55924. showBackLines: boolean;
  55925. /**
  55926. * @hidden
  55927. */
  55928. renderList: SmartArray<BoundingBox>;
  55929. private _colorShader;
  55930. private _vertexBuffers;
  55931. private _indexBuffer;
  55932. /**
  55933. * Instantiates a new bounding box renderer in a scene.
  55934. * @param scene the scene the renderer renders in
  55935. */
  55936. constructor(scene: Scene);
  55937. /**
  55938. * Registers the component in a given scene
  55939. */
  55940. register(): void;
  55941. private _evaluateSubMesh;
  55942. private _activeMesh;
  55943. private _prepareRessources;
  55944. private _createIndexBuffer;
  55945. /**
  55946. * Rebuilds the elements related to this component in case of
  55947. * context lost for instance.
  55948. */
  55949. rebuild(): void;
  55950. /**
  55951. * @hidden
  55952. */
  55953. reset(): void;
  55954. /**
  55955. * Render the bounding boxes of a specific rendering group
  55956. * @param renderingGroupId defines the rendering group to render
  55957. */
  55958. render(renderingGroupId: number): void;
  55959. /**
  55960. * In case of occlusion queries, we can render the occlusion bounding box through this method
  55961. * @param mesh Define the mesh to render the occlusion bounding box for
  55962. */
  55963. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  55964. /**
  55965. * Dispose and release the resources attached to this renderer.
  55966. */
  55967. dispose(): void;
  55968. }
  55969. }
  55970. declare module "babylonjs/Shaders/depth.fragment" {
  55971. /** @hidden */
  55972. export var depthPixelShader: {
  55973. name: string;
  55974. shader: string;
  55975. };
  55976. }
  55977. declare module "babylonjs/Rendering/depthRenderer" {
  55978. import { Nullable } from "babylonjs/types";
  55979. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55980. import { Scene } from "babylonjs/scene";
  55981. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55982. import { Camera } from "babylonjs/Cameras/camera";
  55983. import "babylonjs/Shaders/depth.fragment";
  55984. import "babylonjs/Shaders/depth.vertex";
  55985. /**
  55986. * This represents a depth renderer in Babylon.
  55987. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  55988. */
  55989. export class DepthRenderer {
  55990. private _scene;
  55991. private _depthMap;
  55992. private _effect;
  55993. private _cachedDefines;
  55994. private _camera;
  55995. /**
  55996. * Specifiess that the depth renderer will only be used within
  55997. * the camera it is created for.
  55998. * This can help forcing its rendering during the camera processing.
  55999. */
  56000. useOnlyInActiveCamera: boolean;
  56001. /** @hidden */
  56002. static _SceneComponentInitialization: (scene: Scene) => void;
  56003. /**
  56004. * Instantiates a depth renderer
  56005. * @param scene The scene the renderer belongs to
  56006. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56007. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56008. */
  56009. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  56010. /**
  56011. * Creates the depth rendering effect and checks if the effect is ready.
  56012. * @param subMesh The submesh to be used to render the depth map of
  56013. * @param useInstances If multiple world instances should be used
  56014. * @returns if the depth renderer is ready to render the depth map
  56015. */
  56016. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56017. /**
  56018. * Gets the texture which the depth map will be written to.
  56019. * @returns The depth map texture
  56020. */
  56021. getDepthMap(): RenderTargetTexture;
  56022. /**
  56023. * Disposes of the depth renderer.
  56024. */
  56025. dispose(): void;
  56026. }
  56027. }
  56028. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  56029. import { Nullable } from "babylonjs/types";
  56030. import { Scene } from "babylonjs/scene";
  56031. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56032. import { Camera } from "babylonjs/Cameras/camera";
  56033. import { ISceneComponent } from "babylonjs/sceneComponent";
  56034. module "babylonjs/scene" {
  56035. interface Scene {
  56036. /** @hidden (Backing field) */
  56037. _depthRenderer: {
  56038. [id: string]: DepthRenderer;
  56039. };
  56040. /**
  56041. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  56042. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  56043. * @returns the created depth renderer
  56044. */
  56045. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  56046. /**
  56047. * Disables a depth renderer for a given camera
  56048. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  56049. */
  56050. disableDepthRenderer(camera?: Nullable<Camera>): void;
  56051. }
  56052. }
  56053. /**
  56054. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  56055. * in several rendering techniques.
  56056. */
  56057. export class DepthRendererSceneComponent implements ISceneComponent {
  56058. /**
  56059. * The component name helpfull to identify the component in the list of scene components.
  56060. */
  56061. readonly name: string;
  56062. /**
  56063. * The scene the component belongs to.
  56064. */
  56065. scene: Scene;
  56066. /**
  56067. * Creates a new instance of the component for the given scene
  56068. * @param scene Defines the scene to register the component in
  56069. */
  56070. constructor(scene: Scene);
  56071. /**
  56072. * Registers the component in a given scene
  56073. */
  56074. register(): void;
  56075. /**
  56076. * Rebuilds the elements related to this component in case of
  56077. * context lost for instance.
  56078. */
  56079. rebuild(): void;
  56080. /**
  56081. * Disposes the component and the associated ressources
  56082. */
  56083. dispose(): void;
  56084. private _gatherRenderTargets;
  56085. private _gatherActiveCameraRenderTargets;
  56086. }
  56087. }
  56088. declare module "babylonjs/Shaders/outline.fragment" {
  56089. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56090. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  56091. /** @hidden */
  56092. export var outlinePixelShader: {
  56093. name: string;
  56094. shader: string;
  56095. };
  56096. }
  56097. declare module "babylonjs/Shaders/outline.vertex" {
  56098. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56099. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56100. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  56101. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56102. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56103. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  56104. /** @hidden */
  56105. export var outlineVertexShader: {
  56106. name: string;
  56107. shader: string;
  56108. };
  56109. }
  56110. declare module "babylonjs/Rendering/outlineRenderer" {
  56111. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56112. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  56113. import { Scene } from "babylonjs/scene";
  56114. import { ISceneComponent } from "babylonjs/sceneComponent";
  56115. import "babylonjs/Shaders/outline.fragment";
  56116. import "babylonjs/Shaders/outline.vertex";
  56117. module "babylonjs/scene" {
  56118. interface Scene {
  56119. /** @hidden */
  56120. _outlineRenderer: OutlineRenderer;
  56121. /**
  56122. * Gets the outline renderer associated with the scene
  56123. * @returns a OutlineRenderer
  56124. */
  56125. getOutlineRenderer(): OutlineRenderer;
  56126. }
  56127. }
  56128. module "babylonjs/Meshes/abstractMesh" {
  56129. interface AbstractMesh {
  56130. /** @hidden (Backing field) */
  56131. _renderOutline: boolean;
  56132. /**
  56133. * Gets or sets a boolean indicating if the outline must be rendered as well
  56134. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  56135. */
  56136. renderOutline: boolean;
  56137. /** @hidden (Backing field) */
  56138. _renderOverlay: boolean;
  56139. /**
  56140. * Gets or sets a boolean indicating if the overlay must be rendered as well
  56141. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  56142. */
  56143. renderOverlay: boolean;
  56144. }
  56145. }
  56146. /**
  56147. * This class is responsible to draw bothe outline/overlay of meshes.
  56148. * It should not be used directly but through the available method on mesh.
  56149. */
  56150. export class OutlineRenderer implements ISceneComponent {
  56151. /**
  56152. * The name of the component. Each component must have a unique name.
  56153. */
  56154. name: string;
  56155. /**
  56156. * The scene the component belongs to.
  56157. */
  56158. scene: Scene;
  56159. /**
  56160. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  56161. */
  56162. zOffset: number;
  56163. private _engine;
  56164. private _effect;
  56165. private _cachedDefines;
  56166. private _savedDepthWrite;
  56167. /**
  56168. * Instantiates a new outline renderer. (There could be only one per scene).
  56169. * @param scene Defines the scene it belongs to
  56170. */
  56171. constructor(scene: Scene);
  56172. /**
  56173. * Register the component to one instance of a scene.
  56174. */
  56175. register(): void;
  56176. /**
  56177. * Rebuilds the elements related to this component in case of
  56178. * context lost for instance.
  56179. */
  56180. rebuild(): void;
  56181. /**
  56182. * Disposes the component and the associated ressources.
  56183. */
  56184. dispose(): void;
  56185. /**
  56186. * Renders the outline in the canvas.
  56187. * @param subMesh Defines the sumesh to render
  56188. * @param batch Defines the batch of meshes in case of instances
  56189. * @param useOverlay Defines if the rendering is for the overlay or the outline
  56190. */
  56191. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  56192. /**
  56193. * Returns whether or not the outline renderer is ready for a given submesh.
  56194. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  56195. * @param subMesh Defines the submesh to check readyness for
  56196. * @param useInstances Defines wheter wee are trying to render instances or not
  56197. * @returns true if ready otherwise false
  56198. */
  56199. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56200. private _beforeRenderingMesh;
  56201. private _afterRenderingMesh;
  56202. }
  56203. }
  56204. declare module "babylonjs/Rendering/index" {
  56205. export * from "babylonjs/Rendering/boundingBoxRenderer";
  56206. export * from "babylonjs/Rendering/depthRenderer";
  56207. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  56208. export * from "babylonjs/Rendering/edgesRenderer";
  56209. export * from "babylonjs/Rendering/geometryBufferRenderer";
  56210. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  56211. export * from "babylonjs/Rendering/outlineRenderer";
  56212. export * from "babylonjs/Rendering/renderingGroup";
  56213. export * from "babylonjs/Rendering/renderingManager";
  56214. export * from "babylonjs/Rendering/utilityLayerRenderer";
  56215. }
  56216. declare module "babylonjs/Sprites/index" {
  56217. export * from "babylonjs/Sprites/sprite";
  56218. export * from "babylonjs/Sprites/spriteManager";
  56219. export * from "babylonjs/Sprites/spriteSceneComponent";
  56220. }
  56221. declare module "babylonjs/Misc/assetsManager" {
  56222. import { Scene } from "babylonjs/scene";
  56223. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56224. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56225. import { Skeleton } from "babylonjs/Bones/skeleton";
  56226. import { Observable } from "babylonjs/Misc/observable";
  56227. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56228. import { Texture } from "babylonjs/Materials/Textures/texture";
  56229. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  56230. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  56231. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  56232. /**
  56233. * Defines the list of states available for a task inside a AssetsManager
  56234. */
  56235. export enum AssetTaskState {
  56236. /**
  56237. * Initialization
  56238. */
  56239. INIT = 0,
  56240. /**
  56241. * Running
  56242. */
  56243. RUNNING = 1,
  56244. /**
  56245. * Done
  56246. */
  56247. DONE = 2,
  56248. /**
  56249. * Error
  56250. */
  56251. ERROR = 3
  56252. }
  56253. /**
  56254. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  56255. */
  56256. export abstract class AbstractAssetTask {
  56257. /**
  56258. * Task name
  56259. */ name: string;
  56260. /**
  56261. * Callback called when the task is successful
  56262. */
  56263. onSuccess: (task: any) => void;
  56264. /**
  56265. * Callback called when the task is not successful
  56266. */
  56267. onError: (task: any, message?: string, exception?: any) => void;
  56268. /**
  56269. * Creates a new AssetsManager
  56270. * @param name defines the name of the task
  56271. */
  56272. constructor(
  56273. /**
  56274. * Task name
  56275. */ name: string);
  56276. private _isCompleted;
  56277. private _taskState;
  56278. private _errorObject;
  56279. /**
  56280. * Get if the task is completed
  56281. */
  56282. readonly isCompleted: boolean;
  56283. /**
  56284. * Gets the current state of the task
  56285. */
  56286. readonly taskState: AssetTaskState;
  56287. /**
  56288. * Gets the current error object (if task is in error)
  56289. */
  56290. readonly errorObject: {
  56291. message?: string;
  56292. exception?: any;
  56293. };
  56294. /**
  56295. * Internal only
  56296. * @hidden
  56297. */
  56298. _setErrorObject(message?: string, exception?: any): void;
  56299. /**
  56300. * Execute the current task
  56301. * @param scene defines the scene where you want your assets to be loaded
  56302. * @param onSuccess is a callback called when the task is successfully executed
  56303. * @param onError is a callback called if an error occurs
  56304. */
  56305. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56306. /**
  56307. * Execute the current task
  56308. * @param scene defines the scene where you want your assets to be loaded
  56309. * @param onSuccess is a callback called when the task is successfully executed
  56310. * @param onError is a callback called if an error occurs
  56311. */
  56312. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56313. /**
  56314. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  56315. * This can be used with failed tasks that have the reason for failure fixed.
  56316. */
  56317. reset(): void;
  56318. private onErrorCallback;
  56319. private onDoneCallback;
  56320. }
  56321. /**
  56322. * Define the interface used by progress events raised during assets loading
  56323. */
  56324. export interface IAssetsProgressEvent {
  56325. /**
  56326. * Defines the number of remaining tasks to process
  56327. */
  56328. remainingCount: number;
  56329. /**
  56330. * Defines the total number of tasks
  56331. */
  56332. totalCount: number;
  56333. /**
  56334. * Defines the task that was just processed
  56335. */
  56336. task: AbstractAssetTask;
  56337. }
  56338. /**
  56339. * Class used to share progress information about assets loading
  56340. */
  56341. export class AssetsProgressEvent implements IAssetsProgressEvent {
  56342. /**
  56343. * Defines the number of remaining tasks to process
  56344. */
  56345. remainingCount: number;
  56346. /**
  56347. * Defines the total number of tasks
  56348. */
  56349. totalCount: number;
  56350. /**
  56351. * Defines the task that was just processed
  56352. */
  56353. task: AbstractAssetTask;
  56354. /**
  56355. * Creates a AssetsProgressEvent
  56356. * @param remainingCount defines the number of remaining tasks to process
  56357. * @param totalCount defines the total number of tasks
  56358. * @param task defines the task that was just processed
  56359. */
  56360. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  56361. }
  56362. /**
  56363. * Define a task used by AssetsManager to load meshes
  56364. */
  56365. export class MeshAssetTask extends AbstractAssetTask {
  56366. /**
  56367. * Defines the name of the task
  56368. */
  56369. name: string;
  56370. /**
  56371. * Defines the list of mesh's names you want to load
  56372. */
  56373. meshesNames: any;
  56374. /**
  56375. * Defines the root url to use as a base to load your meshes and associated resources
  56376. */
  56377. rootUrl: string;
  56378. /**
  56379. * Defines the filename of the scene to load from
  56380. */
  56381. sceneFilename: string;
  56382. /**
  56383. * Gets the list of loaded meshes
  56384. */
  56385. loadedMeshes: Array<AbstractMesh>;
  56386. /**
  56387. * Gets the list of loaded particle systems
  56388. */
  56389. loadedParticleSystems: Array<IParticleSystem>;
  56390. /**
  56391. * Gets the list of loaded skeletons
  56392. */
  56393. loadedSkeletons: Array<Skeleton>;
  56394. /**
  56395. * Gets the list of loaded animation groups
  56396. */
  56397. loadedAnimationGroups: Array<AnimationGroup>;
  56398. /**
  56399. * Callback called when the task is successful
  56400. */
  56401. onSuccess: (task: MeshAssetTask) => void;
  56402. /**
  56403. * Callback called when the task is successful
  56404. */
  56405. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  56406. /**
  56407. * Creates a new MeshAssetTask
  56408. * @param name defines the name of the task
  56409. * @param meshesNames defines the list of mesh's names you want to load
  56410. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  56411. * @param sceneFilename defines the filename of the scene to load from
  56412. */
  56413. constructor(
  56414. /**
  56415. * Defines the name of the task
  56416. */
  56417. name: string,
  56418. /**
  56419. * Defines the list of mesh's names you want to load
  56420. */
  56421. meshesNames: any,
  56422. /**
  56423. * Defines the root url to use as a base to load your meshes and associated resources
  56424. */
  56425. rootUrl: string,
  56426. /**
  56427. * Defines the filename of the scene to load from
  56428. */
  56429. sceneFilename: string);
  56430. /**
  56431. * Execute the current task
  56432. * @param scene defines the scene where you want your assets to be loaded
  56433. * @param onSuccess is a callback called when the task is successfully executed
  56434. * @param onError is a callback called if an error occurs
  56435. */
  56436. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56437. }
  56438. /**
  56439. * Define a task used by AssetsManager to load text content
  56440. */
  56441. export class TextFileAssetTask extends AbstractAssetTask {
  56442. /**
  56443. * Defines the name of the task
  56444. */
  56445. name: string;
  56446. /**
  56447. * Defines the location of the file to load
  56448. */
  56449. url: string;
  56450. /**
  56451. * Gets the loaded text string
  56452. */
  56453. text: string;
  56454. /**
  56455. * Callback called when the task is successful
  56456. */
  56457. onSuccess: (task: TextFileAssetTask) => void;
  56458. /**
  56459. * Callback called when the task is successful
  56460. */
  56461. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  56462. /**
  56463. * Creates a new TextFileAssetTask object
  56464. * @param name defines the name of the task
  56465. * @param url defines the location of the file to load
  56466. */
  56467. constructor(
  56468. /**
  56469. * Defines the name of the task
  56470. */
  56471. name: string,
  56472. /**
  56473. * Defines the location of the file to load
  56474. */
  56475. url: string);
  56476. /**
  56477. * Execute the current task
  56478. * @param scene defines the scene where you want your assets to be loaded
  56479. * @param onSuccess is a callback called when the task is successfully executed
  56480. * @param onError is a callback called if an error occurs
  56481. */
  56482. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56483. }
  56484. /**
  56485. * Define a task used by AssetsManager to load binary data
  56486. */
  56487. export class BinaryFileAssetTask extends AbstractAssetTask {
  56488. /**
  56489. * Defines the name of the task
  56490. */
  56491. name: string;
  56492. /**
  56493. * Defines the location of the file to load
  56494. */
  56495. url: string;
  56496. /**
  56497. * Gets the lodaded data (as an array buffer)
  56498. */
  56499. data: ArrayBuffer;
  56500. /**
  56501. * Callback called when the task is successful
  56502. */
  56503. onSuccess: (task: BinaryFileAssetTask) => void;
  56504. /**
  56505. * Callback called when the task is successful
  56506. */
  56507. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  56508. /**
  56509. * Creates a new BinaryFileAssetTask object
  56510. * @param name defines the name of the new task
  56511. * @param url defines the location of the file to load
  56512. */
  56513. constructor(
  56514. /**
  56515. * Defines the name of the task
  56516. */
  56517. name: string,
  56518. /**
  56519. * Defines the location of the file to load
  56520. */
  56521. url: string);
  56522. /**
  56523. * Execute the current task
  56524. * @param scene defines the scene where you want your assets to be loaded
  56525. * @param onSuccess is a callback called when the task is successfully executed
  56526. * @param onError is a callback called if an error occurs
  56527. */
  56528. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56529. }
  56530. /**
  56531. * Define a task used by AssetsManager to load images
  56532. */
  56533. export class ImageAssetTask extends AbstractAssetTask {
  56534. /**
  56535. * Defines the name of the task
  56536. */
  56537. name: string;
  56538. /**
  56539. * Defines the location of the image to load
  56540. */
  56541. url: string;
  56542. /**
  56543. * Gets the loaded images
  56544. */
  56545. image: HTMLImageElement;
  56546. /**
  56547. * Callback called when the task is successful
  56548. */
  56549. onSuccess: (task: ImageAssetTask) => void;
  56550. /**
  56551. * Callback called when the task is successful
  56552. */
  56553. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  56554. /**
  56555. * Creates a new ImageAssetTask
  56556. * @param name defines the name of the task
  56557. * @param url defines the location of the image to load
  56558. */
  56559. constructor(
  56560. /**
  56561. * Defines the name of the task
  56562. */
  56563. name: string,
  56564. /**
  56565. * Defines the location of the image to load
  56566. */
  56567. url: string);
  56568. /**
  56569. * Execute the current task
  56570. * @param scene defines the scene where you want your assets to be loaded
  56571. * @param onSuccess is a callback called when the task is successfully executed
  56572. * @param onError is a callback called if an error occurs
  56573. */
  56574. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56575. }
  56576. /**
  56577. * Defines the interface used by texture loading tasks
  56578. */
  56579. export interface ITextureAssetTask<TEX extends BaseTexture> {
  56580. /**
  56581. * Gets the loaded texture
  56582. */
  56583. texture: TEX;
  56584. }
  56585. /**
  56586. * Define a task used by AssetsManager to load 2D textures
  56587. */
  56588. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  56589. /**
  56590. * Defines the name of the task
  56591. */
  56592. name: string;
  56593. /**
  56594. * Defines the location of the file to load
  56595. */
  56596. url: string;
  56597. /**
  56598. * Defines if mipmap should not be generated (default is false)
  56599. */
  56600. noMipmap?: boolean | undefined;
  56601. /**
  56602. * Defines if texture must be inverted on Y axis (default is false)
  56603. */
  56604. invertY?: boolean | undefined;
  56605. /**
  56606. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56607. */
  56608. samplingMode: number;
  56609. /**
  56610. * Gets the loaded texture
  56611. */
  56612. texture: Texture;
  56613. /**
  56614. * Callback called when the task is successful
  56615. */
  56616. onSuccess: (task: TextureAssetTask) => void;
  56617. /**
  56618. * Callback called when the task is successful
  56619. */
  56620. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  56621. /**
  56622. * Creates a new TextureAssetTask object
  56623. * @param name defines the name of the task
  56624. * @param url defines the location of the file to load
  56625. * @param noMipmap defines if mipmap should not be generated (default is false)
  56626. * @param invertY defines if texture must be inverted on Y axis (default is false)
  56627. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56628. */
  56629. constructor(
  56630. /**
  56631. * Defines the name of the task
  56632. */
  56633. name: string,
  56634. /**
  56635. * Defines the location of the file to load
  56636. */
  56637. url: string,
  56638. /**
  56639. * Defines if mipmap should not be generated (default is false)
  56640. */
  56641. noMipmap?: boolean | undefined,
  56642. /**
  56643. * Defines if texture must be inverted on Y axis (default is false)
  56644. */
  56645. invertY?: boolean | undefined,
  56646. /**
  56647. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56648. */
  56649. samplingMode?: number);
  56650. /**
  56651. * Execute the current task
  56652. * @param scene defines the scene where you want your assets to be loaded
  56653. * @param onSuccess is a callback called when the task is successfully executed
  56654. * @param onError is a callback called if an error occurs
  56655. */
  56656. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56657. }
  56658. /**
  56659. * Define a task used by AssetsManager to load cube textures
  56660. */
  56661. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  56662. /**
  56663. * Defines the name of the task
  56664. */
  56665. name: string;
  56666. /**
  56667. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56668. */
  56669. url: string;
  56670. /**
  56671. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56672. */
  56673. extensions?: string[] | undefined;
  56674. /**
  56675. * Defines if mipmaps should not be generated (default is false)
  56676. */
  56677. noMipmap?: boolean | undefined;
  56678. /**
  56679. * Defines the explicit list of files (undefined by default)
  56680. */
  56681. files?: string[] | undefined;
  56682. /**
  56683. * Gets the loaded texture
  56684. */
  56685. texture: CubeTexture;
  56686. /**
  56687. * Callback called when the task is successful
  56688. */
  56689. onSuccess: (task: CubeTextureAssetTask) => void;
  56690. /**
  56691. * Callback called when the task is successful
  56692. */
  56693. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  56694. /**
  56695. * Creates a new CubeTextureAssetTask
  56696. * @param name defines the name of the task
  56697. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56698. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56699. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56700. * @param files defines the explicit list of files (undefined by default)
  56701. */
  56702. constructor(
  56703. /**
  56704. * Defines the name of the task
  56705. */
  56706. name: string,
  56707. /**
  56708. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56709. */
  56710. url: string,
  56711. /**
  56712. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56713. */
  56714. extensions?: string[] | undefined,
  56715. /**
  56716. * Defines if mipmaps should not be generated (default is false)
  56717. */
  56718. noMipmap?: boolean | undefined,
  56719. /**
  56720. * Defines the explicit list of files (undefined by default)
  56721. */
  56722. files?: string[] | undefined);
  56723. /**
  56724. * Execute the current task
  56725. * @param scene defines the scene where you want your assets to be loaded
  56726. * @param onSuccess is a callback called when the task is successfully executed
  56727. * @param onError is a callback called if an error occurs
  56728. */
  56729. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56730. }
  56731. /**
  56732. * Define a task used by AssetsManager to load HDR cube textures
  56733. */
  56734. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  56735. /**
  56736. * Defines the name of the task
  56737. */
  56738. name: string;
  56739. /**
  56740. * Defines the location of the file to load
  56741. */
  56742. url: string;
  56743. /**
  56744. * Defines the desired size (the more it increases the longer the generation will be)
  56745. */
  56746. size: number;
  56747. /**
  56748. * Defines if mipmaps should not be generated (default is false)
  56749. */
  56750. noMipmap: boolean;
  56751. /**
  56752. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56753. */
  56754. generateHarmonics: boolean;
  56755. /**
  56756. * 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)
  56757. */
  56758. gammaSpace: boolean;
  56759. /**
  56760. * Internal Use Only
  56761. */
  56762. reserved: boolean;
  56763. /**
  56764. * Gets the loaded texture
  56765. */
  56766. texture: HDRCubeTexture;
  56767. /**
  56768. * Callback called when the task is successful
  56769. */
  56770. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  56771. /**
  56772. * Callback called when the task is successful
  56773. */
  56774. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  56775. /**
  56776. * Creates a new HDRCubeTextureAssetTask object
  56777. * @param name defines the name of the task
  56778. * @param url defines the location of the file to load
  56779. * @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.
  56780. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56781. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56782. * @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)
  56783. * @param reserved Internal use only
  56784. */
  56785. constructor(
  56786. /**
  56787. * Defines the name of the task
  56788. */
  56789. name: string,
  56790. /**
  56791. * Defines the location of the file to load
  56792. */
  56793. url: string,
  56794. /**
  56795. * Defines the desired size (the more it increases the longer the generation will be)
  56796. */
  56797. size: number,
  56798. /**
  56799. * Defines if mipmaps should not be generated (default is false)
  56800. */
  56801. noMipmap?: boolean,
  56802. /**
  56803. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56804. */
  56805. generateHarmonics?: boolean,
  56806. /**
  56807. * 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)
  56808. */
  56809. gammaSpace?: boolean,
  56810. /**
  56811. * Internal Use Only
  56812. */
  56813. reserved?: boolean);
  56814. /**
  56815. * Execute the current task
  56816. * @param scene defines the scene where you want your assets to be loaded
  56817. * @param onSuccess is a callback called when the task is successfully executed
  56818. * @param onError is a callback called if an error occurs
  56819. */
  56820. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56821. }
  56822. /**
  56823. * This class can be used to easily import assets into a scene
  56824. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  56825. */
  56826. export class AssetsManager {
  56827. private _scene;
  56828. private _isLoading;
  56829. protected _tasks: AbstractAssetTask[];
  56830. protected _waitingTasksCount: number;
  56831. protected _totalTasksCount: number;
  56832. /**
  56833. * Callback called when all tasks are processed
  56834. */
  56835. onFinish: (tasks: AbstractAssetTask[]) => void;
  56836. /**
  56837. * Callback called when a task is successful
  56838. */
  56839. onTaskSuccess: (task: AbstractAssetTask) => void;
  56840. /**
  56841. * Callback called when a task had an error
  56842. */
  56843. onTaskError: (task: AbstractAssetTask) => void;
  56844. /**
  56845. * Callback called when a task is done (whatever the result is)
  56846. */
  56847. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  56848. /**
  56849. * Observable called when all tasks are processed
  56850. */
  56851. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  56852. /**
  56853. * Observable called when a task had an error
  56854. */
  56855. onTaskErrorObservable: Observable<AbstractAssetTask>;
  56856. /**
  56857. * Observable called when all tasks were executed
  56858. */
  56859. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  56860. /**
  56861. * Observable called when a task is done (whatever the result is)
  56862. */
  56863. onProgressObservable: Observable<IAssetsProgressEvent>;
  56864. /**
  56865. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  56866. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  56867. */
  56868. useDefaultLoadingScreen: boolean;
  56869. /**
  56870. * Creates a new AssetsManager
  56871. * @param scene defines the scene to work on
  56872. */
  56873. constructor(scene: Scene);
  56874. /**
  56875. * Add a MeshAssetTask to the list of active tasks
  56876. * @param taskName defines the name of the new task
  56877. * @param meshesNames defines the name of meshes to load
  56878. * @param rootUrl defines the root url to use to locate files
  56879. * @param sceneFilename defines the filename of the scene file
  56880. * @returns a new MeshAssetTask object
  56881. */
  56882. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  56883. /**
  56884. * Add a TextFileAssetTask to the list of active tasks
  56885. * @param taskName defines the name of the new task
  56886. * @param url defines the url of the file to load
  56887. * @returns a new TextFileAssetTask object
  56888. */
  56889. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  56890. /**
  56891. * Add a BinaryFileAssetTask to the list of active tasks
  56892. * @param taskName defines the name of the new task
  56893. * @param url defines the url of the file to load
  56894. * @returns a new BinaryFileAssetTask object
  56895. */
  56896. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  56897. /**
  56898. * Add a ImageAssetTask to the list of active tasks
  56899. * @param taskName defines the name of the new task
  56900. * @param url defines the url of the file to load
  56901. * @returns a new ImageAssetTask object
  56902. */
  56903. addImageTask(taskName: string, url: string): ImageAssetTask;
  56904. /**
  56905. * Add a TextureAssetTask to the list of active tasks
  56906. * @param taskName defines the name of the new task
  56907. * @param url defines the url of the file to load
  56908. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56909. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  56910. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56911. * @returns a new TextureAssetTask object
  56912. */
  56913. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  56914. /**
  56915. * Add a CubeTextureAssetTask to the list of active tasks
  56916. * @param taskName defines the name of the new task
  56917. * @param url defines the url of the file to load
  56918. * @param extensions defines the extension to use to load the cube map (can be null)
  56919. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56920. * @param files defines the list of files to load (can be null)
  56921. * @returns a new CubeTextureAssetTask object
  56922. */
  56923. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  56924. /**
  56925. *
  56926. * Add a HDRCubeTextureAssetTask to the list of active tasks
  56927. * @param taskName defines the name of the new task
  56928. * @param url defines the url of the file to load
  56929. * @param size defines the size you want for the cubemap (can be null)
  56930. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56931. * @param generateHarmonics defines if you want to automatically generate (true by default)
  56932. * @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)
  56933. * @param reserved Internal use only
  56934. * @returns a new HDRCubeTextureAssetTask object
  56935. */
  56936. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  56937. /**
  56938. * Remove a task from the assets manager.
  56939. * @param task the task to remove
  56940. */
  56941. removeTask(task: AbstractAssetTask): void;
  56942. private _decreaseWaitingTasksCount;
  56943. private _runTask;
  56944. /**
  56945. * Reset the AssetsManager and remove all tasks
  56946. * @return the current instance of the AssetsManager
  56947. */
  56948. reset(): AssetsManager;
  56949. /**
  56950. * Start the loading process
  56951. * @return the current instance of the AssetsManager
  56952. */
  56953. load(): AssetsManager;
  56954. /**
  56955. * Start the loading process as an async operation
  56956. * @return a promise returning the list of failed tasks
  56957. */
  56958. loadAsync(): Promise<void>;
  56959. }
  56960. }
  56961. declare module "babylonjs/Misc/deferred" {
  56962. /**
  56963. * Wrapper class for promise with external resolve and reject.
  56964. */
  56965. export class Deferred<T> {
  56966. /**
  56967. * The promise associated with this deferred object.
  56968. */
  56969. readonly promise: Promise<T>;
  56970. private _resolve;
  56971. private _reject;
  56972. /**
  56973. * The resolve method of the promise associated with this deferred object.
  56974. */
  56975. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  56976. /**
  56977. * The reject method of the promise associated with this deferred object.
  56978. */
  56979. readonly reject: (reason?: any) => void;
  56980. /**
  56981. * Constructor for this deferred object.
  56982. */
  56983. constructor();
  56984. }
  56985. }
  56986. declare module "babylonjs/Misc/meshExploder" {
  56987. import { Mesh } from "babylonjs/Meshes/mesh";
  56988. /**
  56989. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  56990. */
  56991. export class MeshExploder {
  56992. private _centerMesh;
  56993. private _meshes;
  56994. private _meshesOrigins;
  56995. private _toCenterVectors;
  56996. private _scaledDirection;
  56997. private _newPosition;
  56998. private _centerPosition;
  56999. /**
  57000. * Explodes meshes from a center mesh.
  57001. * @param meshes The meshes to explode.
  57002. * @param centerMesh The mesh to be center of explosion.
  57003. */
  57004. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  57005. private _setCenterMesh;
  57006. /**
  57007. * Get class name
  57008. * @returns "MeshExploder"
  57009. */
  57010. getClassName(): string;
  57011. /**
  57012. * "Exploded meshes"
  57013. * @returns Array of meshes with the centerMesh at index 0.
  57014. */
  57015. getMeshes(): Array<Mesh>;
  57016. /**
  57017. * Explodes meshes giving a specific direction
  57018. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  57019. */
  57020. explode(direction?: number): void;
  57021. }
  57022. }
  57023. declare module "babylonjs/Misc/filesInput" {
  57024. import { Engine } from "babylonjs/Engines/engine";
  57025. import { Scene } from "babylonjs/scene";
  57026. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  57027. /**
  57028. * Class used to help managing file picking and drag'n'drop
  57029. */
  57030. export class FilesInput {
  57031. /**
  57032. * List of files ready to be loaded
  57033. */
  57034. static readonly FilesToLoad: {
  57035. [key: string]: File;
  57036. };
  57037. /**
  57038. * Callback called when a file is processed
  57039. */
  57040. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  57041. private _engine;
  57042. private _currentScene;
  57043. private _sceneLoadedCallback;
  57044. private _progressCallback;
  57045. private _additionalRenderLoopLogicCallback;
  57046. private _textureLoadingCallback;
  57047. private _startingProcessingFilesCallback;
  57048. private _onReloadCallback;
  57049. private _errorCallback;
  57050. private _elementToMonitor;
  57051. private _sceneFileToLoad;
  57052. private _filesToLoad;
  57053. /**
  57054. * Creates a new FilesInput
  57055. * @param engine defines the rendering engine
  57056. * @param scene defines the hosting scene
  57057. * @param sceneLoadedCallback callback called when scene is loaded
  57058. * @param progressCallback callback called to track progress
  57059. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  57060. * @param textureLoadingCallback callback called when a texture is loading
  57061. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  57062. * @param onReloadCallback callback called when a reload is requested
  57063. * @param errorCallback callback call if an error occurs
  57064. */
  57065. 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);
  57066. private _dragEnterHandler;
  57067. private _dragOverHandler;
  57068. private _dropHandler;
  57069. /**
  57070. * Calls this function to listen to drag'n'drop events on a specific DOM element
  57071. * @param elementToMonitor defines the DOM element to track
  57072. */
  57073. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  57074. /**
  57075. * Release all associated resources
  57076. */
  57077. dispose(): void;
  57078. private renderFunction;
  57079. private drag;
  57080. private drop;
  57081. private _traverseFolder;
  57082. private _processFiles;
  57083. /**
  57084. * Load files from a drop event
  57085. * @param event defines the drop event to use as source
  57086. */
  57087. loadFiles(event: any): void;
  57088. private _processReload;
  57089. /**
  57090. * Reload the current scene from the loaded files
  57091. */
  57092. reload(): void;
  57093. }
  57094. }
  57095. declare module "babylonjs/Misc/HighDynamicRange/index" {
  57096. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  57097. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  57098. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57099. }
  57100. declare module "babylonjs/Misc/sceneOptimizer" {
  57101. import { Scene, IDisposable } from "babylonjs/scene";
  57102. import { Observable } from "babylonjs/Misc/observable";
  57103. /**
  57104. * Defines the root class used to create scene optimization to use with SceneOptimizer
  57105. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57106. */
  57107. export class SceneOptimization {
  57108. /**
  57109. * Defines the priority of this optimization (0 by default which means first in the list)
  57110. */
  57111. priority: number;
  57112. /**
  57113. * Gets a string describing the action executed by the current optimization
  57114. * @returns description string
  57115. */
  57116. getDescription(): string;
  57117. /**
  57118. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57119. * @param scene defines the current scene where to apply this optimization
  57120. * @param optimizer defines the current optimizer
  57121. * @returns true if everything that can be done was applied
  57122. */
  57123. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57124. /**
  57125. * Creates the SceneOptimization object
  57126. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57127. * @param desc defines the description associated with the optimization
  57128. */
  57129. constructor(
  57130. /**
  57131. * Defines the priority of this optimization (0 by default which means first in the list)
  57132. */
  57133. priority?: number);
  57134. }
  57135. /**
  57136. * Defines an optimization used to reduce the size of render target textures
  57137. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57138. */
  57139. export class TextureOptimization extends SceneOptimization {
  57140. /**
  57141. * Defines the priority of this optimization (0 by default which means first in the list)
  57142. */
  57143. priority: number;
  57144. /**
  57145. * 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
  57146. */
  57147. maximumSize: number;
  57148. /**
  57149. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57150. */
  57151. step: number;
  57152. /**
  57153. * Gets a string describing the action executed by the current optimization
  57154. * @returns description string
  57155. */
  57156. getDescription(): string;
  57157. /**
  57158. * Creates the TextureOptimization object
  57159. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57160. * @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
  57161. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57162. */
  57163. constructor(
  57164. /**
  57165. * Defines the priority of this optimization (0 by default which means first in the list)
  57166. */
  57167. priority?: number,
  57168. /**
  57169. * 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
  57170. */
  57171. maximumSize?: number,
  57172. /**
  57173. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57174. */
  57175. step?: number);
  57176. /**
  57177. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57178. * @param scene defines the current scene where to apply this optimization
  57179. * @param optimizer defines the current optimizer
  57180. * @returns true if everything that can be done was applied
  57181. */
  57182. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57183. }
  57184. /**
  57185. * Defines an optimization used to increase or decrease the rendering resolution
  57186. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57187. */
  57188. export class HardwareScalingOptimization extends SceneOptimization {
  57189. /**
  57190. * Defines the priority of this optimization (0 by default which means first in the list)
  57191. */
  57192. priority: number;
  57193. /**
  57194. * Defines the maximum scale to use (2 by default)
  57195. */
  57196. maximumScale: number;
  57197. /**
  57198. * Defines the step to use between two passes (0.5 by default)
  57199. */
  57200. step: number;
  57201. private _currentScale;
  57202. private _directionOffset;
  57203. /**
  57204. * Gets a string describing the action executed by the current optimization
  57205. * @return description string
  57206. */
  57207. getDescription(): string;
  57208. /**
  57209. * Creates the HardwareScalingOptimization object
  57210. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57211. * @param maximumScale defines the maximum scale to use (2 by default)
  57212. * @param step defines the step to use between two passes (0.5 by default)
  57213. */
  57214. constructor(
  57215. /**
  57216. * Defines the priority of this optimization (0 by default which means first in the list)
  57217. */
  57218. priority?: number,
  57219. /**
  57220. * Defines the maximum scale to use (2 by default)
  57221. */
  57222. maximumScale?: number,
  57223. /**
  57224. * Defines the step to use between two passes (0.5 by default)
  57225. */
  57226. step?: number);
  57227. /**
  57228. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57229. * @param scene defines the current scene where to apply this optimization
  57230. * @param optimizer defines the current optimizer
  57231. * @returns true if everything that can be done was applied
  57232. */
  57233. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57234. }
  57235. /**
  57236. * Defines an optimization used to remove shadows
  57237. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57238. */
  57239. export class ShadowsOptimization extends SceneOptimization {
  57240. /**
  57241. * Gets a string describing the action executed by the current optimization
  57242. * @return description string
  57243. */
  57244. getDescription(): string;
  57245. /**
  57246. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57247. * @param scene defines the current scene where to apply this optimization
  57248. * @param optimizer defines the current optimizer
  57249. * @returns true if everything that can be done was applied
  57250. */
  57251. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57252. }
  57253. /**
  57254. * Defines an optimization used to turn post-processes off
  57255. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57256. */
  57257. export class PostProcessesOptimization extends SceneOptimization {
  57258. /**
  57259. * Gets a string describing the action executed by the current optimization
  57260. * @return description string
  57261. */
  57262. getDescription(): string;
  57263. /**
  57264. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57265. * @param scene defines the current scene where to apply this optimization
  57266. * @param optimizer defines the current optimizer
  57267. * @returns true if everything that can be done was applied
  57268. */
  57269. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57270. }
  57271. /**
  57272. * Defines an optimization used to turn lens flares off
  57273. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57274. */
  57275. export class LensFlaresOptimization extends SceneOptimization {
  57276. /**
  57277. * Gets a string describing the action executed by the current optimization
  57278. * @return description string
  57279. */
  57280. getDescription(): string;
  57281. /**
  57282. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57283. * @param scene defines the current scene where to apply this optimization
  57284. * @param optimizer defines the current optimizer
  57285. * @returns true if everything that can be done was applied
  57286. */
  57287. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57288. }
  57289. /**
  57290. * Defines an optimization based on user defined callback.
  57291. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57292. */
  57293. export class CustomOptimization extends SceneOptimization {
  57294. /**
  57295. * Callback called to apply the custom optimization.
  57296. */
  57297. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  57298. /**
  57299. * Callback called to get custom description
  57300. */
  57301. onGetDescription: () => string;
  57302. /**
  57303. * Gets a string describing the action executed by the current optimization
  57304. * @returns description string
  57305. */
  57306. getDescription(): string;
  57307. /**
  57308. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57309. * @param scene defines the current scene where to apply this optimization
  57310. * @param optimizer defines the current optimizer
  57311. * @returns true if everything that can be done was applied
  57312. */
  57313. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57314. }
  57315. /**
  57316. * Defines an optimization used to turn particles off
  57317. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57318. */
  57319. export class ParticlesOptimization extends SceneOptimization {
  57320. /**
  57321. * Gets a string describing the action executed by the current optimization
  57322. * @return description string
  57323. */
  57324. getDescription(): string;
  57325. /**
  57326. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57327. * @param scene defines the current scene where to apply this optimization
  57328. * @param optimizer defines the current optimizer
  57329. * @returns true if everything that can be done was applied
  57330. */
  57331. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57332. }
  57333. /**
  57334. * Defines an optimization used to turn render targets off
  57335. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57336. */
  57337. export class RenderTargetsOptimization extends SceneOptimization {
  57338. /**
  57339. * Gets a string describing the action executed by the current optimization
  57340. * @return description string
  57341. */
  57342. getDescription(): string;
  57343. /**
  57344. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57345. * @param scene defines the current scene where to apply this optimization
  57346. * @param optimizer defines the current optimizer
  57347. * @returns true if everything that can be done was applied
  57348. */
  57349. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57350. }
  57351. /**
  57352. * Defines an optimization used to merge meshes with compatible materials
  57353. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57354. */
  57355. export class MergeMeshesOptimization extends SceneOptimization {
  57356. private static _UpdateSelectionTree;
  57357. /**
  57358. * Gets or sets a boolean which defines if optimization octree has to be updated
  57359. */
  57360. /**
  57361. * Gets or sets a boolean which defines if optimization octree has to be updated
  57362. */
  57363. static UpdateSelectionTree: boolean;
  57364. /**
  57365. * Gets a string describing the action executed by the current optimization
  57366. * @return description string
  57367. */
  57368. getDescription(): string;
  57369. private _canBeMerged;
  57370. /**
  57371. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57372. * @param scene defines the current scene where to apply this optimization
  57373. * @param optimizer defines the current optimizer
  57374. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  57375. * @returns true if everything that can be done was applied
  57376. */
  57377. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  57378. }
  57379. /**
  57380. * Defines a list of options used by SceneOptimizer
  57381. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57382. */
  57383. export class SceneOptimizerOptions {
  57384. /**
  57385. * Defines the target frame rate to reach (60 by default)
  57386. */
  57387. targetFrameRate: number;
  57388. /**
  57389. * Defines the interval between two checkes (2000ms by default)
  57390. */
  57391. trackerDuration: number;
  57392. /**
  57393. * Gets the list of optimizations to apply
  57394. */
  57395. optimizations: SceneOptimization[];
  57396. /**
  57397. * Creates a new list of options used by SceneOptimizer
  57398. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  57399. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  57400. */
  57401. constructor(
  57402. /**
  57403. * Defines the target frame rate to reach (60 by default)
  57404. */
  57405. targetFrameRate?: number,
  57406. /**
  57407. * Defines the interval between two checkes (2000ms by default)
  57408. */
  57409. trackerDuration?: number);
  57410. /**
  57411. * Add a new optimization
  57412. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  57413. * @returns the current SceneOptimizerOptions
  57414. */
  57415. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  57416. /**
  57417. * Add a new custom optimization
  57418. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  57419. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  57420. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57421. * @returns the current SceneOptimizerOptions
  57422. */
  57423. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  57424. /**
  57425. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  57426. * @param targetFrameRate defines the target frame rate (60 by default)
  57427. * @returns a SceneOptimizerOptions object
  57428. */
  57429. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57430. /**
  57431. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  57432. * @param targetFrameRate defines the target frame rate (60 by default)
  57433. * @returns a SceneOptimizerOptions object
  57434. */
  57435. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57436. /**
  57437. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  57438. * @param targetFrameRate defines the target frame rate (60 by default)
  57439. * @returns a SceneOptimizerOptions object
  57440. */
  57441. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57442. }
  57443. /**
  57444. * Class used to run optimizations in order to reach a target frame rate
  57445. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57446. */
  57447. export class SceneOptimizer implements IDisposable {
  57448. private _isRunning;
  57449. private _options;
  57450. private _scene;
  57451. private _currentPriorityLevel;
  57452. private _targetFrameRate;
  57453. private _trackerDuration;
  57454. private _currentFrameRate;
  57455. private _sceneDisposeObserver;
  57456. private _improvementMode;
  57457. /**
  57458. * Defines an observable called when the optimizer reaches the target frame rate
  57459. */
  57460. onSuccessObservable: Observable<SceneOptimizer>;
  57461. /**
  57462. * Defines an observable called when the optimizer enables an optimization
  57463. */
  57464. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  57465. /**
  57466. * Defines an observable called when the optimizer is not able to reach the target frame rate
  57467. */
  57468. onFailureObservable: Observable<SceneOptimizer>;
  57469. /**
  57470. * Gets a boolean indicating if the optimizer is in improvement mode
  57471. */
  57472. readonly isInImprovementMode: boolean;
  57473. /**
  57474. * Gets the current priority level (0 at start)
  57475. */
  57476. readonly currentPriorityLevel: number;
  57477. /**
  57478. * Gets the current frame rate checked by the SceneOptimizer
  57479. */
  57480. readonly currentFrameRate: number;
  57481. /**
  57482. * Gets or sets the current target frame rate (60 by default)
  57483. */
  57484. /**
  57485. * Gets or sets the current target frame rate (60 by default)
  57486. */
  57487. targetFrameRate: number;
  57488. /**
  57489. * Gets or sets the current interval between two checks (every 2000ms by default)
  57490. */
  57491. /**
  57492. * Gets or sets the current interval between two checks (every 2000ms by default)
  57493. */
  57494. trackerDuration: number;
  57495. /**
  57496. * Gets the list of active optimizations
  57497. */
  57498. readonly optimizations: SceneOptimization[];
  57499. /**
  57500. * Creates a new SceneOptimizer
  57501. * @param scene defines the scene to work on
  57502. * @param options defines the options to use with the SceneOptimizer
  57503. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  57504. * @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)
  57505. */
  57506. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  57507. /**
  57508. * Stops the current optimizer
  57509. */
  57510. stop(): void;
  57511. /**
  57512. * Reset the optimizer to initial step (current priority level = 0)
  57513. */
  57514. reset(): void;
  57515. /**
  57516. * Start the optimizer. By default it will try to reach a specific framerate
  57517. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  57518. */
  57519. start(): void;
  57520. private _checkCurrentState;
  57521. /**
  57522. * Release all resources
  57523. */
  57524. dispose(): void;
  57525. /**
  57526. * Helper function to create a SceneOptimizer with one single line of code
  57527. * @param scene defines the scene to work on
  57528. * @param options defines the options to use with the SceneOptimizer
  57529. * @param onSuccess defines a callback to call on success
  57530. * @param onFailure defines a callback to call on failure
  57531. * @returns the new SceneOptimizer object
  57532. */
  57533. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  57534. }
  57535. }
  57536. declare module "babylonjs/Misc/sceneSerializer" {
  57537. import { Scene } from "babylonjs/scene";
  57538. /**
  57539. * Class used to serialize a scene into a string
  57540. */
  57541. export class SceneSerializer {
  57542. /**
  57543. * Clear cache used by a previous serialization
  57544. */
  57545. static ClearCache(): void;
  57546. /**
  57547. * Serialize a scene into a JSON compatible object
  57548. * @param scene defines the scene to serialize
  57549. * @returns a JSON compatible object
  57550. */
  57551. static Serialize(scene: Scene): any;
  57552. /**
  57553. * Serialize a mesh into a JSON compatible object
  57554. * @param toSerialize defines the mesh to serialize
  57555. * @param withParents defines if parents must be serialized as well
  57556. * @param withChildren defines if children must be serialized as well
  57557. * @returns a JSON compatible object
  57558. */
  57559. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  57560. }
  57561. }
  57562. declare module "babylonjs/Misc/videoRecorder" {
  57563. import { Nullable } from "babylonjs/types";
  57564. import { Engine } from "babylonjs/Engines/engine";
  57565. /**
  57566. * This represents the different options avilable for the video capture.
  57567. */
  57568. export interface VideoRecorderOptions {
  57569. /** Defines the mime type of the video */
  57570. mimeType: string;
  57571. /** Defines the video the video should be recorded at */
  57572. fps: number;
  57573. /** Defines the chunk size for the recording data */
  57574. recordChunckSize: number;
  57575. /** The audio tracks to attach to the record */
  57576. audioTracks?: MediaStreamTrack[];
  57577. }
  57578. /**
  57579. * This can helps recording videos from BabylonJS.
  57580. * This is based on the available WebRTC functionalities of the browser.
  57581. *
  57582. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  57583. */
  57584. export class VideoRecorder {
  57585. private static readonly _defaultOptions;
  57586. /**
  57587. * Returns wehther or not the VideoRecorder is available in your browser.
  57588. * @param engine Defines the Babylon Engine to check the support for
  57589. * @returns true if supported otherwise false
  57590. */
  57591. static IsSupported(engine: Engine): boolean;
  57592. private readonly _options;
  57593. private _canvas;
  57594. private _mediaRecorder;
  57595. private _recordedChunks;
  57596. private _fileName;
  57597. private _resolve;
  57598. private _reject;
  57599. /**
  57600. * True wether a recording is already in progress.
  57601. */
  57602. readonly isRecording: boolean;
  57603. /**
  57604. * Create a new VideoCapture object which can help converting what you see in Babylon to
  57605. * a video file.
  57606. * @param engine Defines the BabylonJS Engine you wish to record
  57607. * @param options Defines options that can be used to customized the capture
  57608. */
  57609. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  57610. /**
  57611. * Stops the current recording before the default capture timeout passed in the startRecording
  57612. * functions.
  57613. */
  57614. stopRecording(): void;
  57615. /**
  57616. * Starts recording the canvas for a max duration specified in parameters.
  57617. * @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.
  57618. * @param maxDuration Defines the maximum recording time in seconds.
  57619. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  57620. * @return a promise callback at the end of the recording with the video data in Blob.
  57621. */
  57622. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  57623. /**
  57624. * Releases internal resources used during the recording.
  57625. */
  57626. dispose(): void;
  57627. private _handleDataAvailable;
  57628. private _handleError;
  57629. private _handleStop;
  57630. }
  57631. }
  57632. declare module "babylonjs/Misc/workerPool" {
  57633. import { IDisposable } from "babylonjs/scene";
  57634. /**
  57635. * Helper class to push actions to a pool of workers.
  57636. */
  57637. export class WorkerPool implements IDisposable {
  57638. private _workerInfos;
  57639. private _pendingActions;
  57640. /**
  57641. * Constructor
  57642. * @param workers Array of workers to use for actions
  57643. */
  57644. constructor(workers: Array<Worker>);
  57645. /**
  57646. * Terminates all workers and clears any pending actions.
  57647. */
  57648. dispose(): void;
  57649. /**
  57650. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57651. * pended until a worker has completed its action.
  57652. * @param action The action to perform. Call onComplete when the action is complete.
  57653. */
  57654. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57655. private _execute;
  57656. }
  57657. }
  57658. declare module "babylonjs/Misc/screenshotTools" {
  57659. import { Camera } from "babylonjs/Cameras/camera";
  57660. import { Engine } from "babylonjs/Engines/engine";
  57661. /**
  57662. * Class containing a set of static utilities functions for screenshots
  57663. */
  57664. export class ScreenshotTools {
  57665. /**
  57666. * Captures a screenshot of the current rendering
  57667. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  57668. * @param engine defines the rendering engine
  57669. * @param camera defines the source camera
  57670. * @param size This parameter can be set to a single number or to an object with the
  57671. * following (optional) properties: precision, width, height. If a single number is passed,
  57672. * it will be used for both width and height. If an object is passed, the screenshot size
  57673. * will be derived from the parameters. The precision property is a multiplier allowing
  57674. * rendering at a higher or lower resolution
  57675. * @param successCallback defines the callback receives a single parameter which contains the
  57676. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57677. * src parameter of an <img> to display it
  57678. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  57679. * Check your browser for supported MIME types
  57680. */
  57681. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  57682. /**
  57683. * Generates an image screenshot from the specified camera.
  57684. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  57685. * @param engine The engine to use for rendering
  57686. * @param camera The camera to use for rendering
  57687. * @param size This parameter can be set to a single number or to an object with the
  57688. * following (optional) properties: precision, width, height. If a single number is passed,
  57689. * it will be used for both width and height. If an object is passed, the screenshot size
  57690. * will be derived from the parameters. The precision property is a multiplier allowing
  57691. * rendering at a higher or lower resolution
  57692. * @param successCallback The callback receives a single parameter which contains the
  57693. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57694. * src parameter of an <img> to display it
  57695. * @param mimeType The MIME type of the screenshot image (default: image/png).
  57696. * Check your browser for supported MIME types
  57697. * @param samples Texture samples (default: 1)
  57698. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  57699. * @param fileName A name for for the downloaded file.
  57700. */
  57701. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  57702. }
  57703. }
  57704. declare module "babylonjs/Misc/index" {
  57705. export * from "babylonjs/Misc/andOrNotEvaluator";
  57706. export * from "babylonjs/Misc/assetsManager";
  57707. export * from "babylonjs/Misc/dds";
  57708. export * from "babylonjs/Misc/decorators";
  57709. export * from "babylonjs/Misc/deferred";
  57710. export * from "babylonjs/Misc/environmentTextureTools";
  57711. export * from "babylonjs/Misc/meshExploder";
  57712. export * from "babylonjs/Misc/filesInput";
  57713. export * from "babylonjs/Misc/HighDynamicRange/index";
  57714. export * from "babylonjs/Misc/khronosTextureContainer";
  57715. export * from "babylonjs/Misc/observable";
  57716. export * from "babylonjs/Misc/performanceMonitor";
  57717. export * from "babylonjs/Misc/promise";
  57718. export * from "babylonjs/Misc/sceneOptimizer";
  57719. export * from "babylonjs/Misc/sceneSerializer";
  57720. export * from "babylonjs/Misc/smartArray";
  57721. export * from "babylonjs/Misc/stringDictionary";
  57722. export * from "babylonjs/Misc/tags";
  57723. export * from "babylonjs/Misc/textureTools";
  57724. export * from "babylonjs/Misc/tga";
  57725. export * from "babylonjs/Misc/tools";
  57726. export * from "babylonjs/Misc/videoRecorder";
  57727. export * from "babylonjs/Misc/virtualJoystick";
  57728. export * from "babylonjs/Misc/workerPool";
  57729. export * from "babylonjs/Misc/logger";
  57730. export * from "babylonjs/Misc/typeStore";
  57731. export * from "babylonjs/Misc/filesInputStore";
  57732. export * from "babylonjs/Misc/deepCopier";
  57733. export * from "babylonjs/Misc/pivotTools";
  57734. export * from "babylonjs/Misc/precisionDate";
  57735. export * from "babylonjs/Misc/screenshotTools";
  57736. export * from "babylonjs/Misc/typeStore";
  57737. export * from "babylonjs/Misc/webRequest";
  57738. export * from "babylonjs/Misc/iInspectable";
  57739. }
  57740. declare module "babylonjs/index" {
  57741. export * from "babylonjs/abstractScene";
  57742. export * from "babylonjs/Actions/index";
  57743. export * from "babylonjs/Animations/index";
  57744. export * from "babylonjs/assetContainer";
  57745. export * from "babylonjs/Audio/index";
  57746. export * from "babylonjs/Behaviors/index";
  57747. export * from "babylonjs/Bones/index";
  57748. export * from "babylonjs/Cameras/index";
  57749. export * from "babylonjs/Collisions/index";
  57750. export * from "babylonjs/Culling/index";
  57751. export * from "babylonjs/Debug/index";
  57752. export * from "babylonjs/Engines/index";
  57753. export * from "babylonjs/Events/index";
  57754. export * from "babylonjs/Gamepads/index";
  57755. export * from "babylonjs/Gizmos/index";
  57756. export * from "babylonjs/Helpers/index";
  57757. export * from "babylonjs/Instrumentation/index";
  57758. export * from "babylonjs/Layers/index";
  57759. export * from "babylonjs/LensFlares/index";
  57760. export * from "babylonjs/Lights/index";
  57761. export * from "babylonjs/Loading/index";
  57762. export * from "babylonjs/Materials/index";
  57763. export * from "babylonjs/Maths/index";
  57764. export * from "babylonjs/Meshes/index";
  57765. export * from "babylonjs/Morph/index";
  57766. export * from "babylonjs/node";
  57767. export * from "babylonjs/Offline/index";
  57768. export * from "babylonjs/Particles/index";
  57769. export * from "babylonjs/Physics/index";
  57770. export * from "babylonjs/PostProcesses/index";
  57771. export * from "babylonjs/Probes/index";
  57772. export * from "babylonjs/Rendering/index";
  57773. export * from "babylonjs/scene";
  57774. export * from "babylonjs/sceneComponent";
  57775. export * from "babylonjs/Sprites/index";
  57776. export * from "babylonjs/States/index";
  57777. export * from "babylonjs/Misc/index";
  57778. export * from "babylonjs/types";
  57779. }
  57780. declare module "babylonjs/Animations/pathCursor" {
  57781. import { Path2, Vector3 } from "babylonjs/Maths/math";
  57782. /**
  57783. * A cursor which tracks a point on a path
  57784. */
  57785. export class PathCursor {
  57786. private path;
  57787. /**
  57788. * Stores path cursor callbacks for when an onchange event is triggered
  57789. */
  57790. private _onchange;
  57791. /**
  57792. * The value of the path cursor
  57793. */
  57794. value: number;
  57795. /**
  57796. * The animation array of the path cursor
  57797. */
  57798. animations: Animation[];
  57799. /**
  57800. * Initializes the path cursor
  57801. * @param path The path to track
  57802. */
  57803. constructor(path: Path2);
  57804. /**
  57805. * Gets the cursor point on the path
  57806. * @returns A point on the path cursor at the cursor location
  57807. */
  57808. getPoint(): Vector3;
  57809. /**
  57810. * Moves the cursor ahead by the step amount
  57811. * @param step The amount to move the cursor forward
  57812. * @returns This path cursor
  57813. */
  57814. moveAhead(step?: number): PathCursor;
  57815. /**
  57816. * Moves the cursor behind by the step amount
  57817. * @param step The amount to move the cursor back
  57818. * @returns This path cursor
  57819. */
  57820. moveBack(step?: number): PathCursor;
  57821. /**
  57822. * Moves the cursor by the step amount
  57823. * If the step amount is greater than one, an exception is thrown
  57824. * @param step The amount to move the cursor
  57825. * @returns This path cursor
  57826. */
  57827. move(step: number): PathCursor;
  57828. /**
  57829. * Ensures that the value is limited between zero and one
  57830. * @returns This path cursor
  57831. */
  57832. private ensureLimits;
  57833. /**
  57834. * Runs onchange callbacks on change (used by the animation engine)
  57835. * @returns This path cursor
  57836. */
  57837. private raiseOnChange;
  57838. /**
  57839. * Executes a function on change
  57840. * @param f A path cursor onchange callback
  57841. * @returns This path cursor
  57842. */
  57843. onchange(f: (cursor: PathCursor) => void): PathCursor;
  57844. }
  57845. }
  57846. declare module "babylonjs/Legacy/legacy" {
  57847. import * as Babylon from "babylonjs/index";
  57848. export * from "babylonjs/index";
  57849. }
  57850. declare module "babylonjs/Shaders/blur.fragment" {
  57851. /** @hidden */
  57852. export var blurPixelShader: {
  57853. name: string;
  57854. shader: string;
  57855. };
  57856. }
  57857. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  57858. /** @hidden */
  57859. export var bones300Declaration: {
  57860. name: string;
  57861. shader: string;
  57862. };
  57863. }
  57864. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  57865. /** @hidden */
  57866. export var instances300Declaration: {
  57867. name: string;
  57868. shader: string;
  57869. };
  57870. }
  57871. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  57872. /** @hidden */
  57873. export var pointCloudVertexDeclaration: {
  57874. name: string;
  57875. shader: string;
  57876. };
  57877. }
  57878. // Mixins
  57879. interface Window {
  57880. mozIndexedDB: IDBFactory;
  57881. webkitIndexedDB: IDBFactory;
  57882. msIndexedDB: IDBFactory;
  57883. webkitURL: typeof URL;
  57884. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  57885. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  57886. WebGLRenderingContext: WebGLRenderingContext;
  57887. MSGesture: MSGesture;
  57888. CANNON: any;
  57889. AudioContext: AudioContext;
  57890. webkitAudioContext: AudioContext;
  57891. PointerEvent: any;
  57892. Math: Math;
  57893. Uint8Array: Uint8ArrayConstructor;
  57894. Float32Array: Float32ArrayConstructor;
  57895. mozURL: typeof URL;
  57896. msURL: typeof URL;
  57897. VRFrameData: any; // WebVR, from specs 1.1
  57898. DracoDecoderModule: any;
  57899. setImmediate(handler: (...args: any[]) => void): number;
  57900. }
  57901. interface HTMLCanvasElement {
  57902. requestPointerLock(): void;
  57903. msRequestPointerLock?(): void;
  57904. mozRequestPointerLock?(): void;
  57905. webkitRequestPointerLock?(): void;
  57906. /** Track wether a record is in progress */
  57907. isRecording: boolean;
  57908. /** Capture Stream method defined by some browsers */
  57909. captureStream(fps?: number): MediaStream;
  57910. }
  57911. interface CanvasRenderingContext2D {
  57912. msImageSmoothingEnabled: boolean;
  57913. }
  57914. interface MouseEvent {
  57915. mozMovementX: number;
  57916. mozMovementY: number;
  57917. webkitMovementX: number;
  57918. webkitMovementY: number;
  57919. msMovementX: number;
  57920. msMovementY: number;
  57921. }
  57922. interface Navigator {
  57923. mozGetVRDevices: (any: any) => any;
  57924. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57925. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57926. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57927. webkitGetGamepads(): Gamepad[];
  57928. msGetGamepads(): Gamepad[];
  57929. webkitGamepads(): Gamepad[];
  57930. }
  57931. interface HTMLVideoElement {
  57932. mozSrcObject: any;
  57933. }
  57934. interface Math {
  57935. fround(x: number): number;
  57936. imul(a: number, b: number): number;
  57937. }
  57938. interface WebGLProgram {
  57939. context?: WebGLRenderingContext;
  57940. vertexShader?: WebGLShader;
  57941. fragmentShader?: WebGLShader;
  57942. isParallelCompiled: boolean;
  57943. onCompiled?: () => void;
  57944. }
  57945. interface WebGLRenderingContext {
  57946. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  57947. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  57948. vertexAttribDivisor(index: number, divisor: number): void;
  57949. createVertexArray(): any;
  57950. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  57951. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  57952. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  57953. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  57954. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  57955. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  57956. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  57957. // Queries
  57958. createQuery(): WebGLQuery;
  57959. deleteQuery(query: WebGLQuery): void;
  57960. beginQuery(target: number, query: WebGLQuery): void;
  57961. endQuery(target: number): void;
  57962. getQueryParameter(query: WebGLQuery, pname: number): any;
  57963. getQuery(target: number, pname: number): any;
  57964. MAX_SAMPLES: number;
  57965. RGBA8: number;
  57966. READ_FRAMEBUFFER: number;
  57967. DRAW_FRAMEBUFFER: number;
  57968. UNIFORM_BUFFER: number;
  57969. HALF_FLOAT_OES: number;
  57970. RGBA16F: number;
  57971. RGBA32F: number;
  57972. R32F: number;
  57973. RG32F: number;
  57974. RGB32F: number;
  57975. R16F: number;
  57976. RG16F: number;
  57977. RGB16F: number;
  57978. RED: number;
  57979. RG: number;
  57980. R8: number;
  57981. RG8: number;
  57982. UNSIGNED_INT_24_8: number;
  57983. DEPTH24_STENCIL8: number;
  57984. /* Multiple Render Targets */
  57985. drawBuffers(buffers: number[]): void;
  57986. readBuffer(src: number): void;
  57987. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  57988. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  57989. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  57990. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  57991. // Occlusion Query
  57992. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  57993. ANY_SAMPLES_PASSED: number;
  57994. QUERY_RESULT_AVAILABLE: number;
  57995. QUERY_RESULT: number;
  57996. }
  57997. interface WebGLBuffer {
  57998. references: number;
  57999. capacity: number;
  58000. is32Bits: boolean;
  58001. }
  58002. interface WebGLProgram {
  58003. transformFeedback?: WebGLTransformFeedback | null;
  58004. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  58005. }
  58006. interface EXT_disjoint_timer_query {
  58007. QUERY_COUNTER_BITS_EXT: number;
  58008. TIME_ELAPSED_EXT: number;
  58009. TIMESTAMP_EXT: number;
  58010. GPU_DISJOINT_EXT: number;
  58011. QUERY_RESULT_EXT: number;
  58012. QUERY_RESULT_AVAILABLE_EXT: number;
  58013. queryCounterEXT(query: WebGLQuery, target: number): void;
  58014. createQueryEXT(): WebGLQuery;
  58015. beginQueryEXT(target: number, query: WebGLQuery): void;
  58016. endQueryEXT(target: number): void;
  58017. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  58018. deleteQueryEXT(query: WebGLQuery): void;
  58019. }
  58020. interface WebGLUniformLocation {
  58021. _currentState: any;
  58022. }
  58023. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  58024. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  58025. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  58026. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58027. interface WebGLRenderingContext {
  58028. readonly RASTERIZER_DISCARD: number;
  58029. readonly DEPTH_COMPONENT24: number;
  58030. readonly TEXTURE_3D: number;
  58031. readonly TEXTURE_2D_ARRAY: number;
  58032. readonly TEXTURE_COMPARE_FUNC: number;
  58033. readonly TEXTURE_COMPARE_MODE: number;
  58034. readonly COMPARE_REF_TO_TEXTURE: number;
  58035. readonly TEXTURE_WRAP_R: number;
  58036. readonly HALF_FLOAT: number;
  58037. readonly RGB8: number;
  58038. readonly RED_INTEGER: number;
  58039. readonly RG_INTEGER: number;
  58040. readonly RGB_INTEGER: number;
  58041. readonly RGBA_INTEGER: number;
  58042. readonly R8_SNORM: number;
  58043. readonly RG8_SNORM: number;
  58044. readonly RGB8_SNORM: number;
  58045. readonly RGBA8_SNORM: number;
  58046. readonly R8I: number;
  58047. readonly RG8I: number;
  58048. readonly RGB8I: number;
  58049. readonly RGBA8I: number;
  58050. readonly R8UI: number;
  58051. readonly RG8UI: number;
  58052. readonly RGB8UI: number;
  58053. readonly RGBA8UI: number;
  58054. readonly R16I: number;
  58055. readonly RG16I: number;
  58056. readonly RGB16I: number;
  58057. readonly RGBA16I: number;
  58058. readonly R16UI: number;
  58059. readonly RG16UI: number;
  58060. readonly RGB16UI: number;
  58061. readonly RGBA16UI: number;
  58062. readonly R32I: number;
  58063. readonly RG32I: number;
  58064. readonly RGB32I: number;
  58065. readonly RGBA32I: number;
  58066. readonly R32UI: number;
  58067. readonly RG32UI: number;
  58068. readonly RGB32UI: number;
  58069. readonly RGBA32UI: number;
  58070. readonly RGB10_A2UI: number;
  58071. readonly R11F_G11F_B10F: number;
  58072. readonly RGB9_E5: number;
  58073. readonly RGB10_A2: number;
  58074. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  58075. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  58076. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  58077. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  58078. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  58079. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  58080. 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;
  58081. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  58082. readonly TRANSFORM_FEEDBACK: number;
  58083. readonly INTERLEAVED_ATTRIBS: number;
  58084. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  58085. createTransformFeedback(): WebGLTransformFeedback;
  58086. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  58087. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  58088. beginTransformFeedback(primitiveMode: number): void;
  58089. endTransformFeedback(): void;
  58090. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  58091. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58092. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58093. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  58094. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  58095. }
  58096. interface ImageBitmap {
  58097. readonly width: number;
  58098. readonly height: number;
  58099. close(): void;
  58100. }
  58101. interface WebGLQuery extends WebGLObject {
  58102. }
  58103. declare var WebGLQuery: {
  58104. prototype: WebGLQuery;
  58105. new(): WebGLQuery;
  58106. };
  58107. interface WebGLSampler extends WebGLObject {
  58108. }
  58109. declare var WebGLSampler: {
  58110. prototype: WebGLSampler;
  58111. new(): WebGLSampler;
  58112. };
  58113. interface WebGLSync extends WebGLObject {
  58114. }
  58115. declare var WebGLSync: {
  58116. prototype: WebGLSync;
  58117. new(): WebGLSync;
  58118. };
  58119. interface WebGLTransformFeedback extends WebGLObject {
  58120. }
  58121. declare var WebGLTransformFeedback: {
  58122. prototype: WebGLTransformFeedback;
  58123. new(): WebGLTransformFeedback;
  58124. };
  58125. interface WebGLVertexArrayObject extends WebGLObject {
  58126. }
  58127. declare var WebGLVertexArrayObject: {
  58128. prototype: WebGLVertexArrayObject;
  58129. new(): WebGLVertexArrayObject;
  58130. };
  58131. // Type definitions for WebVR API
  58132. // Project: https://w3c.github.io/webvr/
  58133. // Definitions by: six a <https://github.com/lostfictions>
  58134. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  58135. interface VRDisplay extends EventTarget {
  58136. /**
  58137. * Dictionary of capabilities describing the VRDisplay.
  58138. */
  58139. readonly capabilities: VRDisplayCapabilities;
  58140. /**
  58141. * z-depth defining the far plane of the eye view frustum
  58142. * enables mapping of values in the render target depth
  58143. * attachment to scene coordinates. Initially set to 10000.0.
  58144. */
  58145. depthFar: number;
  58146. /**
  58147. * z-depth defining the near plane of the eye view frustum
  58148. * enables mapping of values in the render target depth
  58149. * attachment to scene coordinates. Initially set to 0.01.
  58150. */
  58151. depthNear: number;
  58152. /**
  58153. * An identifier for this distinct VRDisplay. Used as an
  58154. * association point in the Gamepad API.
  58155. */
  58156. readonly displayId: number;
  58157. /**
  58158. * A display name, a user-readable name identifying it.
  58159. */
  58160. readonly displayName: string;
  58161. readonly isConnected: boolean;
  58162. readonly isPresenting: boolean;
  58163. /**
  58164. * If this VRDisplay supports room-scale experiences, the optional
  58165. * stage attribute contains details on the room-scale parameters.
  58166. */
  58167. readonly stageParameters: VRStageParameters | null;
  58168. /**
  58169. * Passing the value returned by `requestAnimationFrame` to
  58170. * `cancelAnimationFrame` will unregister the callback.
  58171. * @param handle Define the hanle of the request to cancel
  58172. */
  58173. cancelAnimationFrame(handle: number): void;
  58174. /**
  58175. * Stops presenting to the VRDisplay.
  58176. * @returns a promise to know when it stopped
  58177. */
  58178. exitPresent(): Promise<void>;
  58179. /**
  58180. * Return the current VREyeParameters for the given eye.
  58181. * @param whichEye Define the eye we want the parameter for
  58182. * @returns the eye parameters
  58183. */
  58184. getEyeParameters(whichEye: string): VREyeParameters;
  58185. /**
  58186. * Populates the passed VRFrameData with the information required to render
  58187. * the current frame.
  58188. * @param frameData Define the data structure to populate
  58189. * @returns true if ok otherwise false
  58190. */
  58191. getFrameData(frameData: VRFrameData): boolean;
  58192. /**
  58193. * Get the layers currently being presented.
  58194. * @returns the list of VR layers
  58195. */
  58196. getLayers(): VRLayer[];
  58197. /**
  58198. * Return a VRPose containing the future predicted pose of the VRDisplay
  58199. * when the current frame will be presented. The value returned will not
  58200. * change until JavaScript has returned control to the browser.
  58201. *
  58202. * The VRPose will contain the position, orientation, velocity,
  58203. * and acceleration of each of these properties.
  58204. * @returns the pose object
  58205. */
  58206. getPose(): VRPose;
  58207. /**
  58208. * Return the current instantaneous pose of the VRDisplay, with no
  58209. * prediction applied.
  58210. * @returns the current instantaneous pose
  58211. */
  58212. getImmediatePose(): VRPose;
  58213. /**
  58214. * The callback passed to `requestAnimationFrame` will be called
  58215. * any time a new frame should be rendered. When the VRDisplay is
  58216. * presenting the callback will be called at the native refresh
  58217. * rate of the HMD. When not presenting this function acts
  58218. * identically to how window.requestAnimationFrame acts. Content should
  58219. * make no assumptions of frame rate or vsync behavior as the HMD runs
  58220. * asynchronously from other displays and at differing refresh rates.
  58221. * @param callback Define the eaction to run next frame
  58222. * @returns the request handle it
  58223. */
  58224. requestAnimationFrame(callback: FrameRequestCallback): number;
  58225. /**
  58226. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  58227. * Repeat calls while already presenting will update the VRLayers being displayed.
  58228. * @param layers Define the list of layer to present
  58229. * @returns a promise to know when the request has been fulfilled
  58230. */
  58231. requestPresent(layers: VRLayer[]): Promise<void>;
  58232. /**
  58233. * Reset the pose for this display, treating its current position and
  58234. * orientation as the "origin/zero" values. VRPose.position,
  58235. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  58236. * updated when calling resetPose(). This should be called in only
  58237. * sitting-space experiences.
  58238. */
  58239. resetPose(): void;
  58240. /**
  58241. * The VRLayer provided to the VRDisplay will be captured and presented
  58242. * in the HMD. Calling this function has the same effect on the source
  58243. * canvas as any other operation that uses its source image, and canvases
  58244. * created without preserveDrawingBuffer set to true will be cleared.
  58245. * @param pose Define the pose to submit
  58246. */
  58247. submitFrame(pose?: VRPose): void;
  58248. }
  58249. declare var VRDisplay: {
  58250. prototype: VRDisplay;
  58251. new(): VRDisplay;
  58252. };
  58253. interface VRLayer {
  58254. leftBounds?: number[] | Float32Array | null;
  58255. rightBounds?: number[] | Float32Array | null;
  58256. source?: HTMLCanvasElement | null;
  58257. }
  58258. interface VRDisplayCapabilities {
  58259. readonly canPresent: boolean;
  58260. readonly hasExternalDisplay: boolean;
  58261. readonly hasOrientation: boolean;
  58262. readonly hasPosition: boolean;
  58263. readonly maxLayers: number;
  58264. }
  58265. interface VREyeParameters {
  58266. /** @deprecated */
  58267. readonly fieldOfView: VRFieldOfView;
  58268. readonly offset: Float32Array;
  58269. readonly renderHeight: number;
  58270. readonly renderWidth: number;
  58271. }
  58272. interface VRFieldOfView {
  58273. readonly downDegrees: number;
  58274. readonly leftDegrees: number;
  58275. readonly rightDegrees: number;
  58276. readonly upDegrees: number;
  58277. }
  58278. interface VRFrameData {
  58279. readonly leftProjectionMatrix: Float32Array;
  58280. readonly leftViewMatrix: Float32Array;
  58281. readonly pose: VRPose;
  58282. readonly rightProjectionMatrix: Float32Array;
  58283. readonly rightViewMatrix: Float32Array;
  58284. readonly timestamp: number;
  58285. }
  58286. interface VRPose {
  58287. readonly angularAcceleration: Float32Array | null;
  58288. readonly angularVelocity: Float32Array | null;
  58289. readonly linearAcceleration: Float32Array | null;
  58290. readonly linearVelocity: Float32Array | null;
  58291. readonly orientation: Float32Array | null;
  58292. readonly position: Float32Array | null;
  58293. readonly timestamp: number;
  58294. }
  58295. interface VRStageParameters {
  58296. sittingToStandingTransform?: Float32Array;
  58297. sizeX?: number;
  58298. sizeY?: number;
  58299. }
  58300. interface Navigator {
  58301. getVRDisplays(): Promise<VRDisplay[]>;
  58302. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  58303. }
  58304. interface Window {
  58305. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  58306. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  58307. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  58308. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  58309. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  58310. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  58311. }
  58312. interface Gamepad {
  58313. readonly displayId: number;
  58314. }
  58315. interface XRDevice {
  58316. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  58317. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  58318. }
  58319. interface XRSession {
  58320. getInputSources(): Array<any>;
  58321. baseLayer: XRWebGLLayer;
  58322. requestFrameOfReference(type: string): Promise<void>;
  58323. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  58324. end(): Promise<void>;
  58325. requestAnimationFrame: Function;
  58326. addEventListener: Function;
  58327. }
  58328. interface XRSessionCreationOptions {
  58329. outputContext?: WebGLRenderingContext | null;
  58330. immersive?: boolean;
  58331. environmentIntegration?: boolean;
  58332. }
  58333. interface XRLayer {
  58334. getViewport: Function;
  58335. framebufferWidth: number;
  58336. framebufferHeight: number;
  58337. }
  58338. interface XRView {
  58339. projectionMatrix: Float32Array;
  58340. }
  58341. interface XRFrame {
  58342. getDevicePose: Function;
  58343. getInputPose: Function;
  58344. views: Array<XRView>;
  58345. baseLayer: XRLayer;
  58346. }
  58347. interface XRFrameOfReference {
  58348. }
  58349. interface XRWebGLLayer extends XRLayer {
  58350. framebuffer: WebGLFramebuffer;
  58351. }
  58352. declare var XRWebGLLayer: {
  58353. prototype: XRWebGLLayer;
  58354. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  58355. };
  58356. declare module "babylonjs" {
  58357. export * from "babylonjs/Legacy/legacy";
  58358. }
  58359. declare module BABYLON {
  58360. /** Alias type for value that can be null */
  58361. export type Nullable<T> = T | null;
  58362. /**
  58363. * Alias type for number that are floats
  58364. * @ignorenaming
  58365. */
  58366. export type float = number;
  58367. /**
  58368. * Alias type for number that are doubles.
  58369. * @ignorenaming
  58370. */
  58371. export type double = number;
  58372. /**
  58373. * Alias type for number that are integer
  58374. * @ignorenaming
  58375. */
  58376. export type int = number;
  58377. /** Alias type for number array or Float32Array */
  58378. export type FloatArray = number[] | Float32Array;
  58379. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  58380. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  58381. /**
  58382. * Alias for types that can be used by a Buffer or VertexBuffer.
  58383. */
  58384. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  58385. /**
  58386. * Alias type for primitive types
  58387. * @ignorenaming
  58388. */
  58389. type Primitive = undefined | null | boolean | string | number | Function;
  58390. /**
  58391. * Type modifier to make all the properties of an object Readonly
  58392. */
  58393. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  58394. /**
  58395. * Type modifier to make all the properties of an object Readonly recursively
  58396. */
  58397. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  58398. /** @hidden */
  58399. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  58400. }
  58401. /** @hidden */
  58402. /** @hidden */
  58403. type DeepImmutableObject<T> = {
  58404. readonly [K in keyof T]: DeepImmutable<T[K]>;
  58405. };
  58406. }
  58407. declare module BABYLON {
  58408. /**
  58409. * Class containing a set of static utilities functions for arrays.
  58410. */
  58411. export class ArrayTools {
  58412. /**
  58413. * Returns an array of the given size filled with element built from the given constructor and the paramters
  58414. * @param size the number of element to construct and put in the array
  58415. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58416. * @returns a new array filled with new objects
  58417. */
  58418. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  58419. }
  58420. }
  58421. declare module BABYLON {
  58422. /**
  58423. * Scalar computation library
  58424. */
  58425. export class Scalar {
  58426. /**
  58427. * Two pi constants convenient for computation.
  58428. */
  58429. static TwoPi: number;
  58430. /**
  58431. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  58432. * @param a number
  58433. * @param b number
  58434. * @param epsilon (default = 1.401298E-45)
  58435. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  58436. */
  58437. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  58438. /**
  58439. * Returns a string : the upper case translation of the number i to hexadecimal.
  58440. * @param i number
  58441. * @returns the upper case translation of the number i to hexadecimal.
  58442. */
  58443. static ToHex(i: number): string;
  58444. /**
  58445. * Returns -1 if value is negative and +1 is value is positive.
  58446. * @param value the value
  58447. * @returns the value itself if it's equal to zero.
  58448. */
  58449. static Sign(value: number): number;
  58450. /**
  58451. * Returns the value itself if it's between min and max.
  58452. * Returns min if the value is lower than min.
  58453. * Returns max if the value is greater than max.
  58454. * @param value the value to clmap
  58455. * @param min the min value to clamp to (default: 0)
  58456. * @param max the max value to clamp to (default: 1)
  58457. * @returns the clamped value
  58458. */
  58459. static Clamp(value: number, min?: number, max?: number): number;
  58460. /**
  58461. * the log2 of value.
  58462. * @param value the value to compute log2 of
  58463. * @returns the log2 of value.
  58464. */
  58465. static Log2(value: number): number;
  58466. /**
  58467. * Loops the value, so that it is never larger than length and never smaller than 0.
  58468. *
  58469. * This is similar to the modulo operator but it works with floating point numbers.
  58470. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  58471. * With t = 5 and length = 2.5, the result would be 0.0.
  58472. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  58473. * @param value the value
  58474. * @param length the length
  58475. * @returns the looped value
  58476. */
  58477. static Repeat(value: number, length: number): number;
  58478. /**
  58479. * Normalize the value between 0.0 and 1.0 using min and max values
  58480. * @param value value to normalize
  58481. * @param min max to normalize between
  58482. * @param max min to normalize between
  58483. * @returns the normalized value
  58484. */
  58485. static Normalize(value: number, min: number, max: number): number;
  58486. /**
  58487. * Denormalize the value from 0.0 and 1.0 using min and max values
  58488. * @param normalized value to denormalize
  58489. * @param min max to denormalize between
  58490. * @param max min to denormalize between
  58491. * @returns the denormalized value
  58492. */
  58493. static Denormalize(normalized: number, min: number, max: number): number;
  58494. /**
  58495. * Calculates the shortest difference between two given angles given in degrees.
  58496. * @param current current angle in degrees
  58497. * @param target target angle in degrees
  58498. * @returns the delta
  58499. */
  58500. static DeltaAngle(current: number, target: number): number;
  58501. /**
  58502. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  58503. * @param tx value
  58504. * @param length length
  58505. * @returns The returned value will move back and forth between 0 and length
  58506. */
  58507. static PingPong(tx: number, length: number): number;
  58508. /**
  58509. * Interpolates between min and max with smoothing at the limits.
  58510. *
  58511. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  58512. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  58513. * @param from from
  58514. * @param to to
  58515. * @param tx value
  58516. * @returns the smooth stepped value
  58517. */
  58518. static SmoothStep(from: number, to: number, tx: number): number;
  58519. /**
  58520. * Moves a value current towards target.
  58521. *
  58522. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  58523. * Negative values of maxDelta pushes the value away from target.
  58524. * @param current current value
  58525. * @param target target value
  58526. * @param maxDelta max distance to move
  58527. * @returns resulting value
  58528. */
  58529. static MoveTowards(current: number, target: number, maxDelta: number): number;
  58530. /**
  58531. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  58532. *
  58533. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  58534. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  58535. * @param current current value
  58536. * @param target target value
  58537. * @param maxDelta max distance to move
  58538. * @returns resulting angle
  58539. */
  58540. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  58541. /**
  58542. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  58543. * @param start start value
  58544. * @param end target value
  58545. * @param amount amount to lerp between
  58546. * @returns the lerped value
  58547. */
  58548. static Lerp(start: number, end: number, amount: number): number;
  58549. /**
  58550. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  58551. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  58552. * @param start start value
  58553. * @param end target value
  58554. * @param amount amount to lerp between
  58555. * @returns the lerped value
  58556. */
  58557. static LerpAngle(start: number, end: number, amount: number): number;
  58558. /**
  58559. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  58560. * @param a start value
  58561. * @param b target value
  58562. * @param value value between a and b
  58563. * @returns the inverseLerp value
  58564. */
  58565. static InverseLerp(a: number, b: number, value: number): number;
  58566. /**
  58567. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  58568. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  58569. * @param value1 spline value
  58570. * @param tangent1 spline value
  58571. * @param value2 spline value
  58572. * @param tangent2 spline value
  58573. * @param amount input value
  58574. * @returns hermite result
  58575. */
  58576. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  58577. /**
  58578. * Returns a random float number between and min and max values
  58579. * @param min min value of random
  58580. * @param max max value of random
  58581. * @returns random value
  58582. */
  58583. static RandomRange(min: number, max: number): number;
  58584. /**
  58585. * This function returns percentage of a number in a given range.
  58586. *
  58587. * RangeToPercent(40,20,60) will return 0.5 (50%)
  58588. * RangeToPercent(34,0,100) will return 0.34 (34%)
  58589. * @param number to convert to percentage
  58590. * @param min min range
  58591. * @param max max range
  58592. * @returns the percentage
  58593. */
  58594. static RangeToPercent(number: number, min: number, max: number): number;
  58595. /**
  58596. * This function returns number that corresponds to the percentage in a given range.
  58597. *
  58598. * PercentToRange(0.34,0,100) will return 34.
  58599. * @param percent to convert to number
  58600. * @param min min range
  58601. * @param max max range
  58602. * @returns the number
  58603. */
  58604. static PercentToRange(percent: number, min: number, max: number): number;
  58605. /**
  58606. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  58607. * @param angle The angle to normalize in radian.
  58608. * @return The converted angle.
  58609. */
  58610. static NormalizeRadians(angle: number): number;
  58611. }
  58612. }
  58613. declare module BABYLON {
  58614. /**
  58615. * Constant used to convert a value to gamma space
  58616. * @ignorenaming
  58617. */
  58618. export const ToGammaSpace: number;
  58619. /**
  58620. * Constant used to convert a value to linear space
  58621. * @ignorenaming
  58622. */
  58623. export const ToLinearSpace = 2.2;
  58624. /**
  58625. * Constant used to define the minimal number value in Babylon.js
  58626. * @ignorenaming
  58627. */
  58628. export const Epsilon = 0.001;
  58629. /**
  58630. * Class used to hold a RBG color
  58631. */
  58632. export class Color3 {
  58633. /**
  58634. * Defines the red component (between 0 and 1, default is 0)
  58635. */
  58636. r: number;
  58637. /**
  58638. * Defines the green component (between 0 and 1, default is 0)
  58639. */
  58640. g: number;
  58641. /**
  58642. * Defines the blue component (between 0 and 1, default is 0)
  58643. */
  58644. b: number;
  58645. /**
  58646. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  58647. * @param r defines the red component (between 0 and 1, default is 0)
  58648. * @param g defines the green component (between 0 and 1, default is 0)
  58649. * @param b defines the blue component (between 0 and 1, default is 0)
  58650. */
  58651. constructor(
  58652. /**
  58653. * Defines the red component (between 0 and 1, default is 0)
  58654. */
  58655. r?: number,
  58656. /**
  58657. * Defines the green component (between 0 and 1, default is 0)
  58658. */
  58659. g?: number,
  58660. /**
  58661. * Defines the blue component (between 0 and 1, default is 0)
  58662. */
  58663. b?: number);
  58664. /**
  58665. * Creates a string with the Color3 current values
  58666. * @returns the string representation of the Color3 object
  58667. */
  58668. toString(): string;
  58669. /**
  58670. * Returns the string "Color3"
  58671. * @returns "Color3"
  58672. */
  58673. getClassName(): string;
  58674. /**
  58675. * Compute the Color3 hash code
  58676. * @returns an unique number that can be used to hash Color3 objects
  58677. */
  58678. getHashCode(): number;
  58679. /**
  58680. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  58681. * @param array defines the array where to store the r,g,b components
  58682. * @param index defines an optional index in the target array to define where to start storing values
  58683. * @returns the current Color3 object
  58684. */
  58685. toArray(array: FloatArray, index?: number): Color3;
  58686. /**
  58687. * Returns a new Color4 object from the current Color3 and the given alpha
  58688. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  58689. * @returns a new Color4 object
  58690. */
  58691. toColor4(alpha?: number): Color4;
  58692. /**
  58693. * Returns a new array populated with 3 numeric elements : red, green and blue values
  58694. * @returns the new array
  58695. */
  58696. asArray(): number[];
  58697. /**
  58698. * Returns the luminance value
  58699. * @returns a float value
  58700. */
  58701. toLuminance(): number;
  58702. /**
  58703. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  58704. * @param otherColor defines the second operand
  58705. * @returns the new Color3 object
  58706. */
  58707. multiply(otherColor: DeepImmutable<Color3>): Color3;
  58708. /**
  58709. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  58710. * @param otherColor defines the second operand
  58711. * @param result defines the Color3 object where to store the result
  58712. * @returns the current Color3
  58713. */
  58714. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58715. /**
  58716. * Determines equality between Color3 objects
  58717. * @param otherColor defines the second operand
  58718. * @returns true if the rgb values are equal to the given ones
  58719. */
  58720. equals(otherColor: DeepImmutable<Color3>): boolean;
  58721. /**
  58722. * Determines equality between the current Color3 object and a set of r,b,g values
  58723. * @param r defines the red component to check
  58724. * @param g defines the green component to check
  58725. * @param b defines the blue component to check
  58726. * @returns true if the rgb values are equal to the given ones
  58727. */
  58728. equalsFloats(r: number, g: number, b: number): boolean;
  58729. /**
  58730. * Multiplies in place each rgb value by scale
  58731. * @param scale defines the scaling factor
  58732. * @returns the updated Color3
  58733. */
  58734. scale(scale: number): Color3;
  58735. /**
  58736. * Multiplies the rgb values by scale and stores the result into "result"
  58737. * @param scale defines the scaling factor
  58738. * @param result defines the Color3 object where to store the result
  58739. * @returns the unmodified current Color3
  58740. */
  58741. scaleToRef(scale: number, result: Color3): Color3;
  58742. /**
  58743. * Scale the current Color3 values by a factor and add the result to a given Color3
  58744. * @param scale defines the scale factor
  58745. * @param result defines color to store the result into
  58746. * @returns the unmodified current Color3
  58747. */
  58748. scaleAndAddToRef(scale: number, result: Color3): Color3;
  58749. /**
  58750. * Clamps the rgb values by the min and max values and stores the result into "result"
  58751. * @param min defines minimum clamping value (default is 0)
  58752. * @param max defines maximum clamping value (default is 1)
  58753. * @param result defines color to store the result into
  58754. * @returns the original Color3
  58755. */
  58756. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  58757. /**
  58758. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  58759. * @param otherColor defines the second operand
  58760. * @returns the new Color3
  58761. */
  58762. add(otherColor: DeepImmutable<Color3>): Color3;
  58763. /**
  58764. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  58765. * @param otherColor defines the second operand
  58766. * @param result defines Color3 object to store the result into
  58767. * @returns the unmodified current Color3
  58768. */
  58769. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58770. /**
  58771. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  58772. * @param otherColor defines the second operand
  58773. * @returns the new Color3
  58774. */
  58775. subtract(otherColor: DeepImmutable<Color3>): Color3;
  58776. /**
  58777. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  58778. * @param otherColor defines the second operand
  58779. * @param result defines Color3 object to store the result into
  58780. * @returns the unmodified current Color3
  58781. */
  58782. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  58783. /**
  58784. * Copy the current object
  58785. * @returns a new Color3 copied the current one
  58786. */
  58787. clone(): Color3;
  58788. /**
  58789. * Copies the rgb values from the source in the current Color3
  58790. * @param source defines the source Color3 object
  58791. * @returns the updated Color3 object
  58792. */
  58793. copyFrom(source: DeepImmutable<Color3>): Color3;
  58794. /**
  58795. * Updates the Color3 rgb values from the given floats
  58796. * @param r defines the red component to read from
  58797. * @param g defines the green component to read from
  58798. * @param b defines the blue component to read from
  58799. * @returns the current Color3 object
  58800. */
  58801. copyFromFloats(r: number, g: number, b: number): Color3;
  58802. /**
  58803. * Updates the Color3 rgb values from the given floats
  58804. * @param r defines the red component to read from
  58805. * @param g defines the green component to read from
  58806. * @param b defines the blue component to read from
  58807. * @returns the current Color3 object
  58808. */
  58809. set(r: number, g: number, b: number): Color3;
  58810. /**
  58811. * Compute the Color3 hexadecimal code as a string
  58812. * @returns a string containing the hexadecimal representation of the Color3 object
  58813. */
  58814. toHexString(): string;
  58815. /**
  58816. * Computes a new Color3 converted from the current one to linear space
  58817. * @returns a new Color3 object
  58818. */
  58819. toLinearSpace(): Color3;
  58820. /**
  58821. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  58822. * @param convertedColor defines the Color3 object where to store the linear space version
  58823. * @returns the unmodified Color3
  58824. */
  58825. toLinearSpaceToRef(convertedColor: Color3): Color3;
  58826. /**
  58827. * Computes a new Color3 converted from the current one to gamma space
  58828. * @returns a new Color3 object
  58829. */
  58830. toGammaSpace(): Color3;
  58831. /**
  58832. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  58833. * @param convertedColor defines the Color3 object where to store the gamma space version
  58834. * @returns the unmodified Color3
  58835. */
  58836. toGammaSpaceToRef(convertedColor: Color3): Color3;
  58837. private static _BlackReadOnly;
  58838. /**
  58839. * Creates a new Color3 from the string containing valid hexadecimal values
  58840. * @param hex defines a string containing valid hexadecimal values
  58841. * @returns a new Color3 object
  58842. */
  58843. static FromHexString(hex: string): Color3;
  58844. /**
  58845. * Creates a new Vector3 from the starting index of the given array
  58846. * @param array defines the source array
  58847. * @param offset defines an offset in the source array
  58848. * @returns a new Color3 object
  58849. */
  58850. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  58851. /**
  58852. * Creates a new Color3 from integer values (< 256)
  58853. * @param r defines the red component to read from (value between 0 and 255)
  58854. * @param g defines the green component to read from (value between 0 and 255)
  58855. * @param b defines the blue component to read from (value between 0 and 255)
  58856. * @returns a new Color3 object
  58857. */
  58858. static FromInts(r: number, g: number, b: number): Color3;
  58859. /**
  58860. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  58861. * @param start defines the start Color3 value
  58862. * @param end defines the end Color3 value
  58863. * @param amount defines the gradient value between start and end
  58864. * @returns a new Color3 object
  58865. */
  58866. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  58867. /**
  58868. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  58869. * @param left defines the start value
  58870. * @param right defines the end value
  58871. * @param amount defines the gradient factor
  58872. * @param result defines the Color3 object where to store the result
  58873. */
  58874. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  58875. /**
  58876. * Returns a Color3 value containing a red color
  58877. * @returns a new Color3 object
  58878. */
  58879. static Red(): Color3;
  58880. /**
  58881. * Returns a Color3 value containing a green color
  58882. * @returns a new Color3 object
  58883. */
  58884. static Green(): Color3;
  58885. /**
  58886. * Returns a Color3 value containing a blue color
  58887. * @returns a new Color3 object
  58888. */
  58889. static Blue(): Color3;
  58890. /**
  58891. * Returns a Color3 value containing a black color
  58892. * @returns a new Color3 object
  58893. */
  58894. static Black(): Color3;
  58895. /**
  58896. * Gets a Color3 value containing a black color that must not be updated
  58897. */
  58898. static readonly BlackReadOnly: DeepImmutable<Color3>;
  58899. /**
  58900. * Returns a Color3 value containing a white color
  58901. * @returns a new Color3 object
  58902. */
  58903. static White(): Color3;
  58904. /**
  58905. * Returns a Color3 value containing a purple color
  58906. * @returns a new Color3 object
  58907. */
  58908. static Purple(): Color3;
  58909. /**
  58910. * Returns a Color3 value containing a magenta color
  58911. * @returns a new Color3 object
  58912. */
  58913. static Magenta(): Color3;
  58914. /**
  58915. * Returns a Color3 value containing a yellow color
  58916. * @returns a new Color3 object
  58917. */
  58918. static Yellow(): Color3;
  58919. /**
  58920. * Returns a Color3 value containing a gray color
  58921. * @returns a new Color3 object
  58922. */
  58923. static Gray(): Color3;
  58924. /**
  58925. * Returns a Color3 value containing a teal color
  58926. * @returns a new Color3 object
  58927. */
  58928. static Teal(): Color3;
  58929. /**
  58930. * Returns a Color3 value containing a random color
  58931. * @returns a new Color3 object
  58932. */
  58933. static Random(): Color3;
  58934. }
  58935. /**
  58936. * Class used to hold a RBGA color
  58937. */
  58938. export class Color4 {
  58939. /**
  58940. * Defines the red component (between 0 and 1, default is 0)
  58941. */
  58942. r: number;
  58943. /**
  58944. * Defines the green component (between 0 and 1, default is 0)
  58945. */
  58946. g: number;
  58947. /**
  58948. * Defines the blue component (between 0 and 1, default is 0)
  58949. */
  58950. b: number;
  58951. /**
  58952. * Defines the alpha component (between 0 and 1, default is 1)
  58953. */
  58954. a: number;
  58955. /**
  58956. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  58957. * @param r defines the red component (between 0 and 1, default is 0)
  58958. * @param g defines the green component (between 0 and 1, default is 0)
  58959. * @param b defines the blue component (between 0 and 1, default is 0)
  58960. * @param a defines the alpha component (between 0 and 1, default is 1)
  58961. */
  58962. constructor(
  58963. /**
  58964. * Defines the red component (between 0 and 1, default is 0)
  58965. */
  58966. r?: number,
  58967. /**
  58968. * Defines the green component (between 0 and 1, default is 0)
  58969. */
  58970. g?: number,
  58971. /**
  58972. * Defines the blue component (between 0 and 1, default is 0)
  58973. */
  58974. b?: number,
  58975. /**
  58976. * Defines the alpha component (between 0 and 1, default is 1)
  58977. */
  58978. a?: number);
  58979. /**
  58980. * Adds in place the given Color4 values to the current Color4 object
  58981. * @param right defines the second operand
  58982. * @returns the current updated Color4 object
  58983. */
  58984. addInPlace(right: DeepImmutable<Color4>): Color4;
  58985. /**
  58986. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  58987. * @returns the new array
  58988. */
  58989. asArray(): number[];
  58990. /**
  58991. * Stores from the starting index in the given array the Color4 successive values
  58992. * @param array defines the array where to store the r,g,b components
  58993. * @param index defines an optional index in the target array to define where to start storing values
  58994. * @returns the current Color4 object
  58995. */
  58996. toArray(array: number[], index?: number): Color4;
  58997. /**
  58998. * Determines equality between Color4 objects
  58999. * @param otherColor defines the second operand
  59000. * @returns true if the rgba values are equal to the given ones
  59001. */
  59002. equals(otherColor: DeepImmutable<Color4>): boolean;
  59003. /**
  59004. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  59005. * @param right defines the second operand
  59006. * @returns a new Color4 object
  59007. */
  59008. add(right: DeepImmutable<Color4>): Color4;
  59009. /**
  59010. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  59011. * @param right defines the second operand
  59012. * @returns a new Color4 object
  59013. */
  59014. subtract(right: DeepImmutable<Color4>): Color4;
  59015. /**
  59016. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  59017. * @param right defines the second operand
  59018. * @param result defines the Color4 object where to store the result
  59019. * @returns the current Color4 object
  59020. */
  59021. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  59022. /**
  59023. * Creates a new Color4 with the current Color4 values multiplied by scale
  59024. * @param scale defines the scaling factor to apply
  59025. * @returns a new Color4 object
  59026. */
  59027. scale(scale: number): Color4;
  59028. /**
  59029. * Multiplies the current Color4 values by scale and stores the result in "result"
  59030. * @param scale defines the scaling factor to apply
  59031. * @param result defines the Color4 object where to store the result
  59032. * @returns the current unmodified Color4
  59033. */
  59034. scaleToRef(scale: number, result: Color4): Color4;
  59035. /**
  59036. * Scale the current Color4 values by a factor and add the result to a given Color4
  59037. * @param scale defines the scale factor
  59038. * @param result defines the Color4 object where to store the result
  59039. * @returns the unmodified current Color4
  59040. */
  59041. scaleAndAddToRef(scale: number, result: Color4): Color4;
  59042. /**
  59043. * Clamps the rgb values by the min and max values and stores the result into "result"
  59044. * @param min defines minimum clamping value (default is 0)
  59045. * @param max defines maximum clamping value (default is 1)
  59046. * @param result defines color to store the result into.
  59047. * @returns the cuurent Color4
  59048. */
  59049. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  59050. /**
  59051. * Multipy an Color4 value by another and return a new Color4 object
  59052. * @param color defines the Color4 value to multiply by
  59053. * @returns a new Color4 object
  59054. */
  59055. multiply(color: Color4): Color4;
  59056. /**
  59057. * Multipy a Color4 value by another and push the result in a reference value
  59058. * @param color defines the Color4 value to multiply by
  59059. * @param result defines the Color4 to fill the result in
  59060. * @returns the result Color4
  59061. */
  59062. multiplyToRef(color: Color4, result: Color4): Color4;
  59063. /**
  59064. * Creates a string with the Color4 current values
  59065. * @returns the string representation of the Color4 object
  59066. */
  59067. toString(): string;
  59068. /**
  59069. * Returns the string "Color4"
  59070. * @returns "Color4"
  59071. */
  59072. getClassName(): string;
  59073. /**
  59074. * Compute the Color4 hash code
  59075. * @returns an unique number that can be used to hash Color4 objects
  59076. */
  59077. getHashCode(): number;
  59078. /**
  59079. * Creates a new Color4 copied from the current one
  59080. * @returns a new Color4 object
  59081. */
  59082. clone(): Color4;
  59083. /**
  59084. * Copies the given Color4 values into the current one
  59085. * @param source defines the source Color4 object
  59086. * @returns the current updated Color4 object
  59087. */
  59088. copyFrom(source: Color4): Color4;
  59089. /**
  59090. * Copies the given float values into the current one
  59091. * @param r defines the red component to read from
  59092. * @param g defines the green component to read from
  59093. * @param b defines the blue component to read from
  59094. * @param a defines the alpha component to read from
  59095. * @returns the current updated Color4 object
  59096. */
  59097. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  59098. /**
  59099. * Copies the given float values into the current one
  59100. * @param r defines the red component to read from
  59101. * @param g defines the green component to read from
  59102. * @param b defines the blue component to read from
  59103. * @param a defines the alpha component to read from
  59104. * @returns the current updated Color4 object
  59105. */
  59106. set(r: number, g: number, b: number, a: number): Color4;
  59107. /**
  59108. * Compute the Color4 hexadecimal code as a string
  59109. * @returns a string containing the hexadecimal representation of the Color4 object
  59110. */
  59111. toHexString(): string;
  59112. /**
  59113. * Computes a new Color4 converted from the current one to linear space
  59114. * @returns a new Color4 object
  59115. */
  59116. toLinearSpace(): Color4;
  59117. /**
  59118. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  59119. * @param convertedColor defines the Color4 object where to store the linear space version
  59120. * @returns the unmodified Color4
  59121. */
  59122. toLinearSpaceToRef(convertedColor: Color4): Color4;
  59123. /**
  59124. * Computes a new Color4 converted from the current one to gamma space
  59125. * @returns a new Color4 object
  59126. */
  59127. toGammaSpace(): Color4;
  59128. /**
  59129. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  59130. * @param convertedColor defines the Color4 object where to store the gamma space version
  59131. * @returns the unmodified Color4
  59132. */
  59133. toGammaSpaceToRef(convertedColor: Color4): Color4;
  59134. /**
  59135. * Creates a new Color4 from the string containing valid hexadecimal values
  59136. * @param hex defines a string containing valid hexadecimal values
  59137. * @returns a new Color4 object
  59138. */
  59139. static FromHexString(hex: string): Color4;
  59140. /**
  59141. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  59142. * @param left defines the start value
  59143. * @param right defines the end value
  59144. * @param amount defines the gradient factor
  59145. * @returns a new Color4 object
  59146. */
  59147. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  59148. /**
  59149. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  59150. * @param left defines the start value
  59151. * @param right defines the end value
  59152. * @param amount defines the gradient factor
  59153. * @param result defines the Color4 object where to store data
  59154. */
  59155. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  59156. /**
  59157. * Creates a new Color4 from a Color3 and an alpha value
  59158. * @param color3 defines the source Color3 to read from
  59159. * @param alpha defines the alpha component (1.0 by default)
  59160. * @returns a new Color4 object
  59161. */
  59162. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  59163. /**
  59164. * Creates a new Color4 from the starting index element of the given array
  59165. * @param array defines the source array to read from
  59166. * @param offset defines the offset in the source array
  59167. * @returns a new Color4 object
  59168. */
  59169. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  59170. /**
  59171. * Creates a new Color3 from integer values (< 256)
  59172. * @param r defines the red component to read from (value between 0 and 255)
  59173. * @param g defines the green component to read from (value between 0 and 255)
  59174. * @param b defines the blue component to read from (value between 0 and 255)
  59175. * @param a defines the alpha component to read from (value between 0 and 255)
  59176. * @returns a new Color3 object
  59177. */
  59178. static FromInts(r: number, g: number, b: number, a: number): Color4;
  59179. /**
  59180. * Check the content of a given array and convert it to an array containing RGBA data
  59181. * If the original array was already containing count * 4 values then it is returned directly
  59182. * @param colors defines the array to check
  59183. * @param count defines the number of RGBA data to expect
  59184. * @returns an array containing count * 4 values (RGBA)
  59185. */
  59186. static CheckColors4(colors: number[], count: number): number[];
  59187. }
  59188. /**
  59189. * Class representing a vector containing 2 coordinates
  59190. */
  59191. export class Vector2 {
  59192. /** defines the first coordinate */
  59193. x: number;
  59194. /** defines the second coordinate */
  59195. y: number;
  59196. /**
  59197. * Creates a new Vector2 from the given x and y coordinates
  59198. * @param x defines the first coordinate
  59199. * @param y defines the second coordinate
  59200. */
  59201. constructor(
  59202. /** defines the first coordinate */
  59203. x?: number,
  59204. /** defines the second coordinate */
  59205. y?: number);
  59206. /**
  59207. * Gets a string with the Vector2 coordinates
  59208. * @returns a string with the Vector2 coordinates
  59209. */
  59210. toString(): string;
  59211. /**
  59212. * Gets class name
  59213. * @returns the string "Vector2"
  59214. */
  59215. getClassName(): string;
  59216. /**
  59217. * Gets current vector hash code
  59218. * @returns the Vector2 hash code as a number
  59219. */
  59220. getHashCode(): number;
  59221. /**
  59222. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  59223. * @param array defines the source array
  59224. * @param index defines the offset in source array
  59225. * @returns the current Vector2
  59226. */
  59227. toArray(array: FloatArray, index?: number): Vector2;
  59228. /**
  59229. * Copy the current vector to an array
  59230. * @returns a new array with 2 elements: the Vector2 coordinates.
  59231. */
  59232. asArray(): number[];
  59233. /**
  59234. * Sets the Vector2 coordinates with the given Vector2 coordinates
  59235. * @param source defines the source Vector2
  59236. * @returns the current updated Vector2
  59237. */
  59238. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  59239. /**
  59240. * Sets the Vector2 coordinates with the given floats
  59241. * @param x defines the first coordinate
  59242. * @param y defines the second coordinate
  59243. * @returns the current updated Vector2
  59244. */
  59245. copyFromFloats(x: number, y: number): Vector2;
  59246. /**
  59247. * Sets the Vector2 coordinates with the given floats
  59248. * @param x defines the first coordinate
  59249. * @param y defines the second coordinate
  59250. * @returns the current updated Vector2
  59251. */
  59252. set(x: number, y: number): Vector2;
  59253. /**
  59254. * Add another vector with the current one
  59255. * @param otherVector defines the other vector
  59256. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  59257. */
  59258. add(otherVector: DeepImmutable<Vector2>): Vector2;
  59259. /**
  59260. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  59261. * @param otherVector defines the other vector
  59262. * @param result defines the target vector
  59263. * @returns the unmodified current Vector2
  59264. */
  59265. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59266. /**
  59267. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  59268. * @param otherVector defines the other vector
  59269. * @returns the current updated Vector2
  59270. */
  59271. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59272. /**
  59273. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  59274. * @param otherVector defines the other vector
  59275. * @returns a new Vector2
  59276. */
  59277. addVector3(otherVector: Vector3): Vector2;
  59278. /**
  59279. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  59280. * @param otherVector defines the other vector
  59281. * @returns a new Vector2
  59282. */
  59283. subtract(otherVector: Vector2): Vector2;
  59284. /**
  59285. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  59286. * @param otherVector defines the other vector
  59287. * @param result defines the target vector
  59288. * @returns the unmodified current Vector2
  59289. */
  59290. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59291. /**
  59292. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  59293. * @param otherVector defines the other vector
  59294. * @returns the current updated Vector2
  59295. */
  59296. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59297. /**
  59298. * Multiplies in place the current Vector2 coordinates by the given ones
  59299. * @param otherVector defines the other vector
  59300. * @returns the current updated Vector2
  59301. */
  59302. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59303. /**
  59304. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  59305. * @param otherVector defines the other vector
  59306. * @returns a new Vector2
  59307. */
  59308. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  59309. /**
  59310. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  59311. * @param otherVector defines the other vector
  59312. * @param result defines the target vector
  59313. * @returns the unmodified current Vector2
  59314. */
  59315. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59316. /**
  59317. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  59318. * @param x defines the first coordinate
  59319. * @param y defines the second coordinate
  59320. * @returns a new Vector2
  59321. */
  59322. multiplyByFloats(x: number, y: number): Vector2;
  59323. /**
  59324. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  59325. * @param otherVector defines the other vector
  59326. * @returns a new Vector2
  59327. */
  59328. divide(otherVector: Vector2): Vector2;
  59329. /**
  59330. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  59331. * @param otherVector defines the other vector
  59332. * @param result defines the target vector
  59333. * @returns the unmodified current Vector2
  59334. */
  59335. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  59336. /**
  59337. * Divides the current Vector2 coordinates by the given ones
  59338. * @param otherVector defines the other vector
  59339. * @returns the current updated Vector2
  59340. */
  59341. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  59342. /**
  59343. * Gets a new Vector2 with current Vector2 negated coordinates
  59344. * @returns a new Vector2
  59345. */
  59346. negate(): Vector2;
  59347. /**
  59348. * Multiply the Vector2 coordinates by scale
  59349. * @param scale defines the scaling factor
  59350. * @returns the current updated Vector2
  59351. */
  59352. scaleInPlace(scale: number): Vector2;
  59353. /**
  59354. * Returns a new Vector2 scaled by "scale" from the current Vector2
  59355. * @param scale defines the scaling factor
  59356. * @returns a new Vector2
  59357. */
  59358. scale(scale: number): Vector2;
  59359. /**
  59360. * Scale the current Vector2 values by a factor to a given Vector2
  59361. * @param scale defines the scale factor
  59362. * @param result defines the Vector2 object where to store the result
  59363. * @returns the unmodified current Vector2
  59364. */
  59365. scaleToRef(scale: number, result: Vector2): Vector2;
  59366. /**
  59367. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  59368. * @param scale defines the scale factor
  59369. * @param result defines the Vector2 object where to store the result
  59370. * @returns the unmodified current Vector2
  59371. */
  59372. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  59373. /**
  59374. * Gets a boolean if two vectors are equals
  59375. * @param otherVector defines the other vector
  59376. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  59377. */
  59378. equals(otherVector: DeepImmutable<Vector2>): boolean;
  59379. /**
  59380. * Gets a boolean if two vectors are equals (using an epsilon value)
  59381. * @param otherVector defines the other vector
  59382. * @param epsilon defines the minimal distance to consider equality
  59383. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  59384. */
  59385. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  59386. /**
  59387. * Gets a new Vector2 from current Vector2 floored values
  59388. * @returns a new Vector2
  59389. */
  59390. floor(): Vector2;
  59391. /**
  59392. * Gets a new Vector2 from current Vector2 floored values
  59393. * @returns a new Vector2
  59394. */
  59395. fract(): Vector2;
  59396. /**
  59397. * Gets the length of the vector
  59398. * @returns the vector length (float)
  59399. */
  59400. length(): number;
  59401. /**
  59402. * Gets the vector squared length
  59403. * @returns the vector squared length (float)
  59404. */
  59405. lengthSquared(): number;
  59406. /**
  59407. * Normalize the vector
  59408. * @returns the current updated Vector2
  59409. */
  59410. normalize(): Vector2;
  59411. /**
  59412. * Gets a new Vector2 copied from the Vector2
  59413. * @returns a new Vector2
  59414. */
  59415. clone(): Vector2;
  59416. /**
  59417. * Gets a new Vector2(0, 0)
  59418. * @returns a new Vector2
  59419. */
  59420. static Zero(): Vector2;
  59421. /**
  59422. * Gets a new Vector2(1, 1)
  59423. * @returns a new Vector2
  59424. */
  59425. static One(): Vector2;
  59426. /**
  59427. * Gets a new Vector2 set from the given index element of the given array
  59428. * @param array defines the data source
  59429. * @param offset defines the offset in the data source
  59430. * @returns a new Vector2
  59431. */
  59432. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  59433. /**
  59434. * Sets "result" from the given index element of the given array
  59435. * @param array defines the data source
  59436. * @param offset defines the offset in the data source
  59437. * @param result defines the target vector
  59438. */
  59439. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  59440. /**
  59441. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  59442. * @param value1 defines 1st point of control
  59443. * @param value2 defines 2nd point of control
  59444. * @param value3 defines 3rd point of control
  59445. * @param value4 defines 4th point of control
  59446. * @param amount defines the interpolation factor
  59447. * @returns a new Vector2
  59448. */
  59449. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  59450. /**
  59451. * 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".
  59452. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  59453. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  59454. * @param value defines the value to clamp
  59455. * @param min defines the lower limit
  59456. * @param max defines the upper limit
  59457. * @returns a new Vector2
  59458. */
  59459. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  59460. /**
  59461. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  59462. * @param value1 defines the 1st control point
  59463. * @param tangent1 defines the outgoing tangent
  59464. * @param value2 defines the 2nd control point
  59465. * @param tangent2 defines the incoming tangent
  59466. * @param amount defines the interpolation factor
  59467. * @returns a new Vector2
  59468. */
  59469. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  59470. /**
  59471. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  59472. * @param start defines the start vector
  59473. * @param end defines the end vector
  59474. * @param amount defines the interpolation factor
  59475. * @returns a new Vector2
  59476. */
  59477. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  59478. /**
  59479. * Gets the dot product of the vector "left" and the vector "right"
  59480. * @param left defines first vector
  59481. * @param right defines second vector
  59482. * @returns the dot product (float)
  59483. */
  59484. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  59485. /**
  59486. * Returns a new Vector2 equal to the normalized given vector
  59487. * @param vector defines the vector to normalize
  59488. * @returns a new Vector2
  59489. */
  59490. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  59491. /**
  59492. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  59493. * @param left defines 1st vector
  59494. * @param right defines 2nd vector
  59495. * @returns a new Vector2
  59496. */
  59497. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  59498. /**
  59499. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  59500. * @param left defines 1st vector
  59501. * @param right defines 2nd vector
  59502. * @returns a new Vector2
  59503. */
  59504. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  59505. /**
  59506. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  59507. * @param vector defines the vector to transform
  59508. * @param transformation defines the matrix to apply
  59509. * @returns a new Vector2
  59510. */
  59511. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  59512. /**
  59513. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  59514. * @param vector defines the vector to transform
  59515. * @param transformation defines the matrix to apply
  59516. * @param result defines the target vector
  59517. */
  59518. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  59519. /**
  59520. * Determines if a given vector is included in a triangle
  59521. * @param p defines the vector to test
  59522. * @param p0 defines 1st triangle point
  59523. * @param p1 defines 2nd triangle point
  59524. * @param p2 defines 3rd triangle point
  59525. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  59526. */
  59527. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  59528. /**
  59529. * Gets the distance between the vectors "value1" and "value2"
  59530. * @param value1 defines first vector
  59531. * @param value2 defines second vector
  59532. * @returns the distance between vectors
  59533. */
  59534. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  59535. /**
  59536. * Returns the squared distance between the vectors "value1" and "value2"
  59537. * @param value1 defines first vector
  59538. * @param value2 defines second vector
  59539. * @returns the squared distance between vectors
  59540. */
  59541. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  59542. /**
  59543. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  59544. * @param value1 defines first vector
  59545. * @param value2 defines second vector
  59546. * @returns a new Vector2
  59547. */
  59548. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  59549. /**
  59550. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  59551. * @param p defines the middle point
  59552. * @param segA defines one point of the segment
  59553. * @param segB defines the other point of the segment
  59554. * @returns the shortest distance
  59555. */
  59556. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  59557. }
  59558. /**
  59559. * Classed used to store (x,y,z) vector representation
  59560. * A Vector3 is the main object used in 3D geometry
  59561. * It can represent etiher the coordinates of a point the space, either a direction
  59562. * Reminder: js uses a left handed forward facing system
  59563. */
  59564. export class Vector3 {
  59565. /**
  59566. * Defines the first coordinates (on X axis)
  59567. */
  59568. x: number;
  59569. /**
  59570. * Defines the second coordinates (on Y axis)
  59571. */
  59572. y: number;
  59573. /**
  59574. * Defines the third coordinates (on Z axis)
  59575. */
  59576. z: number;
  59577. private static _UpReadOnly;
  59578. /**
  59579. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  59580. * @param x defines the first coordinates (on X axis)
  59581. * @param y defines the second coordinates (on Y axis)
  59582. * @param z defines the third coordinates (on Z axis)
  59583. */
  59584. constructor(
  59585. /**
  59586. * Defines the first coordinates (on X axis)
  59587. */
  59588. x?: number,
  59589. /**
  59590. * Defines the second coordinates (on Y axis)
  59591. */
  59592. y?: number,
  59593. /**
  59594. * Defines the third coordinates (on Z axis)
  59595. */
  59596. z?: number);
  59597. /**
  59598. * Creates a string representation of the Vector3
  59599. * @returns a string with the Vector3 coordinates.
  59600. */
  59601. toString(): string;
  59602. /**
  59603. * Gets the class name
  59604. * @returns the string "Vector3"
  59605. */
  59606. getClassName(): string;
  59607. /**
  59608. * Creates the Vector3 hash code
  59609. * @returns a number which tends to be unique between Vector3 instances
  59610. */
  59611. getHashCode(): number;
  59612. /**
  59613. * Creates an array containing three elements : the coordinates of the Vector3
  59614. * @returns a new array of numbers
  59615. */
  59616. asArray(): number[];
  59617. /**
  59618. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  59619. * @param array defines the destination array
  59620. * @param index defines the offset in the destination array
  59621. * @returns the current Vector3
  59622. */
  59623. toArray(array: FloatArray, index?: number): Vector3;
  59624. /**
  59625. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  59626. * @returns a new Quaternion object, computed from the Vector3 coordinates
  59627. */
  59628. toQuaternion(): Quaternion;
  59629. /**
  59630. * Adds the given vector to the current Vector3
  59631. * @param otherVector defines the second operand
  59632. * @returns the current updated Vector3
  59633. */
  59634. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59635. /**
  59636. * Adds the given coordinates to the current Vector3
  59637. * @param x defines the x coordinate of the operand
  59638. * @param y defines the y coordinate of the operand
  59639. * @param z defines the z coordinate of the operand
  59640. * @returns the current updated Vector3
  59641. */
  59642. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59643. /**
  59644. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  59645. * @param otherVector defines the second operand
  59646. * @returns the resulting Vector3
  59647. */
  59648. add(otherVector: DeepImmutable<Vector3>): Vector3;
  59649. /**
  59650. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  59651. * @param otherVector defines the second operand
  59652. * @param result defines the Vector3 object where to store the result
  59653. * @returns the current Vector3
  59654. */
  59655. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59656. /**
  59657. * Subtract the given vector from the current Vector3
  59658. * @param otherVector defines the second operand
  59659. * @returns the current updated Vector3
  59660. */
  59661. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59662. /**
  59663. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  59664. * @param otherVector defines the second operand
  59665. * @returns the resulting Vector3
  59666. */
  59667. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  59668. /**
  59669. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  59670. * @param otherVector defines the second operand
  59671. * @param result defines the Vector3 object where to store the result
  59672. * @returns the current Vector3
  59673. */
  59674. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59675. /**
  59676. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  59677. * @param x defines the x coordinate of the operand
  59678. * @param y defines the y coordinate of the operand
  59679. * @param z defines the z coordinate of the operand
  59680. * @returns the resulting Vector3
  59681. */
  59682. subtractFromFloats(x: number, y: number, z: number): Vector3;
  59683. /**
  59684. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  59685. * @param x defines the x coordinate of the operand
  59686. * @param y defines the y coordinate of the operand
  59687. * @param z defines the z coordinate of the operand
  59688. * @param result defines the Vector3 object where to store the result
  59689. * @returns the current Vector3
  59690. */
  59691. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  59692. /**
  59693. * Gets a new Vector3 set with the current Vector3 negated coordinates
  59694. * @returns a new Vector3
  59695. */
  59696. negate(): Vector3;
  59697. /**
  59698. * Multiplies the Vector3 coordinates by the float "scale"
  59699. * @param scale defines the multiplier factor
  59700. * @returns the current updated Vector3
  59701. */
  59702. scaleInPlace(scale: number): Vector3;
  59703. /**
  59704. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  59705. * @param scale defines the multiplier factor
  59706. * @returns a new Vector3
  59707. */
  59708. scale(scale: number): Vector3;
  59709. /**
  59710. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  59711. * @param scale defines the multiplier factor
  59712. * @param result defines the Vector3 object where to store the result
  59713. * @returns the current Vector3
  59714. */
  59715. scaleToRef(scale: number, result: Vector3): Vector3;
  59716. /**
  59717. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  59718. * @param scale defines the scale factor
  59719. * @param result defines the Vector3 object where to store the result
  59720. * @returns the unmodified current Vector3
  59721. */
  59722. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  59723. /**
  59724. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  59725. * @param otherVector defines the second operand
  59726. * @returns true if both vectors are equals
  59727. */
  59728. equals(otherVector: DeepImmutable<Vector3>): boolean;
  59729. /**
  59730. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  59731. * @param otherVector defines the second operand
  59732. * @param epsilon defines the minimal distance to define values as equals
  59733. * @returns true if both vectors are distant less than epsilon
  59734. */
  59735. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  59736. /**
  59737. * Returns true if the current Vector3 coordinates equals the given floats
  59738. * @param x defines the x coordinate of the operand
  59739. * @param y defines the y coordinate of the operand
  59740. * @param z defines the z coordinate of the operand
  59741. * @returns true if both vectors are equals
  59742. */
  59743. equalsToFloats(x: number, y: number, z: number): boolean;
  59744. /**
  59745. * Multiplies the current Vector3 coordinates by the given ones
  59746. * @param otherVector defines the second operand
  59747. * @returns the current updated Vector3
  59748. */
  59749. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  59750. /**
  59751. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  59752. * @param otherVector defines the second operand
  59753. * @returns the new Vector3
  59754. */
  59755. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  59756. /**
  59757. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  59758. * @param otherVector defines the second operand
  59759. * @param result defines the Vector3 object where to store the result
  59760. * @returns the current Vector3
  59761. */
  59762. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59763. /**
  59764. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  59765. * @param x defines the x coordinate of the operand
  59766. * @param y defines the y coordinate of the operand
  59767. * @param z defines the z coordinate of the operand
  59768. * @returns the new Vector3
  59769. */
  59770. multiplyByFloats(x: number, y: number, z: number): Vector3;
  59771. /**
  59772. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  59773. * @param otherVector defines the second operand
  59774. * @returns the new Vector3
  59775. */
  59776. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  59777. /**
  59778. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  59779. * @param otherVector defines the second operand
  59780. * @param result defines the Vector3 object where to store the result
  59781. * @returns the current Vector3
  59782. */
  59783. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  59784. /**
  59785. * Divides the current Vector3 coordinates by the given ones.
  59786. * @param otherVector defines the second operand
  59787. * @returns the current updated Vector3
  59788. */
  59789. divideInPlace(otherVector: Vector3): Vector3;
  59790. /**
  59791. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  59792. * @param other defines the second operand
  59793. * @returns the current updated Vector3
  59794. */
  59795. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59796. /**
  59797. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  59798. * @param other defines the second operand
  59799. * @returns the current updated Vector3
  59800. */
  59801. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  59802. /**
  59803. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  59804. * @param x defines the x coordinate of the operand
  59805. * @param y defines the y coordinate of the operand
  59806. * @param z defines the z coordinate of the operand
  59807. * @returns the current updated Vector3
  59808. */
  59809. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59810. /**
  59811. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  59812. * @param x defines the x coordinate of the operand
  59813. * @param y defines the y coordinate of the operand
  59814. * @param z defines the z coordinate of the operand
  59815. * @returns the current updated Vector3
  59816. */
  59817. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  59818. /**
  59819. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  59820. * Check if is non uniform within a certain amount of decimal places to account for this
  59821. * @param epsilon the amount the values can differ
  59822. * @returns if the the vector is non uniform to a certain number of decimal places
  59823. */
  59824. isNonUniformWithinEpsilon(epsilon: number): boolean;
  59825. /**
  59826. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  59827. */
  59828. readonly isNonUniform: boolean;
  59829. /**
  59830. * Gets a new Vector3 from current Vector3 floored values
  59831. * @returns a new Vector3
  59832. */
  59833. floor(): Vector3;
  59834. /**
  59835. * Gets a new Vector3 from current Vector3 floored values
  59836. * @returns a new Vector3
  59837. */
  59838. fract(): Vector3;
  59839. /**
  59840. * Gets the length of the Vector3
  59841. * @returns the length of the Vecto3
  59842. */
  59843. length(): number;
  59844. /**
  59845. * Gets the squared length of the Vector3
  59846. * @returns squared length of the Vector3
  59847. */
  59848. lengthSquared(): number;
  59849. /**
  59850. * Normalize the current Vector3.
  59851. * Please note that this is an in place operation.
  59852. * @returns the current updated Vector3
  59853. */
  59854. normalize(): Vector3;
  59855. /**
  59856. * Reorders the x y z properties of the vector in place
  59857. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  59858. * @returns the current updated vector
  59859. */
  59860. reorderInPlace(order: string): this;
  59861. /**
  59862. * Rotates the vector around 0,0,0 by a quaternion
  59863. * @param quaternion the rotation quaternion
  59864. * @param result vector to store the result
  59865. * @returns the resulting vector
  59866. */
  59867. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  59868. /**
  59869. * Rotates a vector around a given point
  59870. * @param quaternion the rotation quaternion
  59871. * @param point the point to rotate around
  59872. * @param result vector to store the result
  59873. * @returns the resulting vector
  59874. */
  59875. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  59876. /**
  59877. * Normalize the current Vector3 with the given input length.
  59878. * Please note that this is an in place operation.
  59879. * @param len the length of the vector
  59880. * @returns the current updated Vector3
  59881. */
  59882. normalizeFromLength(len: number): Vector3;
  59883. /**
  59884. * Normalize the current Vector3 to a new vector
  59885. * @returns the new Vector3
  59886. */
  59887. normalizeToNew(): Vector3;
  59888. /**
  59889. * Normalize the current Vector3 to the reference
  59890. * @param reference define the Vector3 to update
  59891. * @returns the updated Vector3
  59892. */
  59893. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  59894. /**
  59895. * Creates a new Vector3 copied from the current Vector3
  59896. * @returns the new Vector3
  59897. */
  59898. clone(): Vector3;
  59899. /**
  59900. * Copies the given vector coordinates to the current Vector3 ones
  59901. * @param source defines the source Vector3
  59902. * @returns the current updated Vector3
  59903. */
  59904. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  59905. /**
  59906. * Copies the given floats to the current Vector3 coordinates
  59907. * @param x defines the x coordinate of the operand
  59908. * @param y defines the y coordinate of the operand
  59909. * @param z defines the z coordinate of the operand
  59910. * @returns the current updated Vector3
  59911. */
  59912. copyFromFloats(x: number, y: number, z: number): Vector3;
  59913. /**
  59914. * Copies the given floats to the current Vector3 coordinates
  59915. * @param x defines the x coordinate of the operand
  59916. * @param y defines the y coordinate of the operand
  59917. * @param z defines the z coordinate of the operand
  59918. * @returns the current updated Vector3
  59919. */
  59920. set(x: number, y: number, z: number): Vector3;
  59921. /**
  59922. * Copies the given float to the current Vector3 coordinates
  59923. * @param v defines the x, y and z coordinates of the operand
  59924. * @returns the current updated Vector3
  59925. */
  59926. setAll(v: number): Vector3;
  59927. /**
  59928. * Get the clip factor between two vectors
  59929. * @param vector0 defines the first operand
  59930. * @param vector1 defines the second operand
  59931. * @param axis defines the axis to use
  59932. * @param size defines the size along the axis
  59933. * @returns the clip factor
  59934. */
  59935. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  59936. /**
  59937. * Get angle between two vectors
  59938. * @param vector0 angle between vector0 and vector1
  59939. * @param vector1 angle between vector0 and vector1
  59940. * @param normal direction of the normal
  59941. * @return the angle between vector0 and vector1
  59942. */
  59943. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  59944. /**
  59945. * Returns a new Vector3 set from the index "offset" of the given array
  59946. * @param array defines the source array
  59947. * @param offset defines the offset in the source array
  59948. * @returns the new Vector3
  59949. */
  59950. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  59951. /**
  59952. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  59953. * This function is deprecated. Use FromArray instead
  59954. * @param array defines the source array
  59955. * @param offset defines the offset in the source array
  59956. * @returns the new Vector3
  59957. */
  59958. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  59959. /**
  59960. * Sets the given vector "result" with the element values from the index "offset" of the given array
  59961. * @param array defines the source array
  59962. * @param offset defines the offset in the source array
  59963. * @param result defines the Vector3 where to store the result
  59964. */
  59965. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  59966. /**
  59967. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  59968. * This function is deprecated. Use FromArrayToRef instead.
  59969. * @param array defines the source array
  59970. * @param offset defines the offset in the source array
  59971. * @param result defines the Vector3 where to store the result
  59972. */
  59973. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  59974. /**
  59975. * Sets the given vector "result" with the given floats.
  59976. * @param x defines the x coordinate of the source
  59977. * @param y defines the y coordinate of the source
  59978. * @param z defines the z coordinate of the source
  59979. * @param result defines the Vector3 where to store the result
  59980. */
  59981. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  59982. /**
  59983. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  59984. * @returns a new empty Vector3
  59985. */
  59986. static Zero(): Vector3;
  59987. /**
  59988. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  59989. * @returns a new unit Vector3
  59990. */
  59991. static One(): Vector3;
  59992. /**
  59993. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  59994. * @returns a new up Vector3
  59995. */
  59996. static Up(): Vector3;
  59997. /**
  59998. * Gets a up Vector3 that must not be updated
  59999. */
  60000. static readonly UpReadOnly: DeepImmutable<Vector3>;
  60001. /**
  60002. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  60003. * @returns a new down Vector3
  60004. */
  60005. static Down(): Vector3;
  60006. /**
  60007. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  60008. * @returns a new forward Vector3
  60009. */
  60010. static Forward(): Vector3;
  60011. /**
  60012. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  60013. * @returns a new forward Vector3
  60014. */
  60015. static Backward(): Vector3;
  60016. /**
  60017. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  60018. * @returns a new right Vector3
  60019. */
  60020. static Right(): Vector3;
  60021. /**
  60022. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  60023. * @returns a new left Vector3
  60024. */
  60025. static Left(): Vector3;
  60026. /**
  60027. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  60028. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  60029. * @param vector defines the Vector3 to transform
  60030. * @param transformation defines the transformation matrix
  60031. * @returns the transformed Vector3
  60032. */
  60033. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  60034. /**
  60035. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  60036. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  60037. * @param vector defines the Vector3 to transform
  60038. * @param transformation defines the transformation matrix
  60039. * @param result defines the Vector3 where to store the result
  60040. */
  60041. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60042. /**
  60043. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  60044. * This method computes tranformed coordinates only, not transformed direction vectors
  60045. * @param x define the x coordinate of the source vector
  60046. * @param y define the y coordinate of the source vector
  60047. * @param z define the z coordinate of the source vector
  60048. * @param transformation defines the transformation matrix
  60049. * @param result defines the Vector3 where to store the result
  60050. */
  60051. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60052. /**
  60053. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  60054. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60055. * @param vector defines the Vector3 to transform
  60056. * @param transformation defines the transformation matrix
  60057. * @returns the new Vector3
  60058. */
  60059. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  60060. /**
  60061. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  60062. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60063. * @param vector defines the Vector3 to transform
  60064. * @param transformation defines the transformation matrix
  60065. * @param result defines the Vector3 where to store the result
  60066. */
  60067. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60068. /**
  60069. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  60070. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  60071. * @param x define the x coordinate of the source vector
  60072. * @param y define the y coordinate of the source vector
  60073. * @param z define the z coordinate of the source vector
  60074. * @param transformation defines the transformation matrix
  60075. * @param result defines the Vector3 where to store the result
  60076. */
  60077. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  60078. /**
  60079. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  60080. * @param value1 defines the first control point
  60081. * @param value2 defines the second control point
  60082. * @param value3 defines the third control point
  60083. * @param value4 defines the fourth control point
  60084. * @param amount defines the amount on the spline to use
  60085. * @returns the new Vector3
  60086. */
  60087. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  60088. /**
  60089. * 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"
  60090. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  60091. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  60092. * @param value defines the current value
  60093. * @param min defines the lower range value
  60094. * @param max defines the upper range value
  60095. * @returns the new Vector3
  60096. */
  60097. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  60098. /**
  60099. * 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"
  60100. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  60101. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  60102. * @param value defines the current value
  60103. * @param min defines the lower range value
  60104. * @param max defines the upper range value
  60105. * @param result defines the Vector3 where to store the result
  60106. */
  60107. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  60108. /**
  60109. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  60110. * @param value1 defines the first control point
  60111. * @param tangent1 defines the first tangent vector
  60112. * @param value2 defines the second control point
  60113. * @param tangent2 defines the second tangent vector
  60114. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  60115. * @returns the new Vector3
  60116. */
  60117. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  60118. /**
  60119. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  60120. * @param start defines the start value
  60121. * @param end defines the end value
  60122. * @param amount max defines amount between both (between 0 and 1)
  60123. * @returns the new Vector3
  60124. */
  60125. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  60126. /**
  60127. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  60128. * @param start defines the start value
  60129. * @param end defines the end value
  60130. * @param amount max defines amount between both (between 0 and 1)
  60131. * @param result defines the Vector3 where to store the result
  60132. */
  60133. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  60134. /**
  60135. * Returns the dot product (float) between the vectors "left" and "right"
  60136. * @param left defines the left operand
  60137. * @param right defines the right operand
  60138. * @returns the dot product
  60139. */
  60140. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  60141. /**
  60142. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  60143. * The cross product is then orthogonal to both "left" and "right"
  60144. * @param left defines the left operand
  60145. * @param right defines the right operand
  60146. * @returns the cross product
  60147. */
  60148. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60149. /**
  60150. * Sets the given vector "result" with the cross product of "left" and "right"
  60151. * The cross product is then orthogonal to both "left" and "right"
  60152. * @param left defines the left operand
  60153. * @param right defines the right operand
  60154. * @param result defines the Vector3 where to store the result
  60155. */
  60156. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  60157. /**
  60158. * Returns a new Vector3 as the normalization of the given vector
  60159. * @param vector defines the Vector3 to normalize
  60160. * @returns the new Vector3
  60161. */
  60162. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  60163. /**
  60164. * Sets the given vector "result" with the normalization of the given first vector
  60165. * @param vector defines the Vector3 to normalize
  60166. * @param result defines the Vector3 where to store the result
  60167. */
  60168. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  60169. /**
  60170. * Project a Vector3 onto screen space
  60171. * @param vector defines the Vector3 to project
  60172. * @param world defines the world matrix to use
  60173. * @param transform defines the transform (view x projection) matrix to use
  60174. * @param viewport defines the screen viewport to use
  60175. * @returns the new Vector3
  60176. */
  60177. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  60178. /** @hidden */
  60179. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  60180. /**
  60181. * Unproject from screen space to object space
  60182. * @param source defines the screen space Vector3 to use
  60183. * @param viewportWidth defines the current width of the viewport
  60184. * @param viewportHeight defines the current height of the viewport
  60185. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60186. * @param transform defines the transform (view x projection) matrix to use
  60187. * @returns the new Vector3
  60188. */
  60189. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  60190. /**
  60191. * Unproject from screen space to object space
  60192. * @param source defines the screen space Vector3 to use
  60193. * @param viewportWidth defines the current width of the viewport
  60194. * @param viewportHeight defines the current height of the viewport
  60195. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60196. * @param view defines the view matrix to use
  60197. * @param projection defines the projection matrix to use
  60198. * @returns the new Vector3
  60199. */
  60200. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  60201. /**
  60202. * Unproject from screen space to object space
  60203. * @param source defines the screen space Vector3 to use
  60204. * @param viewportWidth defines the current width of the viewport
  60205. * @param viewportHeight defines the current height of the viewport
  60206. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60207. * @param view defines the view matrix to use
  60208. * @param projection defines the projection matrix to use
  60209. * @param result defines the Vector3 where to store the result
  60210. */
  60211. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  60212. /**
  60213. * Unproject from screen space to object space
  60214. * @param sourceX defines the screen space x coordinate to use
  60215. * @param sourceY defines the screen space y coordinate to use
  60216. * @param sourceZ defines the screen space z coordinate to use
  60217. * @param viewportWidth defines the current width of the viewport
  60218. * @param viewportHeight defines the current height of the viewport
  60219. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  60220. * @param view defines the view matrix to use
  60221. * @param projection defines the projection matrix to use
  60222. * @param result defines the Vector3 where to store the result
  60223. */
  60224. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  60225. /**
  60226. * Gets the minimal coordinate values between two Vector3
  60227. * @param left defines the first operand
  60228. * @param right defines the second operand
  60229. * @returns the new Vector3
  60230. */
  60231. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60232. /**
  60233. * Gets the maximal coordinate values between two Vector3
  60234. * @param left defines the first operand
  60235. * @param right defines the second operand
  60236. * @returns the new Vector3
  60237. */
  60238. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  60239. /**
  60240. * Returns the distance between the vectors "value1" and "value2"
  60241. * @param value1 defines the first operand
  60242. * @param value2 defines the second operand
  60243. * @returns the distance
  60244. */
  60245. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  60246. /**
  60247. * Returns the squared distance between the vectors "value1" and "value2"
  60248. * @param value1 defines the first operand
  60249. * @param value2 defines the second operand
  60250. * @returns the squared distance
  60251. */
  60252. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  60253. /**
  60254. * Returns a new Vector3 located at the center between "value1" and "value2"
  60255. * @param value1 defines the first operand
  60256. * @param value2 defines the second operand
  60257. * @returns the new Vector3
  60258. */
  60259. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  60260. /**
  60261. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  60262. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  60263. * to something in order to rotate it from its local system to the given target system
  60264. * Note: axis1, axis2 and axis3 are normalized during this operation
  60265. * @param axis1 defines the first axis
  60266. * @param axis2 defines the second axis
  60267. * @param axis3 defines the third axis
  60268. * @returns a new Vector3
  60269. */
  60270. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  60271. /**
  60272. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  60273. * @param axis1 defines the first axis
  60274. * @param axis2 defines the second axis
  60275. * @param axis3 defines the third axis
  60276. * @param ref defines the Vector3 where to store the result
  60277. */
  60278. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  60279. }
  60280. /**
  60281. * Vector4 class created for EulerAngle class conversion to Quaternion
  60282. */
  60283. export class Vector4 {
  60284. /** x value of the vector */
  60285. x: number;
  60286. /** y value of the vector */
  60287. y: number;
  60288. /** z value of the vector */
  60289. z: number;
  60290. /** w value of the vector */
  60291. w: number;
  60292. /**
  60293. * Creates a Vector4 object from the given floats.
  60294. * @param x x value of the vector
  60295. * @param y y value of the vector
  60296. * @param z z value of the vector
  60297. * @param w w value of the vector
  60298. */
  60299. constructor(
  60300. /** x value of the vector */
  60301. x: number,
  60302. /** y value of the vector */
  60303. y: number,
  60304. /** z value of the vector */
  60305. z: number,
  60306. /** w value of the vector */
  60307. w: number);
  60308. /**
  60309. * Returns the string with the Vector4 coordinates.
  60310. * @returns a string containing all the vector values
  60311. */
  60312. toString(): string;
  60313. /**
  60314. * Returns the string "Vector4".
  60315. * @returns "Vector4"
  60316. */
  60317. getClassName(): string;
  60318. /**
  60319. * Returns the Vector4 hash code.
  60320. * @returns a unique hash code
  60321. */
  60322. getHashCode(): number;
  60323. /**
  60324. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  60325. * @returns the resulting array
  60326. */
  60327. asArray(): number[];
  60328. /**
  60329. * Populates the given array from the given index with the Vector4 coordinates.
  60330. * @param array array to populate
  60331. * @param index index of the array to start at (default: 0)
  60332. * @returns the Vector4.
  60333. */
  60334. toArray(array: FloatArray, index?: number): Vector4;
  60335. /**
  60336. * Adds the given vector to the current Vector4.
  60337. * @param otherVector the vector to add
  60338. * @returns the updated Vector4.
  60339. */
  60340. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  60341. /**
  60342. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  60343. * @param otherVector the vector to add
  60344. * @returns the resulting vector
  60345. */
  60346. add(otherVector: DeepImmutable<Vector4>): Vector4;
  60347. /**
  60348. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  60349. * @param otherVector the vector to add
  60350. * @param result the vector to store the result
  60351. * @returns the current Vector4.
  60352. */
  60353. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60354. /**
  60355. * Subtract in place the given vector from the current Vector4.
  60356. * @param otherVector the vector to subtract
  60357. * @returns the updated Vector4.
  60358. */
  60359. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  60360. /**
  60361. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  60362. * @param otherVector the vector to add
  60363. * @returns the new vector with the result
  60364. */
  60365. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  60366. /**
  60367. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  60368. * @param otherVector the vector to subtract
  60369. * @param result the vector to store the result
  60370. * @returns the current Vector4.
  60371. */
  60372. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60373. /**
  60374. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  60375. */
  60376. /**
  60377. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  60378. * @param x value to subtract
  60379. * @param y value to subtract
  60380. * @param z value to subtract
  60381. * @param w value to subtract
  60382. * @returns new vector containing the result
  60383. */
  60384. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  60385. /**
  60386. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  60387. * @param x value to subtract
  60388. * @param y value to subtract
  60389. * @param z value to subtract
  60390. * @param w value to subtract
  60391. * @param result the vector to store the result in
  60392. * @returns the current Vector4.
  60393. */
  60394. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  60395. /**
  60396. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  60397. * @returns a new vector with the negated values
  60398. */
  60399. negate(): Vector4;
  60400. /**
  60401. * Multiplies the current Vector4 coordinates by scale (float).
  60402. * @param scale the number to scale with
  60403. * @returns the updated Vector4.
  60404. */
  60405. scaleInPlace(scale: number): Vector4;
  60406. /**
  60407. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  60408. * @param scale the number to scale with
  60409. * @returns a new vector with the result
  60410. */
  60411. scale(scale: number): Vector4;
  60412. /**
  60413. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  60414. * @param scale the number to scale with
  60415. * @param result a vector to store the result in
  60416. * @returns the current Vector4.
  60417. */
  60418. scaleToRef(scale: number, result: Vector4): Vector4;
  60419. /**
  60420. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  60421. * @param scale defines the scale factor
  60422. * @param result defines the Vector4 object where to store the result
  60423. * @returns the unmodified current Vector4
  60424. */
  60425. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  60426. /**
  60427. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  60428. * @param otherVector the vector to compare against
  60429. * @returns true if they are equal
  60430. */
  60431. equals(otherVector: DeepImmutable<Vector4>): boolean;
  60432. /**
  60433. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  60434. * @param otherVector vector to compare against
  60435. * @param epsilon (Default: very small number)
  60436. * @returns true if they are equal
  60437. */
  60438. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  60439. /**
  60440. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  60441. * @param x x value to compare against
  60442. * @param y y value to compare against
  60443. * @param z z value to compare against
  60444. * @param w w value to compare against
  60445. * @returns true if equal
  60446. */
  60447. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  60448. /**
  60449. * Multiplies in place the current Vector4 by the given one.
  60450. * @param otherVector vector to multiple with
  60451. * @returns the updated Vector4.
  60452. */
  60453. multiplyInPlace(otherVector: Vector4): Vector4;
  60454. /**
  60455. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  60456. * @param otherVector vector to multiple with
  60457. * @returns resulting new vector
  60458. */
  60459. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  60460. /**
  60461. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  60462. * @param otherVector vector to multiple with
  60463. * @param result vector to store the result
  60464. * @returns the current Vector4.
  60465. */
  60466. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60467. /**
  60468. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  60469. * @param x x value multiply with
  60470. * @param y y value multiply with
  60471. * @param z z value multiply with
  60472. * @param w w value multiply with
  60473. * @returns resulting new vector
  60474. */
  60475. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  60476. /**
  60477. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  60478. * @param otherVector vector to devide with
  60479. * @returns resulting new vector
  60480. */
  60481. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  60482. /**
  60483. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  60484. * @param otherVector vector to devide with
  60485. * @param result vector to store the result
  60486. * @returns the current Vector4.
  60487. */
  60488. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  60489. /**
  60490. * Divides the current Vector3 coordinates by the given ones.
  60491. * @param otherVector vector to devide with
  60492. * @returns the updated Vector3.
  60493. */
  60494. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  60495. /**
  60496. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  60497. * @param other defines the second operand
  60498. * @returns the current updated Vector4
  60499. */
  60500. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  60501. /**
  60502. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  60503. * @param other defines the second operand
  60504. * @returns the current updated Vector4
  60505. */
  60506. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  60507. /**
  60508. * Gets a new Vector4 from current Vector4 floored values
  60509. * @returns a new Vector4
  60510. */
  60511. floor(): Vector4;
  60512. /**
  60513. * Gets a new Vector4 from current Vector3 floored values
  60514. * @returns a new Vector4
  60515. */
  60516. fract(): Vector4;
  60517. /**
  60518. * Returns the Vector4 length (float).
  60519. * @returns the length
  60520. */
  60521. length(): number;
  60522. /**
  60523. * Returns the Vector4 squared length (float).
  60524. * @returns the length squared
  60525. */
  60526. lengthSquared(): number;
  60527. /**
  60528. * Normalizes in place the Vector4.
  60529. * @returns the updated Vector4.
  60530. */
  60531. normalize(): Vector4;
  60532. /**
  60533. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  60534. * @returns this converted to a new vector3
  60535. */
  60536. toVector3(): Vector3;
  60537. /**
  60538. * Returns a new Vector4 copied from the current one.
  60539. * @returns the new cloned vector
  60540. */
  60541. clone(): Vector4;
  60542. /**
  60543. * Updates the current Vector4 with the given one coordinates.
  60544. * @param source the source vector to copy from
  60545. * @returns the updated Vector4.
  60546. */
  60547. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  60548. /**
  60549. * Updates the current Vector4 coordinates with the given floats.
  60550. * @param x float to copy from
  60551. * @param y float to copy from
  60552. * @param z float to copy from
  60553. * @param w float to copy from
  60554. * @returns the updated Vector4.
  60555. */
  60556. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  60557. /**
  60558. * Updates the current Vector4 coordinates with the given floats.
  60559. * @param x float to set from
  60560. * @param y float to set from
  60561. * @param z float to set from
  60562. * @param w float to set from
  60563. * @returns the updated Vector4.
  60564. */
  60565. set(x: number, y: number, z: number, w: number): Vector4;
  60566. /**
  60567. * Copies the given float to the current Vector3 coordinates
  60568. * @param v defines the x, y, z and w coordinates of the operand
  60569. * @returns the current updated Vector3
  60570. */
  60571. setAll(v: number): Vector4;
  60572. /**
  60573. * Returns a new Vector4 set from the starting index of the given array.
  60574. * @param array the array to pull values from
  60575. * @param offset the offset into the array to start at
  60576. * @returns the new vector
  60577. */
  60578. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  60579. /**
  60580. * Updates the given vector "result" from the starting index of the given array.
  60581. * @param array the array to pull values from
  60582. * @param offset the offset into the array to start at
  60583. * @param result the vector to store the result in
  60584. */
  60585. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  60586. /**
  60587. * Updates the given vector "result" from the starting index of the given Float32Array.
  60588. * @param array the array to pull values from
  60589. * @param offset the offset into the array to start at
  60590. * @param result the vector to store the result in
  60591. */
  60592. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  60593. /**
  60594. * Updates the given vector "result" coordinates from the given floats.
  60595. * @param x float to set from
  60596. * @param y float to set from
  60597. * @param z float to set from
  60598. * @param w float to set from
  60599. * @param result the vector to the floats in
  60600. */
  60601. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  60602. /**
  60603. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  60604. * @returns the new vector
  60605. */
  60606. static Zero(): Vector4;
  60607. /**
  60608. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  60609. * @returns the new vector
  60610. */
  60611. static One(): Vector4;
  60612. /**
  60613. * Returns a new normalized Vector4 from the given one.
  60614. * @param vector the vector to normalize
  60615. * @returns the vector
  60616. */
  60617. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  60618. /**
  60619. * Updates the given vector "result" from the normalization of the given one.
  60620. * @param vector the vector to normalize
  60621. * @param result the vector to store the result in
  60622. */
  60623. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  60624. /**
  60625. * Returns a vector with the minimum values from the left and right vectors
  60626. * @param left left vector to minimize
  60627. * @param right right vector to minimize
  60628. * @returns a new vector with the minimum of the left and right vector values
  60629. */
  60630. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  60631. /**
  60632. * Returns a vector with the maximum values from the left and right vectors
  60633. * @param left left vector to maximize
  60634. * @param right right vector to maximize
  60635. * @returns a new vector with the maximum of the left and right vector values
  60636. */
  60637. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  60638. /**
  60639. * Returns the distance (float) between the vectors "value1" and "value2".
  60640. * @param value1 value to calulate the distance between
  60641. * @param value2 value to calulate the distance between
  60642. * @return the distance between the two vectors
  60643. */
  60644. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  60645. /**
  60646. * Returns the squared distance (float) between the vectors "value1" and "value2".
  60647. * @param value1 value to calulate the distance between
  60648. * @param value2 value to calulate the distance between
  60649. * @return the distance between the two vectors squared
  60650. */
  60651. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  60652. /**
  60653. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  60654. * @param value1 value to calulate the center between
  60655. * @param value2 value to calulate the center between
  60656. * @return the center between the two vectors
  60657. */
  60658. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  60659. /**
  60660. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  60661. * This methods computes transformed normalized direction vectors only.
  60662. * @param vector the vector to transform
  60663. * @param transformation the transformation matrix to apply
  60664. * @returns the new vector
  60665. */
  60666. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  60667. /**
  60668. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  60669. * This methods computes transformed normalized direction vectors only.
  60670. * @param vector the vector to transform
  60671. * @param transformation the transformation matrix to apply
  60672. * @param result the vector to store the result in
  60673. */
  60674. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  60675. /**
  60676. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  60677. * This methods computes transformed normalized direction vectors only.
  60678. * @param x value to transform
  60679. * @param y value to transform
  60680. * @param z value to transform
  60681. * @param w value to transform
  60682. * @param transformation the transformation matrix to apply
  60683. * @param result the vector to store the results in
  60684. */
  60685. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  60686. /**
  60687. * Creates a new Vector4 from a Vector3
  60688. * @param source defines the source data
  60689. * @param w defines the 4th component (default is 0)
  60690. * @returns a new Vector4
  60691. */
  60692. static FromVector3(source: Vector3, w?: number): Vector4;
  60693. }
  60694. /**
  60695. * Interface for the size containing width and height
  60696. */
  60697. export interface ISize {
  60698. /**
  60699. * Width
  60700. */
  60701. width: number;
  60702. /**
  60703. * Heighht
  60704. */
  60705. height: number;
  60706. }
  60707. /**
  60708. * Size containing widht and height
  60709. */
  60710. export class Size implements ISize {
  60711. /**
  60712. * Width
  60713. */
  60714. width: number;
  60715. /**
  60716. * Height
  60717. */
  60718. height: number;
  60719. /**
  60720. * Creates a Size object from the given width and height (floats).
  60721. * @param width width of the new size
  60722. * @param height height of the new size
  60723. */
  60724. constructor(width: number, height: number);
  60725. /**
  60726. * Returns a string with the Size width and height
  60727. * @returns a string with the Size width and height
  60728. */
  60729. toString(): string;
  60730. /**
  60731. * "Size"
  60732. * @returns the string "Size"
  60733. */
  60734. getClassName(): string;
  60735. /**
  60736. * Returns the Size hash code.
  60737. * @returns a hash code for a unique width and height
  60738. */
  60739. getHashCode(): number;
  60740. /**
  60741. * Updates the current size from the given one.
  60742. * @param src the given size
  60743. */
  60744. copyFrom(src: Size): void;
  60745. /**
  60746. * Updates in place the current Size from the given floats.
  60747. * @param width width of the new size
  60748. * @param height height of the new size
  60749. * @returns the updated Size.
  60750. */
  60751. copyFromFloats(width: number, height: number): Size;
  60752. /**
  60753. * Updates in place the current Size from the given floats.
  60754. * @param width width to set
  60755. * @param height height to set
  60756. * @returns the updated Size.
  60757. */
  60758. set(width: number, height: number): Size;
  60759. /**
  60760. * Multiplies the width and height by numbers
  60761. * @param w factor to multiple the width by
  60762. * @param h factor to multiple the height by
  60763. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  60764. */
  60765. multiplyByFloats(w: number, h: number): Size;
  60766. /**
  60767. * Clones the size
  60768. * @returns a new Size copied from the given one.
  60769. */
  60770. clone(): Size;
  60771. /**
  60772. * True if the current Size and the given one width and height are strictly equal.
  60773. * @param other the other size to compare against
  60774. * @returns True if the current Size and the given one width and height are strictly equal.
  60775. */
  60776. equals(other: Size): boolean;
  60777. /**
  60778. * The surface of the Size : width * height (float).
  60779. */
  60780. readonly surface: number;
  60781. /**
  60782. * Create a new size of zero
  60783. * @returns a new Size set to (0.0, 0.0)
  60784. */
  60785. static Zero(): Size;
  60786. /**
  60787. * Sums the width and height of two sizes
  60788. * @param otherSize size to add to this size
  60789. * @returns a new Size set as the addition result of the current Size and the given one.
  60790. */
  60791. add(otherSize: Size): Size;
  60792. /**
  60793. * Subtracts the width and height of two
  60794. * @param otherSize size to subtract to this size
  60795. * @returns a new Size set as the subtraction result of the given one from the current Size.
  60796. */
  60797. subtract(otherSize: Size): Size;
  60798. /**
  60799. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  60800. * @param start starting size to lerp between
  60801. * @param end end size to lerp between
  60802. * @param amount amount to lerp between the start and end values
  60803. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  60804. */
  60805. static Lerp(start: Size, end: Size, amount: number): Size;
  60806. }
  60807. /**
  60808. * Class used to store quaternion data
  60809. * @see https://en.wikipedia.org/wiki/Quaternion
  60810. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  60811. */
  60812. export class Quaternion {
  60813. /** defines the first component (0 by default) */
  60814. x: number;
  60815. /** defines the second component (0 by default) */
  60816. y: number;
  60817. /** defines the third component (0 by default) */
  60818. z: number;
  60819. /** defines the fourth component (1.0 by default) */
  60820. w: number;
  60821. /**
  60822. * Creates a new Quaternion from the given floats
  60823. * @param x defines the first component (0 by default)
  60824. * @param y defines the second component (0 by default)
  60825. * @param z defines the third component (0 by default)
  60826. * @param w defines the fourth component (1.0 by default)
  60827. */
  60828. constructor(
  60829. /** defines the first component (0 by default) */
  60830. x?: number,
  60831. /** defines the second component (0 by default) */
  60832. y?: number,
  60833. /** defines the third component (0 by default) */
  60834. z?: number,
  60835. /** defines the fourth component (1.0 by default) */
  60836. w?: number);
  60837. /**
  60838. * Gets a string representation for the current quaternion
  60839. * @returns a string with the Quaternion coordinates
  60840. */
  60841. toString(): string;
  60842. /**
  60843. * Gets the class name of the quaternion
  60844. * @returns the string "Quaternion"
  60845. */
  60846. getClassName(): string;
  60847. /**
  60848. * Gets a hash code for this quaternion
  60849. * @returns the quaternion hash code
  60850. */
  60851. getHashCode(): number;
  60852. /**
  60853. * Copy the quaternion to an array
  60854. * @returns a new array populated with 4 elements from the quaternion coordinates
  60855. */
  60856. asArray(): number[];
  60857. /**
  60858. * Check if two quaternions are equals
  60859. * @param otherQuaternion defines the second operand
  60860. * @return true if the current quaternion and the given one coordinates are strictly equals
  60861. */
  60862. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  60863. /**
  60864. * Clone the current quaternion
  60865. * @returns a new quaternion copied from the current one
  60866. */
  60867. clone(): Quaternion;
  60868. /**
  60869. * Copy a quaternion to the current one
  60870. * @param other defines the other quaternion
  60871. * @returns the updated current quaternion
  60872. */
  60873. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  60874. /**
  60875. * Updates the current quaternion with the given float coordinates
  60876. * @param x defines the x coordinate
  60877. * @param y defines the y coordinate
  60878. * @param z defines the z coordinate
  60879. * @param w defines the w coordinate
  60880. * @returns the updated current quaternion
  60881. */
  60882. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  60883. /**
  60884. * Updates the current quaternion from the given float coordinates
  60885. * @param x defines the x coordinate
  60886. * @param y defines the y coordinate
  60887. * @param z defines the z coordinate
  60888. * @param w defines the w coordinate
  60889. * @returns the updated current quaternion
  60890. */
  60891. set(x: number, y: number, z: number, w: number): Quaternion;
  60892. /**
  60893. * Adds two quaternions
  60894. * @param other defines the second operand
  60895. * @returns a new quaternion as the addition result of the given one and the current quaternion
  60896. */
  60897. add(other: DeepImmutable<Quaternion>): Quaternion;
  60898. /**
  60899. * Add a quaternion to the current one
  60900. * @param other defines the quaternion to add
  60901. * @returns the current quaternion
  60902. */
  60903. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  60904. /**
  60905. * Subtract two quaternions
  60906. * @param other defines the second operand
  60907. * @returns a new quaternion as the subtraction result of the given one from the current one
  60908. */
  60909. subtract(other: Quaternion): Quaternion;
  60910. /**
  60911. * Multiplies the current quaternion by a scale factor
  60912. * @param value defines the scale factor
  60913. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  60914. */
  60915. scale(value: number): Quaternion;
  60916. /**
  60917. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  60918. * @param scale defines the scale factor
  60919. * @param result defines the Quaternion object where to store the result
  60920. * @returns the unmodified current quaternion
  60921. */
  60922. scaleToRef(scale: number, result: Quaternion): Quaternion;
  60923. /**
  60924. * Multiplies in place the current quaternion by a scale factor
  60925. * @param value defines the scale factor
  60926. * @returns the current modified quaternion
  60927. */
  60928. scaleInPlace(value: number): Quaternion;
  60929. /**
  60930. * Scale the current quaternion values by a factor and add the result to a given quaternion
  60931. * @param scale defines the scale factor
  60932. * @param result defines the Quaternion object where to store the result
  60933. * @returns the unmodified current quaternion
  60934. */
  60935. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  60936. /**
  60937. * Multiplies two quaternions
  60938. * @param q1 defines the second operand
  60939. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  60940. */
  60941. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  60942. /**
  60943. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  60944. * @param q1 defines the second operand
  60945. * @param result defines the target quaternion
  60946. * @returns the current quaternion
  60947. */
  60948. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  60949. /**
  60950. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  60951. * @param q1 defines the second operand
  60952. * @returns the currentupdated quaternion
  60953. */
  60954. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  60955. /**
  60956. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  60957. * @param ref defines the target quaternion
  60958. * @returns the current quaternion
  60959. */
  60960. conjugateToRef(ref: Quaternion): Quaternion;
  60961. /**
  60962. * Conjugates in place (1-q) the current quaternion
  60963. * @returns the current updated quaternion
  60964. */
  60965. conjugateInPlace(): Quaternion;
  60966. /**
  60967. * Conjugates in place (1-q) the current quaternion
  60968. * @returns a new quaternion
  60969. */
  60970. conjugate(): Quaternion;
  60971. /**
  60972. * Gets length of current quaternion
  60973. * @returns the quaternion length (float)
  60974. */
  60975. length(): number;
  60976. /**
  60977. * Normalize in place the current quaternion
  60978. * @returns the current updated quaternion
  60979. */
  60980. normalize(): Quaternion;
  60981. /**
  60982. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  60983. * @param order is a reserved parameter and is ignore for now
  60984. * @returns a new Vector3 containing the Euler angles
  60985. */
  60986. toEulerAngles(order?: string): Vector3;
  60987. /**
  60988. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  60989. * @param result defines the vector which will be filled with the Euler angles
  60990. * @param order is a reserved parameter and is ignore for now
  60991. * @returns the current unchanged quaternion
  60992. */
  60993. toEulerAnglesToRef(result: Vector3): Quaternion;
  60994. /**
  60995. * Updates the given rotation matrix with the current quaternion values
  60996. * @param result defines the target matrix
  60997. * @returns the current unchanged quaternion
  60998. */
  60999. toRotationMatrix(result: Matrix): Quaternion;
  61000. /**
  61001. * Updates the current quaternion from the given rotation matrix values
  61002. * @param matrix defines the source matrix
  61003. * @returns the current updated quaternion
  61004. */
  61005. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  61006. /**
  61007. * Creates a new quaternion from a rotation matrix
  61008. * @param matrix defines the source matrix
  61009. * @returns a new quaternion created from the given rotation matrix values
  61010. */
  61011. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  61012. /**
  61013. * Updates the given quaternion with the given rotation matrix values
  61014. * @param matrix defines the source matrix
  61015. * @param result defines the target quaternion
  61016. */
  61017. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  61018. /**
  61019. * Returns the dot product (float) between the quaternions "left" and "right"
  61020. * @param left defines the left operand
  61021. * @param right defines the right operand
  61022. * @returns the dot product
  61023. */
  61024. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  61025. /**
  61026. * Checks if the two quaternions are close to each other
  61027. * @param quat0 defines the first quaternion to check
  61028. * @param quat1 defines the second quaternion to check
  61029. * @returns true if the two quaternions are close to each other
  61030. */
  61031. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  61032. /**
  61033. * Creates an empty quaternion
  61034. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  61035. */
  61036. static Zero(): Quaternion;
  61037. /**
  61038. * Inverse a given quaternion
  61039. * @param q defines the source quaternion
  61040. * @returns a new quaternion as the inverted current quaternion
  61041. */
  61042. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  61043. /**
  61044. * Inverse a given quaternion
  61045. * @param q defines the source quaternion
  61046. * @param result the quaternion the result will be stored in
  61047. * @returns the result quaternion
  61048. */
  61049. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  61050. /**
  61051. * Creates an identity quaternion
  61052. * @returns the identity quaternion
  61053. */
  61054. static Identity(): Quaternion;
  61055. /**
  61056. * Gets a boolean indicating if the given quaternion is identity
  61057. * @param quaternion defines the quaternion to check
  61058. * @returns true if the quaternion is identity
  61059. */
  61060. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  61061. /**
  61062. * Creates a quaternion from a rotation around an axis
  61063. * @param axis defines the axis to use
  61064. * @param angle defines the angle to use
  61065. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  61066. */
  61067. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  61068. /**
  61069. * Creates a rotation around an axis and stores it into the given quaternion
  61070. * @param axis defines the axis to use
  61071. * @param angle defines the angle to use
  61072. * @param result defines the target quaternion
  61073. * @returns the target quaternion
  61074. */
  61075. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  61076. /**
  61077. * Creates a new quaternion from data stored into an array
  61078. * @param array defines the data source
  61079. * @param offset defines the offset in the source array where the data starts
  61080. * @returns a new quaternion
  61081. */
  61082. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  61083. /**
  61084. * Create a quaternion from Euler rotation angles
  61085. * @param x Pitch
  61086. * @param y Yaw
  61087. * @param z Roll
  61088. * @returns the new Quaternion
  61089. */
  61090. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  61091. /**
  61092. * Updates a quaternion from Euler rotation angles
  61093. * @param x Pitch
  61094. * @param y Yaw
  61095. * @param z Roll
  61096. * @param result the quaternion to store the result
  61097. * @returns the updated quaternion
  61098. */
  61099. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  61100. /**
  61101. * Create a quaternion from Euler rotation vector
  61102. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  61103. * @returns the new Quaternion
  61104. */
  61105. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  61106. /**
  61107. * Updates a quaternion from Euler rotation vector
  61108. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  61109. * @param result the quaternion to store the result
  61110. * @returns the updated quaternion
  61111. */
  61112. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  61113. /**
  61114. * Creates a new quaternion from the given Euler float angles (y, x, z)
  61115. * @param yaw defines the rotation around Y axis
  61116. * @param pitch defines the rotation around X axis
  61117. * @param roll defines the rotation around Z axis
  61118. * @returns the new quaternion
  61119. */
  61120. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  61121. /**
  61122. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  61123. * @param yaw defines the rotation around Y axis
  61124. * @param pitch defines the rotation around X axis
  61125. * @param roll defines the rotation around Z axis
  61126. * @param result defines the target quaternion
  61127. */
  61128. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  61129. /**
  61130. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  61131. * @param alpha defines the rotation around first axis
  61132. * @param beta defines the rotation around second axis
  61133. * @param gamma defines the rotation around third axis
  61134. * @returns the new quaternion
  61135. */
  61136. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  61137. /**
  61138. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  61139. * @param alpha defines the rotation around first axis
  61140. * @param beta defines the rotation around second axis
  61141. * @param gamma defines the rotation around third axis
  61142. * @param result defines the target quaternion
  61143. */
  61144. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  61145. /**
  61146. * 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)
  61147. * @param axis1 defines the first axis
  61148. * @param axis2 defines the second axis
  61149. * @param axis3 defines the third axis
  61150. * @returns the new quaternion
  61151. */
  61152. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  61153. /**
  61154. * 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
  61155. * @param axis1 defines the first axis
  61156. * @param axis2 defines the second axis
  61157. * @param axis3 defines the third axis
  61158. * @param ref defines the target quaternion
  61159. */
  61160. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  61161. /**
  61162. * Interpolates between two quaternions
  61163. * @param left defines first quaternion
  61164. * @param right defines second quaternion
  61165. * @param amount defines the gradient to use
  61166. * @returns the new interpolated quaternion
  61167. */
  61168. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  61169. /**
  61170. * Interpolates between two quaternions and stores it into a target quaternion
  61171. * @param left defines first quaternion
  61172. * @param right defines second quaternion
  61173. * @param amount defines the gradient to use
  61174. * @param result defines the target quaternion
  61175. */
  61176. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  61177. /**
  61178. * Interpolate between two quaternions using Hermite interpolation
  61179. * @param value1 defines first quaternion
  61180. * @param tangent1 defines the incoming tangent
  61181. * @param value2 defines second quaternion
  61182. * @param tangent2 defines the outgoing tangent
  61183. * @param amount defines the target quaternion
  61184. * @returns the new interpolated quaternion
  61185. */
  61186. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  61187. }
  61188. /**
  61189. * Class used to store matrix data (4x4)
  61190. */
  61191. export class Matrix {
  61192. private static _updateFlagSeed;
  61193. private static _identityReadOnly;
  61194. private _isIdentity;
  61195. private _isIdentityDirty;
  61196. private _isIdentity3x2;
  61197. private _isIdentity3x2Dirty;
  61198. /**
  61199. * Gets the update flag of the matrix which is an unique number for the matrix.
  61200. * It will be incremented every time the matrix data change.
  61201. * You can use it to speed the comparison between two versions of the same matrix.
  61202. */
  61203. updateFlag: number;
  61204. private readonly _m;
  61205. /**
  61206. * Gets the internal data of the matrix
  61207. */
  61208. readonly m: DeepImmutable<Float32Array>;
  61209. /** @hidden */
  61210. _markAsUpdated(): void;
  61211. /** @hidden */
  61212. private _updateIdentityStatus;
  61213. /**
  61214. * Creates an empty matrix (filled with zeros)
  61215. */
  61216. constructor();
  61217. /**
  61218. * Check if the current matrix is identity
  61219. * @returns true is the matrix is the identity matrix
  61220. */
  61221. isIdentity(): boolean;
  61222. /**
  61223. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  61224. * @returns true is the matrix is the identity matrix
  61225. */
  61226. isIdentityAs3x2(): boolean;
  61227. /**
  61228. * Gets the determinant of the matrix
  61229. * @returns the matrix determinant
  61230. */
  61231. determinant(): number;
  61232. /**
  61233. * Returns the matrix as a Float32Array
  61234. * @returns the matrix underlying array
  61235. */
  61236. toArray(): DeepImmutable<Float32Array>;
  61237. /**
  61238. * Returns the matrix as a Float32Array
  61239. * @returns the matrix underlying array.
  61240. */
  61241. asArray(): DeepImmutable<Float32Array>;
  61242. /**
  61243. * Inverts the current matrix in place
  61244. * @returns the current inverted matrix
  61245. */
  61246. invert(): Matrix;
  61247. /**
  61248. * Sets all the matrix elements to zero
  61249. * @returns the current matrix
  61250. */
  61251. reset(): Matrix;
  61252. /**
  61253. * Adds the current matrix with a second one
  61254. * @param other defines the matrix to add
  61255. * @returns a new matrix as the addition of the current matrix and the given one
  61256. */
  61257. add(other: DeepImmutable<Matrix>): Matrix;
  61258. /**
  61259. * Sets the given matrix "result" to the addition of the current matrix and the given one
  61260. * @param other defines the matrix to add
  61261. * @param result defines the target matrix
  61262. * @returns the current matrix
  61263. */
  61264. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  61265. /**
  61266. * Adds in place the given matrix to the current matrix
  61267. * @param other defines the second operand
  61268. * @returns the current updated matrix
  61269. */
  61270. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  61271. /**
  61272. * Sets the given matrix to the current inverted Matrix
  61273. * @param other defines the target matrix
  61274. * @returns the unmodified current matrix
  61275. */
  61276. invertToRef(other: Matrix): Matrix;
  61277. /**
  61278. * add a value at the specified position in the current Matrix
  61279. * @param index the index of the value within the matrix. between 0 and 15.
  61280. * @param value the value to be added
  61281. * @returns the current updated matrix
  61282. */
  61283. addAtIndex(index: number, value: number): Matrix;
  61284. /**
  61285. * mutiply the specified position in the current Matrix by a value
  61286. * @param index the index of the value within the matrix. between 0 and 15.
  61287. * @param value the value to be added
  61288. * @returns the current updated matrix
  61289. */
  61290. multiplyAtIndex(index: number, value: number): Matrix;
  61291. /**
  61292. * Inserts the translation vector (using 3 floats) in the current matrix
  61293. * @param x defines the 1st component of the translation
  61294. * @param y defines the 2nd component of the translation
  61295. * @param z defines the 3rd component of the translation
  61296. * @returns the current updated matrix
  61297. */
  61298. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  61299. /**
  61300. * Inserts the translation vector in the current matrix
  61301. * @param vector3 defines the translation to insert
  61302. * @returns the current updated matrix
  61303. */
  61304. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  61305. /**
  61306. * Gets the translation value of the current matrix
  61307. * @returns a new Vector3 as the extracted translation from the matrix
  61308. */
  61309. getTranslation(): Vector3;
  61310. /**
  61311. * Fill a Vector3 with the extracted translation from the matrix
  61312. * @param result defines the Vector3 where to store the translation
  61313. * @returns the current matrix
  61314. */
  61315. getTranslationToRef(result: Vector3): Matrix;
  61316. /**
  61317. * Remove rotation and scaling part from the matrix
  61318. * @returns the updated matrix
  61319. */
  61320. removeRotationAndScaling(): Matrix;
  61321. /**
  61322. * Multiply two matrices
  61323. * @param other defines the second operand
  61324. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  61325. */
  61326. multiply(other: DeepImmutable<Matrix>): Matrix;
  61327. /**
  61328. * Copy the current matrix from the given one
  61329. * @param other defines the source matrix
  61330. * @returns the current updated matrix
  61331. */
  61332. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  61333. /**
  61334. * Populates the given array from the starting index with the current matrix values
  61335. * @param array defines the target array
  61336. * @param offset defines the offset in the target array where to start storing values
  61337. * @returns the current matrix
  61338. */
  61339. copyToArray(array: Float32Array, offset?: number): Matrix;
  61340. /**
  61341. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  61342. * @param other defines the second operand
  61343. * @param result defines the matrix where to store the multiplication
  61344. * @returns the current matrix
  61345. */
  61346. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  61347. /**
  61348. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  61349. * @param other defines the second operand
  61350. * @param result defines the array where to store the multiplication
  61351. * @param offset defines the offset in the target array where to start storing values
  61352. * @returns the current matrix
  61353. */
  61354. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  61355. /**
  61356. * Check equality between this matrix and a second one
  61357. * @param value defines the second matrix to compare
  61358. * @returns true is the current matrix and the given one values are strictly equal
  61359. */
  61360. equals(value: DeepImmutable<Matrix>): boolean;
  61361. /**
  61362. * Clone the current matrix
  61363. * @returns a new matrix from the current matrix
  61364. */
  61365. clone(): Matrix;
  61366. /**
  61367. * Returns the name of the current matrix class
  61368. * @returns the string "Matrix"
  61369. */
  61370. getClassName(): string;
  61371. /**
  61372. * Gets the hash code of the current matrix
  61373. * @returns the hash code
  61374. */
  61375. getHashCode(): number;
  61376. /**
  61377. * Decomposes the current Matrix into a translation, rotation and scaling components
  61378. * @param scale defines the scale vector3 given as a reference to update
  61379. * @param rotation defines the rotation quaternion given as a reference to update
  61380. * @param translation defines the translation vector3 given as a reference to update
  61381. * @returns true if operation was successful
  61382. */
  61383. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  61384. /**
  61385. * Gets specific row of the matrix
  61386. * @param index defines the number of the row to get
  61387. * @returns the index-th row of the current matrix as a new Vector4
  61388. */
  61389. getRow(index: number): Nullable<Vector4>;
  61390. /**
  61391. * Sets the index-th row of the current matrix to the vector4 values
  61392. * @param index defines the number of the row to set
  61393. * @param row defines the target vector4
  61394. * @returns the updated current matrix
  61395. */
  61396. setRow(index: number, row: Vector4): Matrix;
  61397. /**
  61398. * Compute the transpose of the matrix
  61399. * @returns the new transposed matrix
  61400. */
  61401. transpose(): Matrix;
  61402. /**
  61403. * Compute the transpose of the matrix and store it in a given matrix
  61404. * @param result defines the target matrix
  61405. * @returns the current matrix
  61406. */
  61407. transposeToRef(result: Matrix): Matrix;
  61408. /**
  61409. * Sets the index-th row of the current matrix with the given 4 x float values
  61410. * @param index defines the row index
  61411. * @param x defines the x component to set
  61412. * @param y defines the y component to set
  61413. * @param z defines the z component to set
  61414. * @param w defines the w component to set
  61415. * @returns the updated current matrix
  61416. */
  61417. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  61418. /**
  61419. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  61420. * @param scale defines the scale factor
  61421. * @returns a new matrix
  61422. */
  61423. scale(scale: number): Matrix;
  61424. /**
  61425. * Scale the current matrix values by a factor to a given result matrix
  61426. * @param scale defines the scale factor
  61427. * @param result defines the matrix to store the result
  61428. * @returns the current matrix
  61429. */
  61430. scaleToRef(scale: number, result: Matrix): Matrix;
  61431. /**
  61432. * Scale the current matrix values by a factor and add the result to a given matrix
  61433. * @param scale defines the scale factor
  61434. * @param result defines the Matrix to store the result
  61435. * @returns the current matrix
  61436. */
  61437. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  61438. /**
  61439. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  61440. * @param ref matrix to store the result
  61441. */
  61442. toNormalMatrix(ref: Matrix): void;
  61443. /**
  61444. * Gets only rotation part of the current matrix
  61445. * @returns a new matrix sets to the extracted rotation matrix from the current one
  61446. */
  61447. getRotationMatrix(): Matrix;
  61448. /**
  61449. * Extracts the rotation matrix from the current one and sets it as the given "result"
  61450. * @param result defines the target matrix to store data to
  61451. * @returns the current matrix
  61452. */
  61453. getRotationMatrixToRef(result: Matrix): Matrix;
  61454. /**
  61455. * Toggles model matrix from being right handed to left handed in place and vice versa
  61456. */
  61457. toggleModelMatrixHandInPlace(): void;
  61458. /**
  61459. * Toggles projection matrix from being right handed to left handed in place and vice versa
  61460. */
  61461. toggleProjectionMatrixHandInPlace(): void;
  61462. /**
  61463. * Creates a matrix from an array
  61464. * @param array defines the source array
  61465. * @param offset defines an offset in the source array
  61466. * @returns a new Matrix set from the starting index of the given array
  61467. */
  61468. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  61469. /**
  61470. * Copy the content of an array into a given matrix
  61471. * @param array defines the source array
  61472. * @param offset defines an offset in the source array
  61473. * @param result defines the target matrix
  61474. */
  61475. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  61476. /**
  61477. * Stores an array into a matrix after having multiplied each component by a given factor
  61478. * @param array defines the source array
  61479. * @param offset defines the offset in the source array
  61480. * @param scale defines the scaling factor
  61481. * @param result defines the target matrix
  61482. */
  61483. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  61484. /**
  61485. * Gets an identity matrix that must not be updated
  61486. */
  61487. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  61488. /**
  61489. * Stores a list of values (16) inside a given matrix
  61490. * @param initialM11 defines 1st value of 1st row
  61491. * @param initialM12 defines 2nd value of 1st row
  61492. * @param initialM13 defines 3rd value of 1st row
  61493. * @param initialM14 defines 4th value of 1st row
  61494. * @param initialM21 defines 1st value of 2nd row
  61495. * @param initialM22 defines 2nd value of 2nd row
  61496. * @param initialM23 defines 3rd value of 2nd row
  61497. * @param initialM24 defines 4th value of 2nd row
  61498. * @param initialM31 defines 1st value of 3rd row
  61499. * @param initialM32 defines 2nd value of 3rd row
  61500. * @param initialM33 defines 3rd value of 3rd row
  61501. * @param initialM34 defines 4th value of 3rd row
  61502. * @param initialM41 defines 1st value of 4th row
  61503. * @param initialM42 defines 2nd value of 4th row
  61504. * @param initialM43 defines 3rd value of 4th row
  61505. * @param initialM44 defines 4th value of 4th row
  61506. * @param result defines the target matrix
  61507. */
  61508. 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;
  61509. /**
  61510. * Creates new matrix from a list of values (16)
  61511. * @param initialM11 defines 1st value of 1st row
  61512. * @param initialM12 defines 2nd value of 1st row
  61513. * @param initialM13 defines 3rd value of 1st row
  61514. * @param initialM14 defines 4th value of 1st row
  61515. * @param initialM21 defines 1st value of 2nd row
  61516. * @param initialM22 defines 2nd value of 2nd row
  61517. * @param initialM23 defines 3rd value of 2nd row
  61518. * @param initialM24 defines 4th value of 2nd row
  61519. * @param initialM31 defines 1st value of 3rd row
  61520. * @param initialM32 defines 2nd value of 3rd row
  61521. * @param initialM33 defines 3rd value of 3rd row
  61522. * @param initialM34 defines 4th value of 3rd row
  61523. * @param initialM41 defines 1st value of 4th row
  61524. * @param initialM42 defines 2nd value of 4th row
  61525. * @param initialM43 defines 3rd value of 4th row
  61526. * @param initialM44 defines 4th value of 4th row
  61527. * @returns the new matrix
  61528. */
  61529. 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;
  61530. /**
  61531. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  61532. * @param scale defines the scale vector3
  61533. * @param rotation defines the rotation quaternion
  61534. * @param translation defines the translation vector3
  61535. * @returns a new matrix
  61536. */
  61537. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  61538. /**
  61539. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  61540. * @param scale defines the scale vector3
  61541. * @param rotation defines the rotation quaternion
  61542. * @param translation defines the translation vector3
  61543. * @param result defines the target matrix
  61544. */
  61545. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  61546. /**
  61547. * Creates a new identity matrix
  61548. * @returns a new identity matrix
  61549. */
  61550. static Identity(): Matrix;
  61551. /**
  61552. * Creates a new identity matrix and stores the result in a given matrix
  61553. * @param result defines the target matrix
  61554. */
  61555. static IdentityToRef(result: Matrix): void;
  61556. /**
  61557. * Creates a new zero matrix
  61558. * @returns a new zero matrix
  61559. */
  61560. static Zero(): Matrix;
  61561. /**
  61562. * Creates a new rotation matrix for "angle" radians around the X axis
  61563. * @param angle defines the angle (in radians) to use
  61564. * @return the new matrix
  61565. */
  61566. static RotationX(angle: number): Matrix;
  61567. /**
  61568. * Creates a new matrix as the invert of a given matrix
  61569. * @param source defines the source matrix
  61570. * @returns the new matrix
  61571. */
  61572. static Invert(source: DeepImmutable<Matrix>): Matrix;
  61573. /**
  61574. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  61575. * @param angle defines the angle (in radians) to use
  61576. * @param result defines the target matrix
  61577. */
  61578. static RotationXToRef(angle: number, result: Matrix): void;
  61579. /**
  61580. * Creates a new rotation matrix for "angle" radians around the Y axis
  61581. * @param angle defines the angle (in radians) to use
  61582. * @return the new matrix
  61583. */
  61584. static RotationY(angle: number): Matrix;
  61585. /**
  61586. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  61587. * @param angle defines the angle (in radians) to use
  61588. * @param result defines the target matrix
  61589. */
  61590. static RotationYToRef(angle: number, result: Matrix): void;
  61591. /**
  61592. * Creates a new rotation matrix for "angle" radians around the Z axis
  61593. * @param angle defines the angle (in radians) to use
  61594. * @return the new matrix
  61595. */
  61596. static RotationZ(angle: number): Matrix;
  61597. /**
  61598. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  61599. * @param angle defines the angle (in radians) to use
  61600. * @param result defines the target matrix
  61601. */
  61602. static RotationZToRef(angle: number, result: Matrix): void;
  61603. /**
  61604. * Creates a new rotation matrix for "angle" radians around the given axis
  61605. * @param axis defines the axis to use
  61606. * @param angle defines the angle (in radians) to use
  61607. * @return the new matrix
  61608. */
  61609. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  61610. /**
  61611. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  61612. * @param axis defines the axis to use
  61613. * @param angle defines the angle (in radians) to use
  61614. * @param result defines the target matrix
  61615. */
  61616. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  61617. /**
  61618. * Creates a rotation matrix
  61619. * @param yaw defines the yaw angle in radians (Y axis)
  61620. * @param pitch defines the pitch angle in radians (X axis)
  61621. * @param roll defines the roll angle in radians (X axis)
  61622. * @returns the new rotation matrix
  61623. */
  61624. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  61625. /**
  61626. * Creates a rotation matrix and stores it in a given matrix
  61627. * @param yaw defines the yaw angle in radians (Y axis)
  61628. * @param pitch defines the pitch angle in radians (X axis)
  61629. * @param roll defines the roll angle in radians (X axis)
  61630. * @param result defines the target matrix
  61631. */
  61632. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  61633. /**
  61634. * Creates a scaling matrix
  61635. * @param x defines the scale factor on X axis
  61636. * @param y defines the scale factor on Y axis
  61637. * @param z defines the scale factor on Z axis
  61638. * @returns the new matrix
  61639. */
  61640. static Scaling(x: number, y: number, z: number): Matrix;
  61641. /**
  61642. * Creates a scaling matrix and stores it in a given matrix
  61643. * @param x defines the scale factor on X axis
  61644. * @param y defines the scale factor on Y axis
  61645. * @param z defines the scale factor on Z axis
  61646. * @param result defines the target matrix
  61647. */
  61648. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  61649. /**
  61650. * Creates a translation matrix
  61651. * @param x defines the translation on X axis
  61652. * @param y defines the translation on Y axis
  61653. * @param z defines the translationon Z axis
  61654. * @returns the new matrix
  61655. */
  61656. static Translation(x: number, y: number, z: number): Matrix;
  61657. /**
  61658. * Creates a translation matrix and stores it in a given matrix
  61659. * @param x defines the translation on X axis
  61660. * @param y defines the translation on Y axis
  61661. * @param z defines the translationon Z axis
  61662. * @param result defines the target matrix
  61663. */
  61664. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  61665. /**
  61666. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  61667. * @param startValue defines the start value
  61668. * @param endValue defines the end value
  61669. * @param gradient defines the gradient factor
  61670. * @returns the new matrix
  61671. */
  61672. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  61673. /**
  61674. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  61675. * @param startValue defines the start value
  61676. * @param endValue defines the end value
  61677. * @param gradient defines the gradient factor
  61678. * @param result defines the Matrix object where to store data
  61679. */
  61680. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  61681. /**
  61682. * Builds a new matrix whose values are computed by:
  61683. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  61684. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  61685. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  61686. * @param startValue defines the first matrix
  61687. * @param endValue defines the second matrix
  61688. * @param gradient defines the gradient between the two matrices
  61689. * @returns the new matrix
  61690. */
  61691. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  61692. /**
  61693. * Update a matrix to values which are computed by:
  61694. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  61695. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  61696. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  61697. * @param startValue defines the first matrix
  61698. * @param endValue defines the second matrix
  61699. * @param gradient defines the gradient between the two matrices
  61700. * @param result defines the target matrix
  61701. */
  61702. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  61703. /**
  61704. * 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"
  61705. * This function works in left handed mode
  61706. * @param eye defines the final position of the entity
  61707. * @param target defines where the entity should look at
  61708. * @param up defines the up vector for the entity
  61709. * @returns the new matrix
  61710. */
  61711. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  61712. /**
  61713. * 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".
  61714. * This function works in left handed mode
  61715. * @param eye defines the final position of the entity
  61716. * @param target defines where the entity should look at
  61717. * @param up defines the up vector for the entity
  61718. * @param result defines the target matrix
  61719. */
  61720. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  61721. /**
  61722. * 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"
  61723. * This function works in right handed mode
  61724. * @param eye defines the final position of the entity
  61725. * @param target defines where the entity should look at
  61726. * @param up defines the up vector for the entity
  61727. * @returns the new matrix
  61728. */
  61729. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  61730. /**
  61731. * 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".
  61732. * This function works in right handed mode
  61733. * @param eye defines the final position of the entity
  61734. * @param target defines where the entity should look at
  61735. * @param up defines the up vector for the entity
  61736. * @param result defines the target matrix
  61737. */
  61738. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  61739. /**
  61740. * Create a left-handed orthographic projection matrix
  61741. * @param width defines the viewport width
  61742. * @param height defines the viewport height
  61743. * @param znear defines the near clip plane
  61744. * @param zfar defines the far clip plane
  61745. * @returns a new matrix as a left-handed orthographic projection matrix
  61746. */
  61747. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61748. /**
  61749. * Store a left-handed orthographic projection to a given matrix
  61750. * @param width defines the viewport width
  61751. * @param height defines the viewport height
  61752. * @param znear defines the near clip plane
  61753. * @param zfar defines the far clip plane
  61754. * @param result defines the target matrix
  61755. */
  61756. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  61757. /**
  61758. * Create a left-handed orthographic projection matrix
  61759. * @param left defines the viewport left coordinate
  61760. * @param right defines the viewport right coordinate
  61761. * @param bottom defines the viewport bottom coordinate
  61762. * @param top defines the viewport top coordinate
  61763. * @param znear defines the near clip plane
  61764. * @param zfar defines the far clip plane
  61765. * @returns a new matrix as a left-handed orthographic projection matrix
  61766. */
  61767. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61768. /**
  61769. * Stores a left-handed orthographic projection into a given matrix
  61770. * @param left defines the viewport left coordinate
  61771. * @param right defines the viewport right coordinate
  61772. * @param bottom defines the viewport bottom coordinate
  61773. * @param top defines the viewport top coordinate
  61774. * @param znear defines the near clip plane
  61775. * @param zfar defines the far clip plane
  61776. * @param result defines the target matrix
  61777. */
  61778. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61779. /**
  61780. * Creates a right-handed orthographic projection matrix
  61781. * @param left defines the viewport left coordinate
  61782. * @param right defines the viewport right coordinate
  61783. * @param bottom defines the viewport bottom coordinate
  61784. * @param top defines the viewport top coordinate
  61785. * @param znear defines the near clip plane
  61786. * @param zfar defines the far clip plane
  61787. * @returns a new matrix as a right-handed orthographic projection matrix
  61788. */
  61789. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  61790. /**
  61791. * Stores a right-handed orthographic projection into a given matrix
  61792. * @param left defines the viewport left coordinate
  61793. * @param right defines the viewport right coordinate
  61794. * @param bottom defines the viewport bottom coordinate
  61795. * @param top defines the viewport top coordinate
  61796. * @param znear defines the near clip plane
  61797. * @param zfar defines the far clip plane
  61798. * @param result defines the target matrix
  61799. */
  61800. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  61801. /**
  61802. * Creates a left-handed perspective projection matrix
  61803. * @param width defines the viewport width
  61804. * @param height defines the viewport height
  61805. * @param znear defines the near clip plane
  61806. * @param zfar defines the far clip plane
  61807. * @returns a new matrix as a left-handed perspective projection matrix
  61808. */
  61809. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  61810. /**
  61811. * Creates a left-handed perspective projection matrix
  61812. * @param fov defines the horizontal field of view
  61813. * @param aspect defines the aspect ratio
  61814. * @param znear defines the near clip plane
  61815. * @param zfar defines the far clip plane
  61816. * @returns a new matrix as a left-handed perspective projection matrix
  61817. */
  61818. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61819. /**
  61820. * Stores a left-handed perspective projection into a given matrix
  61821. * @param fov defines the horizontal field of view
  61822. * @param aspect defines the aspect ratio
  61823. * @param znear defines the near clip plane
  61824. * @param zfar defines the far clip plane
  61825. * @param result defines the target matrix
  61826. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61827. */
  61828. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61829. /**
  61830. * Creates a right-handed perspective projection matrix
  61831. * @param fov defines the horizontal field of view
  61832. * @param aspect defines the aspect ratio
  61833. * @param znear defines the near clip plane
  61834. * @param zfar defines the far clip plane
  61835. * @returns a new matrix as a right-handed perspective projection matrix
  61836. */
  61837. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  61838. /**
  61839. * Stores a right-handed perspective projection into a given matrix
  61840. * @param fov defines the horizontal field of view
  61841. * @param aspect defines the aspect ratio
  61842. * @param znear defines the near clip plane
  61843. * @param zfar defines the far clip plane
  61844. * @param result defines the target matrix
  61845. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  61846. */
  61847. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  61848. /**
  61849. * Stores a perspective projection for WebVR info a given matrix
  61850. * @param fov defines the field of view
  61851. * @param znear defines the near clip plane
  61852. * @param zfar defines the far clip plane
  61853. * @param result defines the target matrix
  61854. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  61855. */
  61856. static PerspectiveFovWebVRToRef(fov: {
  61857. upDegrees: number;
  61858. downDegrees: number;
  61859. leftDegrees: number;
  61860. rightDegrees: number;
  61861. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  61862. /**
  61863. * Computes a complete transformation matrix
  61864. * @param viewport defines the viewport to use
  61865. * @param world defines the world matrix
  61866. * @param view defines the view matrix
  61867. * @param projection defines the projection matrix
  61868. * @param zmin defines the near clip plane
  61869. * @param zmax defines the far clip plane
  61870. * @returns the transformation matrix
  61871. */
  61872. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  61873. /**
  61874. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  61875. * @param matrix defines the matrix to use
  61876. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  61877. */
  61878. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  61879. /**
  61880. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  61881. * @param matrix defines the matrix to use
  61882. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  61883. */
  61884. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  61885. /**
  61886. * Compute the transpose of a given matrix
  61887. * @param matrix defines the matrix to transpose
  61888. * @returns the new matrix
  61889. */
  61890. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  61891. /**
  61892. * Compute the transpose of a matrix and store it in a target matrix
  61893. * @param matrix defines the matrix to transpose
  61894. * @param result defines the target matrix
  61895. */
  61896. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  61897. /**
  61898. * Computes a reflection matrix from a plane
  61899. * @param plane defines the reflection plane
  61900. * @returns a new matrix
  61901. */
  61902. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  61903. /**
  61904. * Computes a reflection matrix from a plane
  61905. * @param plane defines the reflection plane
  61906. * @param result defines the target matrix
  61907. */
  61908. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  61909. /**
  61910. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  61911. * @param xaxis defines the value of the 1st axis
  61912. * @param yaxis defines the value of the 2nd axis
  61913. * @param zaxis defines the value of the 3rd axis
  61914. * @param result defines the target matrix
  61915. */
  61916. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  61917. /**
  61918. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  61919. * @param quat defines the quaternion to use
  61920. * @param result defines the target matrix
  61921. */
  61922. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  61923. }
  61924. /**
  61925. * Represens a plane by the equation ax + by + cz + d = 0
  61926. */
  61927. export class Plane {
  61928. /**
  61929. * Normal of the plane (a,b,c)
  61930. */
  61931. normal: Vector3;
  61932. /**
  61933. * d component of the plane
  61934. */
  61935. d: number;
  61936. /**
  61937. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  61938. * @param a a component of the plane
  61939. * @param b b component of the plane
  61940. * @param c c component of the plane
  61941. * @param d d component of the plane
  61942. */
  61943. constructor(a: number, b: number, c: number, d: number);
  61944. /**
  61945. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  61946. */
  61947. asArray(): number[];
  61948. /**
  61949. * @returns a new plane copied from the current Plane.
  61950. */
  61951. clone(): Plane;
  61952. /**
  61953. * @returns the string "Plane".
  61954. */
  61955. getClassName(): string;
  61956. /**
  61957. * @returns the Plane hash code.
  61958. */
  61959. getHashCode(): number;
  61960. /**
  61961. * Normalize the current Plane in place.
  61962. * @returns the updated Plane.
  61963. */
  61964. normalize(): Plane;
  61965. /**
  61966. * Applies a transformation the plane and returns the result
  61967. * @param transformation the transformation matrix to be applied to the plane
  61968. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  61969. */
  61970. transform(transformation: DeepImmutable<Matrix>): Plane;
  61971. /**
  61972. * Calcualtte the dot product between the point and the plane normal
  61973. * @param point point to calculate the dot product with
  61974. * @returns the dot product (float) of the point coordinates and the plane normal.
  61975. */
  61976. dotCoordinate(point: DeepImmutable<Vector3>): number;
  61977. /**
  61978. * Updates the current Plane from the plane defined by the three given points.
  61979. * @param point1 one of the points used to contruct the plane
  61980. * @param point2 one of the points used to contruct the plane
  61981. * @param point3 one of the points used to contruct the plane
  61982. * @returns the updated Plane.
  61983. */
  61984. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  61985. /**
  61986. * Checks if the plane is facing a given direction
  61987. * @param direction the direction to check if the plane is facing
  61988. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  61989. * @returns True is the vector "direction" is the same side than the plane normal.
  61990. */
  61991. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  61992. /**
  61993. * Calculates the distance to a point
  61994. * @param point point to calculate distance to
  61995. * @returns the signed distance (float) from the given point to the Plane.
  61996. */
  61997. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  61998. /**
  61999. * Creates a plane from an array
  62000. * @param array the array to create a plane from
  62001. * @returns a new Plane from the given array.
  62002. */
  62003. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  62004. /**
  62005. * Creates a plane from three points
  62006. * @param point1 point used to create the plane
  62007. * @param point2 point used to create the plane
  62008. * @param point3 point used to create the plane
  62009. * @returns a new Plane defined by the three given points.
  62010. */
  62011. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  62012. /**
  62013. * Creates a plane from an origin point and a normal
  62014. * @param origin origin of the plane to be constructed
  62015. * @param normal normal of the plane to be constructed
  62016. * @returns a new Plane the normal vector to this plane at the given origin point.
  62017. * Note : the vector "normal" is updated because normalized.
  62018. */
  62019. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  62020. /**
  62021. * Calculates the distance from a plane and a point
  62022. * @param origin origin of the plane to be constructed
  62023. * @param normal normal of the plane to be constructed
  62024. * @param point point to calculate distance to
  62025. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  62026. */
  62027. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  62028. }
  62029. /**
  62030. * Class used to represent a viewport on screen
  62031. */
  62032. export class Viewport {
  62033. /** viewport left coordinate */
  62034. x: number;
  62035. /** viewport top coordinate */
  62036. y: number;
  62037. /**viewport width */
  62038. width: number;
  62039. /** viewport height */
  62040. height: number;
  62041. /**
  62042. * Creates a Viewport object located at (x, y) and sized (width, height)
  62043. * @param x defines viewport left coordinate
  62044. * @param y defines viewport top coordinate
  62045. * @param width defines the viewport width
  62046. * @param height defines the viewport height
  62047. */
  62048. constructor(
  62049. /** viewport left coordinate */
  62050. x: number,
  62051. /** viewport top coordinate */
  62052. y: number,
  62053. /**viewport width */
  62054. width: number,
  62055. /** viewport height */
  62056. height: number);
  62057. /**
  62058. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  62059. * @param renderWidth defines the rendering width
  62060. * @param renderHeight defines the rendering height
  62061. * @returns a new Viewport
  62062. */
  62063. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  62064. /**
  62065. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  62066. * @param renderWidth defines the rendering width
  62067. * @param renderHeight defines the rendering height
  62068. * @param ref defines the target viewport
  62069. * @returns the current viewport
  62070. */
  62071. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  62072. /**
  62073. * Returns a new Viewport copied from the current one
  62074. * @returns a new Viewport
  62075. */
  62076. clone(): Viewport;
  62077. }
  62078. /**
  62079. * Reprasents a camera frustum
  62080. */
  62081. export class Frustum {
  62082. /**
  62083. * Gets the planes representing the frustum
  62084. * @param transform matrix to be applied to the returned planes
  62085. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  62086. */
  62087. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  62088. /**
  62089. * Gets the near frustum plane transformed by the transform matrix
  62090. * @param transform transformation matrix to be applied to the resulting frustum plane
  62091. * @param frustumPlane the resuling frustum plane
  62092. */
  62093. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62094. /**
  62095. * Gets the far frustum plane transformed by the transform matrix
  62096. * @param transform transformation matrix to be applied to the resulting frustum plane
  62097. * @param frustumPlane the resuling frustum plane
  62098. */
  62099. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62100. /**
  62101. * Gets the left frustum plane transformed by the transform matrix
  62102. * @param transform transformation matrix to be applied to the resulting frustum plane
  62103. * @param frustumPlane the resuling frustum plane
  62104. */
  62105. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62106. /**
  62107. * Gets the right frustum plane transformed by the transform matrix
  62108. * @param transform transformation matrix to be applied to the resulting frustum plane
  62109. * @param frustumPlane the resuling frustum plane
  62110. */
  62111. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62112. /**
  62113. * Gets the top frustum plane transformed by the transform matrix
  62114. * @param transform transformation matrix to be applied to the resulting frustum plane
  62115. * @param frustumPlane the resuling frustum plane
  62116. */
  62117. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62118. /**
  62119. * Gets the bottom frustum plane transformed by the transform matrix
  62120. * @param transform transformation matrix to be applied to the resulting frustum plane
  62121. * @param frustumPlane the resuling frustum plane
  62122. */
  62123. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  62124. /**
  62125. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  62126. * @param transform transformation matrix to be applied to the resulting frustum planes
  62127. * @param frustumPlanes the resuling frustum planes
  62128. */
  62129. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  62130. }
  62131. /** Defines supported spaces */
  62132. export enum Space {
  62133. /** Local (object) space */
  62134. LOCAL = 0,
  62135. /** World space */
  62136. WORLD = 1,
  62137. /** Bone space */
  62138. BONE = 2
  62139. }
  62140. /** Defines the 3 main axes */
  62141. export class Axis {
  62142. /** X axis */
  62143. static X: Vector3;
  62144. /** Y axis */
  62145. static Y: Vector3;
  62146. /** Z axis */
  62147. static Z: Vector3;
  62148. }
  62149. /** Class used to represent a Bezier curve */
  62150. export class BezierCurve {
  62151. /**
  62152. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  62153. * @param t defines the time
  62154. * @param x1 defines the left coordinate on X axis
  62155. * @param y1 defines the left coordinate on Y axis
  62156. * @param x2 defines the right coordinate on X axis
  62157. * @param y2 defines the right coordinate on Y axis
  62158. * @returns the interpolated value
  62159. */
  62160. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  62161. }
  62162. /**
  62163. * Defines potential orientation for back face culling
  62164. */
  62165. export enum Orientation {
  62166. /**
  62167. * Clockwise
  62168. */
  62169. CW = 0,
  62170. /** Counter clockwise */
  62171. CCW = 1
  62172. }
  62173. /**
  62174. * Defines angle representation
  62175. */
  62176. export class Angle {
  62177. private _radians;
  62178. /**
  62179. * Creates an Angle object of "radians" radians (float).
  62180. * @param radians the angle in radians
  62181. */
  62182. constructor(radians: number);
  62183. /**
  62184. * Get value in degrees
  62185. * @returns the Angle value in degrees (float)
  62186. */
  62187. degrees(): number;
  62188. /**
  62189. * Get value in radians
  62190. * @returns the Angle value in radians (float)
  62191. */
  62192. radians(): number;
  62193. /**
  62194. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  62195. * @param a defines first vector
  62196. * @param b defines second vector
  62197. * @returns a new Angle
  62198. */
  62199. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  62200. /**
  62201. * Gets a new Angle object from the given float in radians
  62202. * @param radians defines the angle value in radians
  62203. * @returns a new Angle
  62204. */
  62205. static FromRadians(radians: number): Angle;
  62206. /**
  62207. * Gets a new Angle object from the given float in degrees
  62208. * @param degrees defines the angle value in degrees
  62209. * @returns a new Angle
  62210. */
  62211. static FromDegrees(degrees: number): Angle;
  62212. }
  62213. /**
  62214. * This represents an arc in a 2d space.
  62215. */
  62216. export class Arc2 {
  62217. /** Defines the start point of the arc */
  62218. startPoint: Vector2;
  62219. /** Defines the mid point of the arc */
  62220. midPoint: Vector2;
  62221. /** Defines the end point of the arc */
  62222. endPoint: Vector2;
  62223. /**
  62224. * Defines the center point of the arc.
  62225. */
  62226. centerPoint: Vector2;
  62227. /**
  62228. * Defines the radius of the arc.
  62229. */
  62230. radius: number;
  62231. /**
  62232. * Defines the angle of the arc (from mid point to end point).
  62233. */
  62234. angle: Angle;
  62235. /**
  62236. * Defines the start angle of the arc (from start point to middle point).
  62237. */
  62238. startAngle: Angle;
  62239. /**
  62240. * Defines the orientation of the arc (clock wise/counter clock wise).
  62241. */
  62242. orientation: Orientation;
  62243. /**
  62244. * Creates an Arc object from the three given points : start, middle and end.
  62245. * @param startPoint Defines the start point of the arc
  62246. * @param midPoint Defines the midlle point of the arc
  62247. * @param endPoint Defines the end point of the arc
  62248. */
  62249. constructor(
  62250. /** Defines the start point of the arc */
  62251. startPoint: Vector2,
  62252. /** Defines the mid point of the arc */
  62253. midPoint: Vector2,
  62254. /** Defines the end point of the arc */
  62255. endPoint: Vector2);
  62256. }
  62257. /**
  62258. * Represents a 2D path made up of multiple 2D points
  62259. */
  62260. export class Path2 {
  62261. private _points;
  62262. private _length;
  62263. /**
  62264. * If the path start and end point are the same
  62265. */
  62266. closed: boolean;
  62267. /**
  62268. * Creates a Path2 object from the starting 2D coordinates x and y.
  62269. * @param x the starting points x value
  62270. * @param y the starting points y value
  62271. */
  62272. constructor(x: number, y: number);
  62273. /**
  62274. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  62275. * @param x the added points x value
  62276. * @param y the added points y value
  62277. * @returns the updated Path2.
  62278. */
  62279. addLineTo(x: number, y: number): Path2;
  62280. /**
  62281. * 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.
  62282. * @param midX middle point x value
  62283. * @param midY middle point y value
  62284. * @param endX end point x value
  62285. * @param endY end point y value
  62286. * @param numberOfSegments (default: 36)
  62287. * @returns the updated Path2.
  62288. */
  62289. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  62290. /**
  62291. * Closes the Path2.
  62292. * @returns the Path2.
  62293. */
  62294. close(): Path2;
  62295. /**
  62296. * Gets the sum of the distance between each sequential point in the path
  62297. * @returns the Path2 total length (float).
  62298. */
  62299. length(): number;
  62300. /**
  62301. * Gets the points which construct the path
  62302. * @returns the Path2 internal array of points.
  62303. */
  62304. getPoints(): Vector2[];
  62305. /**
  62306. * Retreives the point at the distance aways from the starting point
  62307. * @param normalizedLengthPosition the length along the path to retreive the point from
  62308. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  62309. */
  62310. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  62311. /**
  62312. * Creates a new path starting from an x and y position
  62313. * @param x starting x value
  62314. * @param y starting y value
  62315. * @returns a new Path2 starting at the coordinates (x, y).
  62316. */
  62317. static StartingAt(x: number, y: number): Path2;
  62318. }
  62319. /**
  62320. * Represents a 3D path made up of multiple 3D points
  62321. */
  62322. export class Path3D {
  62323. /**
  62324. * an array of Vector3, the curve axis of the Path3D
  62325. */
  62326. path: Vector3[];
  62327. private _curve;
  62328. private _distances;
  62329. private _tangents;
  62330. private _normals;
  62331. private _binormals;
  62332. private _raw;
  62333. /**
  62334. * new Path3D(path, normal, raw)
  62335. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  62336. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  62337. * @param path an array of Vector3, the curve axis of the Path3D
  62338. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  62339. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  62340. */
  62341. constructor(
  62342. /**
  62343. * an array of Vector3, the curve axis of the Path3D
  62344. */
  62345. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  62346. /**
  62347. * Returns the Path3D array of successive Vector3 designing its curve.
  62348. * @returns the Path3D array of successive Vector3 designing its curve.
  62349. */
  62350. getCurve(): Vector3[];
  62351. /**
  62352. * Returns an array populated with tangent vectors on each Path3D curve point.
  62353. * @returns an array populated with tangent vectors on each Path3D curve point.
  62354. */
  62355. getTangents(): Vector3[];
  62356. /**
  62357. * Returns an array populated with normal vectors on each Path3D curve point.
  62358. * @returns an array populated with normal vectors on each Path3D curve point.
  62359. */
  62360. getNormals(): Vector3[];
  62361. /**
  62362. * Returns an array populated with binormal vectors on each Path3D curve point.
  62363. * @returns an array populated with binormal vectors on each Path3D curve point.
  62364. */
  62365. getBinormals(): Vector3[];
  62366. /**
  62367. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  62368. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  62369. */
  62370. getDistances(): number[];
  62371. /**
  62372. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  62373. * @param path path which all values are copied into the curves points
  62374. * @param firstNormal which should be projected onto the curve
  62375. * @returns the same object updated.
  62376. */
  62377. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  62378. private _compute;
  62379. private _getFirstNonNullVector;
  62380. private _getLastNonNullVector;
  62381. private _normalVector;
  62382. }
  62383. /**
  62384. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  62385. * A Curve3 is designed from a series of successive Vector3.
  62386. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  62387. */
  62388. export class Curve3 {
  62389. private _points;
  62390. private _length;
  62391. /**
  62392. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  62393. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  62394. * @param v1 (Vector3) the control point
  62395. * @param v2 (Vector3) the end point of the Quadratic Bezier
  62396. * @param nbPoints (integer) the wanted number of points in the curve
  62397. * @returns the created Curve3
  62398. */
  62399. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  62400. /**
  62401. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  62402. * @param v0 (Vector3) the origin point of the Cubic Bezier
  62403. * @param v1 (Vector3) the first control point
  62404. * @param v2 (Vector3) the second control point
  62405. * @param v3 (Vector3) the end point of the Cubic Bezier
  62406. * @param nbPoints (integer) the wanted number of points in the curve
  62407. * @returns the created Curve3
  62408. */
  62409. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  62410. /**
  62411. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  62412. * @param p1 (Vector3) the origin point of the Hermite Spline
  62413. * @param t1 (Vector3) the tangent vector at the origin point
  62414. * @param p2 (Vector3) the end point of the Hermite Spline
  62415. * @param t2 (Vector3) the tangent vector at the end point
  62416. * @param nbPoints (integer) the wanted number of points in the curve
  62417. * @returns the created Curve3
  62418. */
  62419. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  62420. /**
  62421. * Returns a Curve3 object along a CatmullRom Spline curve :
  62422. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  62423. * @param nbPoints (integer) the wanted number of points between each curve control points
  62424. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  62425. * @returns the created Curve3
  62426. */
  62427. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  62428. /**
  62429. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  62430. * A Curve3 is designed from a series of successive Vector3.
  62431. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  62432. * @param points points which make up the curve
  62433. */
  62434. constructor(points: Vector3[]);
  62435. /**
  62436. * @returns the Curve3 stored array of successive Vector3
  62437. */
  62438. getPoints(): Vector3[];
  62439. /**
  62440. * @returns the computed length (float) of the curve.
  62441. */
  62442. length(): number;
  62443. /**
  62444. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  62445. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  62446. * curveA and curveB keep unchanged.
  62447. * @param curve the curve to continue from this curve
  62448. * @returns the newly constructed curve
  62449. */
  62450. continue(curve: DeepImmutable<Curve3>): Curve3;
  62451. private _computeLength;
  62452. }
  62453. /**
  62454. * Contains position and normal vectors for a vertex
  62455. */
  62456. export class PositionNormalVertex {
  62457. /** the position of the vertex (defaut: 0,0,0) */
  62458. position: Vector3;
  62459. /** the normal of the vertex (defaut: 0,1,0) */
  62460. normal: Vector3;
  62461. /**
  62462. * Creates a PositionNormalVertex
  62463. * @param position the position of the vertex (defaut: 0,0,0)
  62464. * @param normal the normal of the vertex (defaut: 0,1,0)
  62465. */
  62466. constructor(
  62467. /** the position of the vertex (defaut: 0,0,0) */
  62468. position?: Vector3,
  62469. /** the normal of the vertex (defaut: 0,1,0) */
  62470. normal?: Vector3);
  62471. /**
  62472. * Clones the PositionNormalVertex
  62473. * @returns the cloned PositionNormalVertex
  62474. */
  62475. clone(): PositionNormalVertex;
  62476. }
  62477. /**
  62478. * Contains position, normal and uv vectors for a vertex
  62479. */
  62480. export class PositionNormalTextureVertex {
  62481. /** the position of the vertex (defaut: 0,0,0) */
  62482. position: Vector3;
  62483. /** the normal of the vertex (defaut: 0,1,0) */
  62484. normal: Vector3;
  62485. /** the uv of the vertex (default: 0,0) */
  62486. uv: Vector2;
  62487. /**
  62488. * Creates a PositionNormalTextureVertex
  62489. * @param position the position of the vertex (defaut: 0,0,0)
  62490. * @param normal the normal of the vertex (defaut: 0,1,0)
  62491. * @param uv the uv of the vertex (default: 0,0)
  62492. */
  62493. constructor(
  62494. /** the position of the vertex (defaut: 0,0,0) */
  62495. position?: Vector3,
  62496. /** the normal of the vertex (defaut: 0,1,0) */
  62497. normal?: Vector3,
  62498. /** the uv of the vertex (default: 0,0) */
  62499. uv?: Vector2);
  62500. /**
  62501. * Clones the PositionNormalTextureVertex
  62502. * @returns the cloned PositionNormalTextureVertex
  62503. */
  62504. clone(): PositionNormalTextureVertex;
  62505. }
  62506. /**
  62507. * @hidden
  62508. */
  62509. export class Tmp {
  62510. static Color3: Color3[];
  62511. static Color4: Color4[];
  62512. static Vector2: Vector2[];
  62513. static Vector3: Vector3[];
  62514. static Vector4: Vector4[];
  62515. static Quaternion: Quaternion[];
  62516. static Matrix: Matrix[];
  62517. }
  62518. }
  62519. declare module BABYLON {
  62520. /**
  62521. * Class used to enable access to offline support
  62522. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62523. */
  62524. export interface IOfflineProvider {
  62525. /**
  62526. * Gets a boolean indicating if scene must be saved in the database
  62527. */
  62528. enableSceneOffline: boolean;
  62529. /**
  62530. * Gets a boolean indicating if textures must be saved in the database
  62531. */
  62532. enableTexturesOffline: boolean;
  62533. /**
  62534. * Open the offline support and make it available
  62535. * @param successCallback defines the callback to call on success
  62536. * @param errorCallback defines the callback to call on error
  62537. */
  62538. open(successCallback: () => void, errorCallback: () => void): void;
  62539. /**
  62540. * Loads an image from the offline support
  62541. * @param url defines the url to load from
  62542. * @param image defines the target DOM image
  62543. */
  62544. loadImage(url: string, image: HTMLImageElement): void;
  62545. /**
  62546. * Loads a file from offline support
  62547. * @param url defines the URL to load from
  62548. * @param sceneLoaded defines a callback to call on success
  62549. * @param progressCallBack defines a callback to call when progress changed
  62550. * @param errorCallback defines a callback to call on error
  62551. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62552. */
  62553. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62554. }
  62555. }
  62556. declare module BABYLON {
  62557. /**
  62558. * A class serves as a medium between the observable and its observers
  62559. */
  62560. export class EventState {
  62561. /**
  62562. * Create a new EventState
  62563. * @param mask defines the mask associated with this state
  62564. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  62565. * @param target defines the original target of the state
  62566. * @param currentTarget defines the current target of the state
  62567. */
  62568. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62569. /**
  62570. * Initialize the current event state
  62571. * @param mask defines the mask associated with this state
  62572. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  62573. * @param target defines the original target of the state
  62574. * @param currentTarget defines the current target of the state
  62575. * @returns the current event state
  62576. */
  62577. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  62578. /**
  62579. * An Observer can set this property to true to prevent subsequent observers of being notified
  62580. */
  62581. skipNextObservers: boolean;
  62582. /**
  62583. * Get the mask value that were used to trigger the event corresponding to this EventState object
  62584. */
  62585. mask: number;
  62586. /**
  62587. * The object that originally notified the event
  62588. */
  62589. target?: any;
  62590. /**
  62591. * The current object in the bubbling phase
  62592. */
  62593. currentTarget?: any;
  62594. /**
  62595. * This will be populated with the return value of the last function that was executed.
  62596. * If it is the first function in the callback chain it will be the event data.
  62597. */
  62598. lastReturnValue?: any;
  62599. }
  62600. /**
  62601. * Represent an Observer registered to a given Observable object.
  62602. */
  62603. export class Observer<T> {
  62604. /**
  62605. * Defines the callback to call when the observer is notified
  62606. */
  62607. callback: (eventData: T, eventState: EventState) => void;
  62608. /**
  62609. * Defines the mask of the observer (used to filter notifications)
  62610. */
  62611. mask: number;
  62612. /**
  62613. * Defines the current scope used to restore the JS context
  62614. */
  62615. scope: any;
  62616. /** @hidden */
  62617. _willBeUnregistered: boolean;
  62618. /**
  62619. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  62620. */
  62621. unregisterOnNextCall: boolean;
  62622. /**
  62623. * Creates a new observer
  62624. * @param callback defines the callback to call when the observer is notified
  62625. * @param mask defines the mask of the observer (used to filter notifications)
  62626. * @param scope defines the current scope used to restore the JS context
  62627. */
  62628. constructor(
  62629. /**
  62630. * Defines the callback to call when the observer is notified
  62631. */
  62632. callback: (eventData: T, eventState: EventState) => void,
  62633. /**
  62634. * Defines the mask of the observer (used to filter notifications)
  62635. */
  62636. mask: number,
  62637. /**
  62638. * Defines the current scope used to restore the JS context
  62639. */
  62640. scope?: any);
  62641. }
  62642. /**
  62643. * Represent a list of observers registered to multiple Observables object.
  62644. */
  62645. export class MultiObserver<T> {
  62646. private _observers;
  62647. private _observables;
  62648. /**
  62649. * Release associated resources
  62650. */
  62651. dispose(): void;
  62652. /**
  62653. * Raise a callback when one of the observable will notify
  62654. * @param observables defines a list of observables to watch
  62655. * @param callback defines the callback to call on notification
  62656. * @param mask defines the mask used to filter notifications
  62657. * @param scope defines the current scope used to restore the JS context
  62658. * @returns the new MultiObserver
  62659. */
  62660. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  62661. }
  62662. /**
  62663. * The Observable class is a simple implementation of the Observable pattern.
  62664. *
  62665. * 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.
  62666. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  62667. * 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).
  62668. * 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.
  62669. */
  62670. export class Observable<T> {
  62671. private _observers;
  62672. private _eventState;
  62673. private _onObserverAdded;
  62674. /**
  62675. * Creates a new observable
  62676. * @param onObserverAdded defines a callback to call when a new observer is added
  62677. */
  62678. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  62679. /**
  62680. * Create a new Observer with the specified callback
  62681. * @param callback the callback that will be executed for that Observer
  62682. * @param mask the mask used to filter observers
  62683. * @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.
  62684. * @param scope optional scope for the callback to be called from
  62685. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  62686. * @returns the new observer created for the callback
  62687. */
  62688. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  62689. /**
  62690. * Create a new Observer with the specified callback and unregisters after the next notification
  62691. * @param callback the callback that will be executed for that Observer
  62692. * @returns the new observer created for the callback
  62693. */
  62694. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  62695. /**
  62696. * Remove an Observer from the Observable object
  62697. * @param observer the instance of the Observer to remove
  62698. * @returns false if it doesn't belong to this Observable
  62699. */
  62700. remove(observer: Nullable<Observer<T>>): boolean;
  62701. /**
  62702. * Remove a callback from the Observable object
  62703. * @param callback the callback to remove
  62704. * @param scope optional scope. If used only the callbacks with this scope will be removed
  62705. * @returns false if it doesn't belong to this Observable
  62706. */
  62707. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  62708. private _deferUnregister;
  62709. private _remove;
  62710. /**
  62711. * Moves the observable to the top of the observer list making it get called first when notified
  62712. * @param observer the observer to move
  62713. */
  62714. makeObserverTopPriority(observer: Observer<T>): void;
  62715. /**
  62716. * Moves the observable to the bottom of the observer list making it get called last when notified
  62717. * @param observer the observer to move
  62718. */
  62719. makeObserverBottomPriority(observer: Observer<T>): void;
  62720. /**
  62721. * Notify all Observers by calling their respective callback with the given data
  62722. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  62723. * @param eventData defines the data to send to all observers
  62724. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  62725. * @param target defines the original target of the state
  62726. * @param currentTarget defines the current target of the state
  62727. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  62728. */
  62729. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  62730. /**
  62731. * Calling this will execute each callback, expecting it to be a promise or return a value.
  62732. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  62733. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  62734. * and it is crucial that all callbacks will be executed.
  62735. * The order of the callbacks is kept, callbacks are not executed parallel.
  62736. *
  62737. * @param eventData The data to be sent to each callback
  62738. * @param mask is used to filter observers defaults to -1
  62739. * @param target defines the callback target (see EventState)
  62740. * @param currentTarget defines he current object in the bubbling phase
  62741. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  62742. */
  62743. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  62744. /**
  62745. * Notify a specific observer
  62746. * @param observer defines the observer to notify
  62747. * @param eventData defines the data to be sent to each callback
  62748. * @param mask is used to filter observers defaults to -1
  62749. */
  62750. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  62751. /**
  62752. * Gets a boolean indicating if the observable has at least one observer
  62753. * @returns true is the Observable has at least one Observer registered
  62754. */
  62755. hasObservers(): boolean;
  62756. /**
  62757. * Clear the list of observers
  62758. */
  62759. clear(): void;
  62760. /**
  62761. * Clone the current observable
  62762. * @returns a new observable
  62763. */
  62764. clone(): Observable<T>;
  62765. /**
  62766. * Does this observable handles observer registered with a given mask
  62767. * @param mask defines the mask to be tested
  62768. * @return whether or not one observer registered with the given mask is handeled
  62769. **/
  62770. hasSpecificMask(mask?: number): boolean;
  62771. }
  62772. }
  62773. declare module BABYLON {
  62774. /**
  62775. * Class used to help managing file picking and drag'n'drop
  62776. * File Storage
  62777. */
  62778. export class FilesInputStore {
  62779. /**
  62780. * List of files ready to be loaded
  62781. */
  62782. static FilesToLoad: {
  62783. [key: string]: File;
  62784. };
  62785. }
  62786. }
  62787. declare module BABYLON {
  62788. /** Defines the cross module used constants to avoid circular dependncies */
  62789. export class Constants {
  62790. /** Defines that alpha blending is disabled */
  62791. static readonly ALPHA_DISABLE: number;
  62792. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  62793. static readonly ALPHA_ADD: number;
  62794. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  62795. static readonly ALPHA_COMBINE: number;
  62796. /** Defines that alpha blending to DEST - SRC * DEST */
  62797. static readonly ALPHA_SUBTRACT: number;
  62798. /** Defines that alpha blending to SRC * DEST */
  62799. static readonly ALPHA_MULTIPLY: number;
  62800. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  62801. static readonly ALPHA_MAXIMIZED: number;
  62802. /** Defines that alpha blending to SRC + DEST */
  62803. static readonly ALPHA_ONEONE: number;
  62804. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  62805. static readonly ALPHA_PREMULTIPLIED: number;
  62806. /**
  62807. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  62808. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  62809. */
  62810. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  62811. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  62812. static readonly ALPHA_INTERPOLATE: number;
  62813. /**
  62814. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  62815. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  62816. */
  62817. static readonly ALPHA_SCREENMODE: number;
  62818. /** Defines that the ressource is not delayed*/
  62819. static readonly DELAYLOADSTATE_NONE: number;
  62820. /** Defines that the ressource was successfully delay loaded */
  62821. static readonly DELAYLOADSTATE_LOADED: number;
  62822. /** Defines that the ressource is currently delay loading */
  62823. static readonly DELAYLOADSTATE_LOADING: number;
  62824. /** Defines that the ressource is delayed and has not started loading */
  62825. static readonly DELAYLOADSTATE_NOTLOADED: number;
  62826. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  62827. static readonly NEVER: number;
  62828. /** 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 */
  62829. static readonly ALWAYS: number;
  62830. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  62831. static readonly LESS: number;
  62832. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  62833. static readonly EQUAL: number;
  62834. /** 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 */
  62835. static readonly LEQUAL: number;
  62836. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  62837. static readonly GREATER: number;
  62838. /** 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 */
  62839. static readonly GEQUAL: number;
  62840. /** 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 */
  62841. static readonly NOTEQUAL: number;
  62842. /** Passed to stencilOperation to specify that stencil value must be kept */
  62843. static readonly KEEP: number;
  62844. /** Passed to stencilOperation to specify that stencil value must be replaced */
  62845. static readonly REPLACE: number;
  62846. /** Passed to stencilOperation to specify that stencil value must be incremented */
  62847. static readonly INCR: number;
  62848. /** Passed to stencilOperation to specify that stencil value must be decremented */
  62849. static readonly DECR: number;
  62850. /** Passed to stencilOperation to specify that stencil value must be inverted */
  62851. static readonly INVERT: number;
  62852. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  62853. static readonly INCR_WRAP: number;
  62854. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  62855. static readonly DECR_WRAP: number;
  62856. /** Texture is not repeating outside of 0..1 UVs */
  62857. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  62858. /** Texture is repeating outside of 0..1 UVs */
  62859. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  62860. /** Texture is repeating and mirrored */
  62861. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  62862. /** ALPHA */
  62863. static readonly TEXTUREFORMAT_ALPHA: number;
  62864. /** LUMINANCE */
  62865. static readonly TEXTUREFORMAT_LUMINANCE: number;
  62866. /** LUMINANCE_ALPHA */
  62867. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  62868. /** RGB */
  62869. static readonly TEXTUREFORMAT_RGB: number;
  62870. /** RGBA */
  62871. static readonly TEXTUREFORMAT_RGBA: number;
  62872. /** RED */
  62873. static readonly TEXTUREFORMAT_RED: number;
  62874. /** RED (2nd reference) */
  62875. static readonly TEXTUREFORMAT_R: number;
  62876. /** RG */
  62877. static readonly TEXTUREFORMAT_RG: number;
  62878. /** RED_INTEGER */
  62879. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  62880. /** RED_INTEGER (2nd reference) */
  62881. static readonly TEXTUREFORMAT_R_INTEGER: number;
  62882. /** RG_INTEGER */
  62883. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  62884. /** RGB_INTEGER */
  62885. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  62886. /** RGBA_INTEGER */
  62887. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  62888. /** UNSIGNED_BYTE */
  62889. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  62890. /** UNSIGNED_BYTE (2nd reference) */
  62891. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  62892. /** FLOAT */
  62893. static readonly TEXTURETYPE_FLOAT: number;
  62894. /** HALF_FLOAT */
  62895. static readonly TEXTURETYPE_HALF_FLOAT: number;
  62896. /** BYTE */
  62897. static readonly TEXTURETYPE_BYTE: number;
  62898. /** SHORT */
  62899. static readonly TEXTURETYPE_SHORT: number;
  62900. /** UNSIGNED_SHORT */
  62901. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  62902. /** INT */
  62903. static readonly TEXTURETYPE_INT: number;
  62904. /** UNSIGNED_INT */
  62905. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  62906. /** UNSIGNED_SHORT_4_4_4_4 */
  62907. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  62908. /** UNSIGNED_SHORT_5_5_5_1 */
  62909. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  62910. /** UNSIGNED_SHORT_5_6_5 */
  62911. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  62912. /** UNSIGNED_INT_2_10_10_10_REV */
  62913. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  62914. /** UNSIGNED_INT_24_8 */
  62915. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  62916. /** UNSIGNED_INT_10F_11F_11F_REV */
  62917. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  62918. /** UNSIGNED_INT_5_9_9_9_REV */
  62919. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  62920. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  62921. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62922. /** nearest is mag = nearest and min = nearest and mip = linear */
  62923. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  62924. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62925. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  62926. /** Trilinear is mag = linear and min = linear and mip = linear */
  62927. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  62928. /** nearest is mag = nearest and min = nearest and mip = linear */
  62929. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  62930. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62931. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  62932. /** Trilinear is mag = linear and min = linear and mip = linear */
  62933. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  62934. /** mag = nearest and min = nearest and mip = nearest */
  62935. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  62936. /** mag = nearest and min = linear and mip = nearest */
  62937. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  62938. /** mag = nearest and min = linear and mip = linear */
  62939. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  62940. /** mag = nearest and min = linear and mip = none */
  62941. static readonly TEXTURE_NEAREST_LINEAR: number;
  62942. /** mag = nearest and min = nearest and mip = none */
  62943. static readonly TEXTURE_NEAREST_NEAREST: number;
  62944. /** mag = linear and min = nearest and mip = nearest */
  62945. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  62946. /** mag = linear and min = nearest and mip = linear */
  62947. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  62948. /** mag = linear and min = linear and mip = none */
  62949. static readonly TEXTURE_LINEAR_LINEAR: number;
  62950. /** mag = linear and min = nearest and mip = none */
  62951. static readonly TEXTURE_LINEAR_NEAREST: number;
  62952. /** Explicit coordinates mode */
  62953. static readonly TEXTURE_EXPLICIT_MODE: number;
  62954. /** Spherical coordinates mode */
  62955. static readonly TEXTURE_SPHERICAL_MODE: number;
  62956. /** Planar coordinates mode */
  62957. static readonly TEXTURE_PLANAR_MODE: number;
  62958. /** Cubic coordinates mode */
  62959. static readonly TEXTURE_CUBIC_MODE: number;
  62960. /** Projection coordinates mode */
  62961. static readonly TEXTURE_PROJECTION_MODE: number;
  62962. /** Skybox coordinates mode */
  62963. static readonly TEXTURE_SKYBOX_MODE: number;
  62964. /** Inverse Cubic coordinates mode */
  62965. static readonly TEXTURE_INVCUBIC_MODE: number;
  62966. /** Equirectangular coordinates mode */
  62967. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  62968. /** Equirectangular Fixed coordinates mode */
  62969. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  62970. /** Equirectangular Fixed Mirrored coordinates mode */
  62971. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  62972. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  62973. static readonly SCALEMODE_FLOOR: number;
  62974. /** Defines that texture rescaling will look for the nearest power of 2 size */
  62975. static readonly SCALEMODE_NEAREST: number;
  62976. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  62977. static readonly SCALEMODE_CEILING: number;
  62978. /**
  62979. * The dirty texture flag value
  62980. */
  62981. static readonly MATERIAL_TextureDirtyFlag: number;
  62982. /**
  62983. * The dirty light flag value
  62984. */
  62985. static readonly MATERIAL_LightDirtyFlag: number;
  62986. /**
  62987. * The dirty fresnel flag value
  62988. */
  62989. static readonly MATERIAL_FresnelDirtyFlag: number;
  62990. /**
  62991. * The dirty attribute flag value
  62992. */
  62993. static readonly MATERIAL_AttributesDirtyFlag: number;
  62994. /**
  62995. * The dirty misc flag value
  62996. */
  62997. static readonly MATERIAL_MiscDirtyFlag: number;
  62998. /**
  62999. * The all dirty flag value
  63000. */
  63001. static readonly MATERIAL_AllDirtyFlag: number;
  63002. /**
  63003. * Returns the triangle fill mode
  63004. */
  63005. static readonly MATERIAL_TriangleFillMode: number;
  63006. /**
  63007. * Returns the wireframe mode
  63008. */
  63009. static readonly MATERIAL_WireFrameFillMode: number;
  63010. /**
  63011. * Returns the point fill mode
  63012. */
  63013. static readonly MATERIAL_PointFillMode: number;
  63014. /**
  63015. * Returns the point list draw mode
  63016. */
  63017. static readonly MATERIAL_PointListDrawMode: number;
  63018. /**
  63019. * Returns the line list draw mode
  63020. */
  63021. static readonly MATERIAL_LineListDrawMode: number;
  63022. /**
  63023. * Returns the line loop draw mode
  63024. */
  63025. static readonly MATERIAL_LineLoopDrawMode: number;
  63026. /**
  63027. * Returns the line strip draw mode
  63028. */
  63029. static readonly MATERIAL_LineStripDrawMode: number;
  63030. /**
  63031. * Returns the triangle strip draw mode
  63032. */
  63033. static readonly MATERIAL_TriangleStripDrawMode: number;
  63034. /**
  63035. * Returns the triangle fan draw mode
  63036. */
  63037. static readonly MATERIAL_TriangleFanDrawMode: number;
  63038. /**
  63039. * Stores the clock-wise side orientation
  63040. */
  63041. static readonly MATERIAL_ClockWiseSideOrientation: number;
  63042. /**
  63043. * Stores the counter clock-wise side orientation
  63044. */
  63045. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  63046. /**
  63047. * Nothing
  63048. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63049. */
  63050. static readonly ACTION_NothingTrigger: number;
  63051. /**
  63052. * On pick
  63053. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63054. */
  63055. static readonly ACTION_OnPickTrigger: number;
  63056. /**
  63057. * On left pick
  63058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63059. */
  63060. static readonly ACTION_OnLeftPickTrigger: number;
  63061. /**
  63062. * On right pick
  63063. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63064. */
  63065. static readonly ACTION_OnRightPickTrigger: number;
  63066. /**
  63067. * On center pick
  63068. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63069. */
  63070. static readonly ACTION_OnCenterPickTrigger: number;
  63071. /**
  63072. * On pick down
  63073. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63074. */
  63075. static readonly ACTION_OnPickDownTrigger: number;
  63076. /**
  63077. * On double pick
  63078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63079. */
  63080. static readonly ACTION_OnDoublePickTrigger: number;
  63081. /**
  63082. * On pick up
  63083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63084. */
  63085. static readonly ACTION_OnPickUpTrigger: number;
  63086. /**
  63087. * On pick out.
  63088. * This trigger will only be raised if you also declared a OnPickDown
  63089. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63090. */
  63091. static readonly ACTION_OnPickOutTrigger: number;
  63092. /**
  63093. * On long press
  63094. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63095. */
  63096. static readonly ACTION_OnLongPressTrigger: number;
  63097. /**
  63098. * On pointer over
  63099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63100. */
  63101. static readonly ACTION_OnPointerOverTrigger: number;
  63102. /**
  63103. * On pointer out
  63104. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63105. */
  63106. static readonly ACTION_OnPointerOutTrigger: number;
  63107. /**
  63108. * On every frame
  63109. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63110. */
  63111. static readonly ACTION_OnEveryFrameTrigger: number;
  63112. /**
  63113. * On intersection enter
  63114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63115. */
  63116. static readonly ACTION_OnIntersectionEnterTrigger: number;
  63117. /**
  63118. * On intersection exit
  63119. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63120. */
  63121. static readonly ACTION_OnIntersectionExitTrigger: number;
  63122. /**
  63123. * On key down
  63124. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63125. */
  63126. static readonly ACTION_OnKeyDownTrigger: number;
  63127. /**
  63128. * On key up
  63129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  63130. */
  63131. static readonly ACTION_OnKeyUpTrigger: number;
  63132. /**
  63133. * Billboard mode will only apply to Y axis
  63134. */
  63135. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  63136. /**
  63137. * Billboard mode will apply to all axes
  63138. */
  63139. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  63140. /**
  63141. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  63142. */
  63143. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  63144. /**
  63145. * Gets or sets base Assets URL
  63146. */
  63147. static readonly PARTICLES_BaseAssetsUrl: string;
  63148. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  63149. * Test order :
  63150. * Is the bounding sphere outside the frustum ?
  63151. * If not, are the bounding box vertices outside the frustum ?
  63152. * It not, then the cullable object is in the frustum.
  63153. */
  63154. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  63155. /** Culling strategy : Bounding Sphere Only.
  63156. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  63157. * It's also less accurate than the standard because some not visible objects can still be selected.
  63158. * Test : is the bounding sphere outside the frustum ?
  63159. * If not, then the cullable object is in the frustum.
  63160. */
  63161. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  63162. /** Culling strategy : Optimistic Inclusion.
  63163. * This in an inclusion test first, then the standard exclusion test.
  63164. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  63165. * 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.
  63166. * Anyway, it's as accurate as the standard strategy.
  63167. * Test :
  63168. * Is the cullable object bounding sphere center in the frustum ?
  63169. * If not, apply the default culling strategy.
  63170. */
  63171. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  63172. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  63173. * This in an inclusion test first, then the bounding sphere only exclusion test.
  63174. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  63175. * 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.
  63176. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  63177. * Test :
  63178. * Is the cullable object bounding sphere center in the frustum ?
  63179. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  63180. */
  63181. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  63182. /**
  63183. * No logging while loading
  63184. */
  63185. static readonly SCENELOADER_NO_LOGGING: number;
  63186. /**
  63187. * Minimal logging while loading
  63188. */
  63189. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  63190. /**
  63191. * Summary logging while loading
  63192. */
  63193. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  63194. /**
  63195. * Detailled logging while loading
  63196. */
  63197. static readonly SCENELOADER_DETAILED_LOGGING: number;
  63198. }
  63199. }
  63200. declare module BABYLON {
  63201. /**
  63202. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  63203. * Babylon.js
  63204. */
  63205. export class DomManagement {
  63206. /**
  63207. * Checks if the window object exists
  63208. * @returns true if the window object exists
  63209. */
  63210. static IsWindowObjectExist(): boolean;
  63211. /**
  63212. * Extracts text content from a DOM element hierarchy
  63213. * @param element defines the root element
  63214. * @returns a string
  63215. */
  63216. static GetDOMTextContent(element: HTMLElement): string;
  63217. }
  63218. }
  63219. declare module BABYLON {
  63220. /**
  63221. * Logger used througouht the application to allow configuration of
  63222. * the log level required for the messages.
  63223. */
  63224. export class Logger {
  63225. /**
  63226. * No log
  63227. */
  63228. static readonly NoneLogLevel: number;
  63229. /**
  63230. * Only message logs
  63231. */
  63232. static readonly MessageLogLevel: number;
  63233. /**
  63234. * Only warning logs
  63235. */
  63236. static readonly WarningLogLevel: number;
  63237. /**
  63238. * Only error logs
  63239. */
  63240. static readonly ErrorLogLevel: number;
  63241. /**
  63242. * All logs
  63243. */
  63244. static readonly AllLogLevel: number;
  63245. private static _LogCache;
  63246. /**
  63247. * Gets a value indicating the number of loading errors
  63248. * @ignorenaming
  63249. */
  63250. static errorsCount: number;
  63251. /**
  63252. * Callback called when a new log is added
  63253. */
  63254. static OnNewCacheEntry: (entry: string) => void;
  63255. private static _AddLogEntry;
  63256. private static _FormatMessage;
  63257. private static _LogDisabled;
  63258. private static _LogEnabled;
  63259. private static _WarnDisabled;
  63260. private static _WarnEnabled;
  63261. private static _ErrorDisabled;
  63262. private static _ErrorEnabled;
  63263. /**
  63264. * Log a message to the console
  63265. */
  63266. static Log: (message: string) => void;
  63267. /**
  63268. * Write a warning message to the console
  63269. */
  63270. static Warn: (message: string) => void;
  63271. /**
  63272. * Write an error message to the console
  63273. */
  63274. static Error: (message: string) => void;
  63275. /**
  63276. * Gets current log cache (list of logs)
  63277. */
  63278. static readonly LogCache: string;
  63279. /**
  63280. * Clears the log cache
  63281. */
  63282. static ClearLogCache(): void;
  63283. /**
  63284. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  63285. */
  63286. static LogLevels: number;
  63287. }
  63288. }
  63289. declare module BABYLON {
  63290. /** @hidden */
  63291. export class _TypeStore {
  63292. /** @hidden */
  63293. static RegisteredTypes: {
  63294. [key: string]: Object;
  63295. };
  63296. /** @hidden */
  63297. static GetClass(fqdn: string): any;
  63298. }
  63299. }
  63300. declare module BABYLON {
  63301. /**
  63302. * Class containing a set of static utilities functions for deep copy.
  63303. */
  63304. export class DeepCopier {
  63305. /**
  63306. * Tries to copy an object by duplicating every property
  63307. * @param source defines the source object
  63308. * @param destination defines the target object
  63309. * @param doNotCopyList defines a list of properties to avoid
  63310. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  63311. */
  63312. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  63313. }
  63314. }
  63315. declare module BABYLON {
  63316. /**
  63317. * Class containing a set of static utilities functions for precision date
  63318. */
  63319. export class PrecisionDate {
  63320. /**
  63321. * Gets either window.performance.now() if supported or Date.now() else
  63322. */
  63323. static readonly Now: number;
  63324. }
  63325. }
  63326. declare module BABYLON {
  63327. /** @hidden */
  63328. export class _DevTools {
  63329. static WarnImport(name: string): string;
  63330. }
  63331. }
  63332. declare module BABYLON {
  63333. /**
  63334. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  63335. */
  63336. export class WebRequest {
  63337. private _xhr;
  63338. /**
  63339. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  63340. * i.e. when loading files, where the server/service expects an Authorization header
  63341. */
  63342. static CustomRequestHeaders: {
  63343. [key: string]: string;
  63344. };
  63345. /**
  63346. * Add callback functions in this array to update all the requests before they get sent to the network
  63347. */
  63348. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  63349. private _injectCustomRequestHeaders;
  63350. /**
  63351. * Gets or sets a function to be called when loading progress changes
  63352. */
  63353. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  63354. /**
  63355. * Returns client's state
  63356. */
  63357. readonly readyState: number;
  63358. /**
  63359. * Returns client's status
  63360. */
  63361. readonly status: number;
  63362. /**
  63363. * Returns client's status as a text
  63364. */
  63365. readonly statusText: string;
  63366. /**
  63367. * Returns client's response
  63368. */
  63369. readonly response: any;
  63370. /**
  63371. * Returns client's response url
  63372. */
  63373. readonly responseURL: string;
  63374. /**
  63375. * Returns client's response as text
  63376. */
  63377. readonly responseText: string;
  63378. /**
  63379. * Gets or sets the expected response type
  63380. */
  63381. responseType: XMLHttpRequestResponseType;
  63382. /** @hidden */
  63383. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  63384. /** @hidden */
  63385. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  63386. /**
  63387. * Cancels any network activity
  63388. */
  63389. abort(): void;
  63390. /**
  63391. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  63392. * @param body defines an optional request body
  63393. */
  63394. send(body?: Document | BodyInit | null): void;
  63395. /**
  63396. * Sets the request method, request URL
  63397. * @param method defines the method to use (GET, POST, etc..)
  63398. * @param url defines the url to connect with
  63399. */
  63400. open(method: string, url: string): void;
  63401. }
  63402. }
  63403. declare module BABYLON {
  63404. /**
  63405. * Class used to evalaute queries containing `and` and `or` operators
  63406. */
  63407. export class AndOrNotEvaluator {
  63408. /**
  63409. * Evaluate a query
  63410. * @param query defines the query to evaluate
  63411. * @param evaluateCallback defines the callback used to filter result
  63412. * @returns true if the query matches
  63413. */
  63414. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  63415. private static _HandleParenthesisContent;
  63416. private static _SimplifyNegation;
  63417. }
  63418. }
  63419. declare module BABYLON {
  63420. /**
  63421. * Class used to store custom tags
  63422. */
  63423. export class Tags {
  63424. /**
  63425. * Adds support for tags on the given object
  63426. * @param obj defines the object to use
  63427. */
  63428. static EnableFor(obj: any): void;
  63429. /**
  63430. * Removes tags support
  63431. * @param obj defines the object to use
  63432. */
  63433. static DisableFor(obj: any): void;
  63434. /**
  63435. * Gets a boolean indicating if the given object has tags
  63436. * @param obj defines the object to use
  63437. * @returns a boolean
  63438. */
  63439. static HasTags(obj: any): boolean;
  63440. /**
  63441. * Gets the tags available on a given object
  63442. * @param obj defines the object to use
  63443. * @param asString defines if the tags must be returned as a string instead of an array of strings
  63444. * @returns the tags
  63445. */
  63446. static GetTags(obj: any, asString?: boolean): any;
  63447. /**
  63448. * Adds tags to an object
  63449. * @param obj defines the object to use
  63450. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  63451. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  63452. */
  63453. static AddTagsTo(obj: any, tagsString: string): void;
  63454. /**
  63455. * @hidden
  63456. */
  63457. static _AddTagTo(obj: any, tag: string): void;
  63458. /**
  63459. * Removes specific tags from a specific object
  63460. * @param obj defines the object to use
  63461. * @param tagsString defines the tags to remove
  63462. */
  63463. static RemoveTagsFrom(obj: any, tagsString: string): void;
  63464. /**
  63465. * @hidden
  63466. */
  63467. static _RemoveTagFrom(obj: any, tag: string): void;
  63468. /**
  63469. * Defines if tags hosted on an object match a given query
  63470. * @param obj defines the object to use
  63471. * @param tagsQuery defines the tag query
  63472. * @returns a boolean
  63473. */
  63474. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  63475. }
  63476. }
  63477. declare module BABYLON {
  63478. /**
  63479. * Manages the defines for the Material
  63480. */
  63481. export class MaterialDefines {
  63482. private _keys;
  63483. private _isDirty;
  63484. /** @hidden */
  63485. _renderId: number;
  63486. /** @hidden */
  63487. _areLightsDirty: boolean;
  63488. /** @hidden */
  63489. _areAttributesDirty: boolean;
  63490. /** @hidden */
  63491. _areTexturesDirty: boolean;
  63492. /** @hidden */
  63493. _areFresnelDirty: boolean;
  63494. /** @hidden */
  63495. _areMiscDirty: boolean;
  63496. /** @hidden */
  63497. _areImageProcessingDirty: boolean;
  63498. /** @hidden */
  63499. _normals: boolean;
  63500. /** @hidden */
  63501. _uvs: boolean;
  63502. /** @hidden */
  63503. _needNormals: boolean;
  63504. /** @hidden */
  63505. _needUVs: boolean;
  63506. /**
  63507. * Specifies if the material needs to be re-calculated
  63508. */
  63509. readonly isDirty: boolean;
  63510. /**
  63511. * Marks the material to indicate that it has been re-calculated
  63512. */
  63513. markAsProcessed(): void;
  63514. /**
  63515. * Marks the material to indicate that it needs to be re-calculated
  63516. */
  63517. markAsUnprocessed(): void;
  63518. /**
  63519. * Marks the material to indicate all of its defines need to be re-calculated
  63520. */
  63521. markAllAsDirty(): void;
  63522. /**
  63523. * Marks the material to indicate that image processing needs to be re-calculated
  63524. */
  63525. markAsImageProcessingDirty(): void;
  63526. /**
  63527. * Marks the material to indicate the lights need to be re-calculated
  63528. */
  63529. markAsLightDirty(): void;
  63530. /**
  63531. * Marks the attribute state as changed
  63532. */
  63533. markAsAttributesDirty(): void;
  63534. /**
  63535. * Marks the texture state as changed
  63536. */
  63537. markAsTexturesDirty(): void;
  63538. /**
  63539. * Marks the fresnel state as changed
  63540. */
  63541. markAsFresnelDirty(): void;
  63542. /**
  63543. * Marks the misc state as changed
  63544. */
  63545. markAsMiscDirty(): void;
  63546. /**
  63547. * Rebuilds the material defines
  63548. */
  63549. rebuild(): void;
  63550. /**
  63551. * Specifies if two material defines are equal
  63552. * @param other - A material define instance to compare to
  63553. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  63554. */
  63555. isEqual(other: MaterialDefines): boolean;
  63556. /**
  63557. * Clones this instance's defines to another instance
  63558. * @param other - material defines to clone values to
  63559. */
  63560. cloneTo(other: MaterialDefines): void;
  63561. /**
  63562. * Resets the material define values
  63563. */
  63564. reset(): void;
  63565. /**
  63566. * Converts the material define values to a string
  63567. * @returns - String of material define information
  63568. */
  63569. toString(): string;
  63570. }
  63571. }
  63572. declare module BABYLON {
  63573. /**
  63574. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  63575. */
  63576. export class PerformanceMonitor {
  63577. private _enabled;
  63578. private _rollingFrameTime;
  63579. private _lastFrameTimeMs;
  63580. /**
  63581. * constructor
  63582. * @param frameSampleSize The number of samples required to saturate the sliding window
  63583. */
  63584. constructor(frameSampleSize?: number);
  63585. /**
  63586. * Samples current frame
  63587. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  63588. */
  63589. sampleFrame(timeMs?: number): void;
  63590. /**
  63591. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  63592. */
  63593. readonly averageFrameTime: number;
  63594. /**
  63595. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  63596. */
  63597. readonly averageFrameTimeVariance: number;
  63598. /**
  63599. * Returns the frame time of the most recent frame
  63600. */
  63601. readonly instantaneousFrameTime: number;
  63602. /**
  63603. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  63604. */
  63605. readonly averageFPS: number;
  63606. /**
  63607. * Returns the average framerate in frames per second using the most recent frame time
  63608. */
  63609. readonly instantaneousFPS: number;
  63610. /**
  63611. * Returns true if enough samples have been taken to completely fill the sliding window
  63612. */
  63613. readonly isSaturated: boolean;
  63614. /**
  63615. * Enables contributions to the sliding window sample set
  63616. */
  63617. enable(): void;
  63618. /**
  63619. * Disables contributions to the sliding window sample set
  63620. * Samples will not be interpolated over the disabled period
  63621. */
  63622. disable(): void;
  63623. /**
  63624. * Returns true if sampling is enabled
  63625. */
  63626. readonly isEnabled: boolean;
  63627. /**
  63628. * Resets performance monitor
  63629. */
  63630. reset(): void;
  63631. }
  63632. /**
  63633. * RollingAverage
  63634. *
  63635. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  63636. */
  63637. export class RollingAverage {
  63638. /**
  63639. * Current average
  63640. */
  63641. average: number;
  63642. /**
  63643. * Current variance
  63644. */
  63645. variance: number;
  63646. protected _samples: Array<number>;
  63647. protected _sampleCount: number;
  63648. protected _pos: number;
  63649. protected _m2: number;
  63650. /**
  63651. * constructor
  63652. * @param length The number of samples required to saturate the sliding window
  63653. */
  63654. constructor(length: number);
  63655. /**
  63656. * Adds a sample to the sample set
  63657. * @param v The sample value
  63658. */
  63659. add(v: number): void;
  63660. /**
  63661. * Returns previously added values or null if outside of history or outside the sliding window domain
  63662. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  63663. * @return Value previously recorded with add() or null if outside of range
  63664. */
  63665. history(i: number): number;
  63666. /**
  63667. * Returns true if enough samples have been taken to completely fill the sliding window
  63668. * @return true if sample-set saturated
  63669. */
  63670. isSaturated(): boolean;
  63671. /**
  63672. * Resets the rolling average (equivalent to 0 samples taken so far)
  63673. */
  63674. reset(): void;
  63675. /**
  63676. * Wraps a value around the sample range boundaries
  63677. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  63678. * @return Wrapped position in sample range
  63679. */
  63680. protected _wrapPosition(i: number): number;
  63681. }
  63682. }
  63683. declare module BABYLON {
  63684. /**
  63685. * This class implement a typical dictionary using a string as key and the generic type T as value.
  63686. * The underlying implementation relies on an associative array to ensure the best performances.
  63687. * The value can be anything including 'null' but except 'undefined'
  63688. */
  63689. export class StringDictionary<T> {
  63690. /**
  63691. * This will clear this dictionary and copy the content from the 'source' one.
  63692. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  63693. * @param source the dictionary to take the content from and copy to this dictionary
  63694. */
  63695. copyFrom(source: StringDictionary<T>): void;
  63696. /**
  63697. * Get a value based from its key
  63698. * @param key the given key to get the matching value from
  63699. * @return the value if found, otherwise undefined is returned
  63700. */
  63701. get(key: string): T | undefined;
  63702. /**
  63703. * Get a value from its key or add it if it doesn't exist.
  63704. * This method will ensure you that a given key/data will be present in the dictionary.
  63705. * @param key the given key to get the matching value from
  63706. * @param factory the factory that will create the value if the key is not present in the dictionary.
  63707. * The factory will only be invoked if there's no data for the given key.
  63708. * @return the value corresponding to the key.
  63709. */
  63710. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  63711. /**
  63712. * Get a value from its key if present in the dictionary otherwise add it
  63713. * @param key the key to get the value from
  63714. * @param val if there's no such key/value pair in the dictionary add it with this value
  63715. * @return the value corresponding to the key
  63716. */
  63717. getOrAdd(key: string, val: T): T;
  63718. /**
  63719. * Check if there's a given key in the dictionary
  63720. * @param key the key to check for
  63721. * @return true if the key is present, false otherwise
  63722. */
  63723. contains(key: string): boolean;
  63724. /**
  63725. * Add a new key and its corresponding value
  63726. * @param key the key to add
  63727. * @param value the value corresponding to the key
  63728. * @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
  63729. */
  63730. add(key: string, value: T): boolean;
  63731. /**
  63732. * Update a specific value associated to a key
  63733. * @param key defines the key to use
  63734. * @param value defines the value to store
  63735. * @returns true if the value was updated (or false if the key was not found)
  63736. */
  63737. set(key: string, value: T): boolean;
  63738. /**
  63739. * Get the element of the given key and remove it from the dictionary
  63740. * @param key defines the key to search
  63741. * @returns the value associated with the key or null if not found
  63742. */
  63743. getAndRemove(key: string): Nullable<T>;
  63744. /**
  63745. * Remove a key/value from the dictionary.
  63746. * @param key the key to remove
  63747. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  63748. */
  63749. remove(key: string): boolean;
  63750. /**
  63751. * Clear the whole content of the dictionary
  63752. */
  63753. clear(): void;
  63754. /**
  63755. * Gets the current count
  63756. */
  63757. readonly count: number;
  63758. /**
  63759. * Execute a callback on each key/val of the dictionary.
  63760. * Note that you can remove any element in this dictionary in the callback implementation
  63761. * @param callback the callback to execute on a given key/value pair
  63762. */
  63763. forEach(callback: (key: string, val: T) => void): void;
  63764. /**
  63765. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  63766. * If the callback returns null or undefined the method will iterate to the next key/value pair
  63767. * Note that you can remove any element in this dictionary in the callback implementation
  63768. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  63769. * @returns the first item
  63770. */
  63771. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  63772. private _count;
  63773. private _data;
  63774. }
  63775. }
  63776. declare module BABYLON {
  63777. /**
  63778. * Helper class that provides a small promise polyfill
  63779. */
  63780. export class PromisePolyfill {
  63781. /**
  63782. * Static function used to check if the polyfill is required
  63783. * If this is the case then the function will inject the polyfill to window.Promise
  63784. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  63785. */
  63786. static Apply(force?: boolean): void;
  63787. }
  63788. }
  63789. declare module BABYLON {
  63790. /**
  63791. * Class used to store data that will be store in GPU memory
  63792. */
  63793. export class Buffer {
  63794. private _engine;
  63795. private _buffer;
  63796. /** @hidden */
  63797. _data: Nullable<DataArray>;
  63798. private _updatable;
  63799. private _instanced;
  63800. /**
  63801. * Gets the byte stride.
  63802. */
  63803. readonly byteStride: number;
  63804. /**
  63805. * Constructor
  63806. * @param engine the engine
  63807. * @param data the data to use for this buffer
  63808. * @param updatable whether the data is updatable
  63809. * @param stride the stride (optional)
  63810. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  63811. * @param instanced whether the buffer is instanced (optional)
  63812. * @param useBytes set to true if the stride in in bytes (optional)
  63813. */
  63814. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  63815. /**
  63816. * Create a new VertexBuffer based on the current buffer
  63817. * @param kind defines the vertex buffer kind (position, normal, etc.)
  63818. * @param offset defines offset in the buffer (0 by default)
  63819. * @param size defines the size in floats of attributes (position is 3 for instance)
  63820. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  63821. * @param instanced defines if the vertex buffer contains indexed data
  63822. * @param useBytes defines if the offset and stride are in bytes
  63823. * @returns the new vertex buffer
  63824. */
  63825. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  63826. /**
  63827. * Gets a boolean indicating if the Buffer is updatable?
  63828. * @returns true if the buffer is updatable
  63829. */
  63830. isUpdatable(): boolean;
  63831. /**
  63832. * Gets current buffer's data
  63833. * @returns a DataArray or null
  63834. */
  63835. getData(): Nullable<DataArray>;
  63836. /**
  63837. * Gets underlying native buffer
  63838. * @returns underlying native buffer
  63839. */
  63840. getBuffer(): Nullable<WebGLBuffer>;
  63841. /**
  63842. * Gets the stride in float32 units (i.e. byte stride / 4).
  63843. * May not be an integer if the byte stride is not divisible by 4.
  63844. * DEPRECATED. Use byteStride instead.
  63845. * @returns the stride in float32 units
  63846. */
  63847. getStrideSize(): number;
  63848. /**
  63849. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  63850. * @param data defines the data to store
  63851. */
  63852. create(data?: Nullable<DataArray>): void;
  63853. /** @hidden */
  63854. _rebuild(): void;
  63855. /**
  63856. * Update current buffer data
  63857. * @param data defines the data to store
  63858. */
  63859. update(data: DataArray): void;
  63860. /**
  63861. * Updates the data directly.
  63862. * @param data the new data
  63863. * @param offset the new offset
  63864. * @param vertexCount the vertex count (optional)
  63865. * @param useBytes set to true if the offset is in bytes
  63866. */
  63867. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  63868. /**
  63869. * Release all resources
  63870. */
  63871. dispose(): void;
  63872. }
  63873. /**
  63874. * Specialized buffer used to store vertex data
  63875. */
  63876. export class VertexBuffer {
  63877. /** @hidden */
  63878. _buffer: Buffer;
  63879. private _kind;
  63880. private _size;
  63881. private _ownsBuffer;
  63882. private _instanced;
  63883. private _instanceDivisor;
  63884. /**
  63885. * The byte type.
  63886. */
  63887. static readonly BYTE: number;
  63888. /**
  63889. * The unsigned byte type.
  63890. */
  63891. static readonly UNSIGNED_BYTE: number;
  63892. /**
  63893. * The short type.
  63894. */
  63895. static readonly SHORT: number;
  63896. /**
  63897. * The unsigned short type.
  63898. */
  63899. static readonly UNSIGNED_SHORT: number;
  63900. /**
  63901. * The integer type.
  63902. */
  63903. static readonly INT: number;
  63904. /**
  63905. * The unsigned integer type.
  63906. */
  63907. static readonly UNSIGNED_INT: number;
  63908. /**
  63909. * The float type.
  63910. */
  63911. static readonly FLOAT: number;
  63912. /**
  63913. * Gets or sets the instance divisor when in instanced mode
  63914. */
  63915. instanceDivisor: number;
  63916. /**
  63917. * Gets the byte stride.
  63918. */
  63919. readonly byteStride: number;
  63920. /**
  63921. * Gets the byte offset.
  63922. */
  63923. readonly byteOffset: number;
  63924. /**
  63925. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  63926. */
  63927. readonly normalized: boolean;
  63928. /**
  63929. * Gets the data type of each component in the array.
  63930. */
  63931. readonly type: number;
  63932. /**
  63933. * Constructor
  63934. * @param engine the engine
  63935. * @param data the data to use for this vertex buffer
  63936. * @param kind the vertex buffer kind
  63937. * @param updatable whether the data is updatable
  63938. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  63939. * @param stride the stride (optional)
  63940. * @param instanced whether the buffer is instanced (optional)
  63941. * @param offset the offset of the data (optional)
  63942. * @param size the number of components (optional)
  63943. * @param type the type of the component (optional)
  63944. * @param normalized whether the data contains normalized data (optional)
  63945. * @param useBytes set to true if stride and offset are in bytes (optional)
  63946. */
  63947. 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);
  63948. /** @hidden */
  63949. _rebuild(): void;
  63950. /**
  63951. * Returns the kind of the VertexBuffer (string)
  63952. * @returns a string
  63953. */
  63954. getKind(): string;
  63955. /**
  63956. * Gets a boolean indicating if the VertexBuffer is updatable?
  63957. * @returns true if the buffer is updatable
  63958. */
  63959. isUpdatable(): boolean;
  63960. /**
  63961. * Gets current buffer's data
  63962. * @returns a DataArray or null
  63963. */
  63964. getData(): Nullable<DataArray>;
  63965. /**
  63966. * Gets underlying native buffer
  63967. * @returns underlying native buffer
  63968. */
  63969. getBuffer(): Nullable<WebGLBuffer>;
  63970. /**
  63971. * Gets the stride in float32 units (i.e. byte stride / 4).
  63972. * May not be an integer if the byte stride is not divisible by 4.
  63973. * DEPRECATED. Use byteStride instead.
  63974. * @returns the stride in float32 units
  63975. */
  63976. getStrideSize(): number;
  63977. /**
  63978. * Returns the offset as a multiple of the type byte length.
  63979. * DEPRECATED. Use byteOffset instead.
  63980. * @returns the offset in bytes
  63981. */
  63982. getOffset(): number;
  63983. /**
  63984. * Returns the number of components per vertex attribute (integer)
  63985. * @returns the size in float
  63986. */
  63987. getSize(): number;
  63988. /**
  63989. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  63990. * @returns true if this buffer is instanced
  63991. */
  63992. getIsInstanced(): boolean;
  63993. /**
  63994. * Returns the instancing divisor, zero for non-instanced (integer).
  63995. * @returns a number
  63996. */
  63997. getInstanceDivisor(): number;
  63998. /**
  63999. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64000. * @param data defines the data to store
  64001. */
  64002. create(data?: DataArray): void;
  64003. /**
  64004. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  64005. * This function will create a new buffer if the current one is not updatable
  64006. * @param data defines the data to store
  64007. */
  64008. update(data: DataArray): void;
  64009. /**
  64010. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  64011. * Returns the directly updated WebGLBuffer.
  64012. * @param data the new data
  64013. * @param offset the new offset
  64014. * @param useBytes set to true if the offset is in bytes
  64015. */
  64016. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  64017. /**
  64018. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  64019. */
  64020. dispose(): void;
  64021. /**
  64022. * Enumerates each value of this vertex buffer as numbers.
  64023. * @param count the number of values to enumerate
  64024. * @param callback the callback function called for each value
  64025. */
  64026. forEach(count: number, callback: (value: number, index: number) => void): void;
  64027. /**
  64028. * Positions
  64029. */
  64030. static readonly PositionKind: string;
  64031. /**
  64032. * Normals
  64033. */
  64034. static readonly NormalKind: string;
  64035. /**
  64036. * Tangents
  64037. */
  64038. static readonly TangentKind: string;
  64039. /**
  64040. * Texture coordinates
  64041. */
  64042. static readonly UVKind: string;
  64043. /**
  64044. * Texture coordinates 2
  64045. */
  64046. static readonly UV2Kind: string;
  64047. /**
  64048. * Texture coordinates 3
  64049. */
  64050. static readonly UV3Kind: string;
  64051. /**
  64052. * Texture coordinates 4
  64053. */
  64054. static readonly UV4Kind: string;
  64055. /**
  64056. * Texture coordinates 5
  64057. */
  64058. static readonly UV5Kind: string;
  64059. /**
  64060. * Texture coordinates 6
  64061. */
  64062. static readonly UV6Kind: string;
  64063. /**
  64064. * Colors
  64065. */
  64066. static readonly ColorKind: string;
  64067. /**
  64068. * Matrix indices (for bones)
  64069. */
  64070. static readonly MatricesIndicesKind: string;
  64071. /**
  64072. * Matrix weights (for bones)
  64073. */
  64074. static readonly MatricesWeightsKind: string;
  64075. /**
  64076. * Additional matrix indices (for bones)
  64077. */
  64078. static readonly MatricesIndicesExtraKind: string;
  64079. /**
  64080. * Additional matrix weights (for bones)
  64081. */
  64082. static readonly MatricesWeightsExtraKind: string;
  64083. /**
  64084. * Deduces the stride given a kind.
  64085. * @param kind The kind string to deduce
  64086. * @returns The deduced stride
  64087. */
  64088. static DeduceStride(kind: string): number;
  64089. /**
  64090. * Gets the byte length of the given type.
  64091. * @param type the type
  64092. * @returns the number of bytes
  64093. */
  64094. static GetTypeByteLength(type: number): number;
  64095. /**
  64096. * Enumerates each value of the given parameters as numbers.
  64097. * @param data the data to enumerate
  64098. * @param byteOffset the byte offset of the data
  64099. * @param byteStride the byte stride of the data
  64100. * @param componentCount the number of components per element
  64101. * @param componentType the type of the component
  64102. * @param count the total number of components
  64103. * @param normalized whether the data is normalized
  64104. * @param callback the callback function called for each value
  64105. */
  64106. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  64107. private static _GetFloatValue;
  64108. }
  64109. }
  64110. declare module BABYLON {
  64111. /**
  64112. * Class representing spherical polynomial coefficients to the 3rd degree
  64113. */
  64114. export class SphericalPolynomial {
  64115. /**
  64116. * The x coefficients of the spherical polynomial
  64117. */
  64118. x: Vector3;
  64119. /**
  64120. * The y coefficients of the spherical polynomial
  64121. */
  64122. y: Vector3;
  64123. /**
  64124. * The z coefficients of the spherical polynomial
  64125. */
  64126. z: Vector3;
  64127. /**
  64128. * The xx coefficients of the spherical polynomial
  64129. */
  64130. xx: Vector3;
  64131. /**
  64132. * The yy coefficients of the spherical polynomial
  64133. */
  64134. yy: Vector3;
  64135. /**
  64136. * The zz coefficients of the spherical polynomial
  64137. */
  64138. zz: Vector3;
  64139. /**
  64140. * The xy coefficients of the spherical polynomial
  64141. */
  64142. xy: Vector3;
  64143. /**
  64144. * The yz coefficients of the spherical polynomial
  64145. */
  64146. yz: Vector3;
  64147. /**
  64148. * The zx coefficients of the spherical polynomial
  64149. */
  64150. zx: Vector3;
  64151. /**
  64152. * Adds an ambient color to the spherical polynomial
  64153. * @param color the color to add
  64154. */
  64155. addAmbient(color: Color3): void;
  64156. /**
  64157. * Scales the spherical polynomial by the given amount
  64158. * @param scale the amount to scale
  64159. */
  64160. scale(scale: number): void;
  64161. /**
  64162. * Gets the spherical polynomial from harmonics
  64163. * @param harmonics the spherical harmonics
  64164. * @returns the spherical polynomial
  64165. */
  64166. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  64167. /**
  64168. * Constructs a spherical polynomial from an array.
  64169. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  64170. * @returns the spherical polynomial
  64171. */
  64172. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  64173. }
  64174. /**
  64175. * Class representing spherical harmonics coefficients to the 3rd degree
  64176. */
  64177. export class SphericalHarmonics {
  64178. /**
  64179. * The l0,0 coefficients of the spherical harmonics
  64180. */
  64181. l00: Vector3;
  64182. /**
  64183. * The l1,-1 coefficients of the spherical harmonics
  64184. */
  64185. l1_1: Vector3;
  64186. /**
  64187. * The l1,0 coefficients of the spherical harmonics
  64188. */
  64189. l10: Vector3;
  64190. /**
  64191. * The l1,1 coefficients of the spherical harmonics
  64192. */
  64193. l11: Vector3;
  64194. /**
  64195. * The l2,-2 coefficients of the spherical harmonics
  64196. */
  64197. l2_2: Vector3;
  64198. /**
  64199. * The l2,-1 coefficients of the spherical harmonics
  64200. */
  64201. l2_1: Vector3;
  64202. /**
  64203. * The l2,0 coefficients of the spherical harmonics
  64204. */
  64205. l20: Vector3;
  64206. /**
  64207. * The l2,1 coefficients of the spherical harmonics
  64208. */
  64209. l21: Vector3;
  64210. /**
  64211. * The l2,2 coefficients of the spherical harmonics
  64212. */
  64213. lL22: Vector3;
  64214. /**
  64215. * Adds a light to the spherical harmonics
  64216. * @param direction the direction of the light
  64217. * @param color the color of the light
  64218. * @param deltaSolidAngle the delta solid angle of the light
  64219. */
  64220. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  64221. /**
  64222. * Scales the spherical harmonics by the given amount
  64223. * @param scale the amount to scale
  64224. */
  64225. scale(scale: number): void;
  64226. /**
  64227. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  64228. *
  64229. * ```
  64230. * E_lm = A_l * L_lm
  64231. * ```
  64232. *
  64233. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  64234. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  64235. * the scaling factors are given in equation 9.
  64236. */
  64237. convertIncidentRadianceToIrradiance(): void;
  64238. /**
  64239. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  64240. *
  64241. * ```
  64242. * L = (1/pi) * E * rho
  64243. * ```
  64244. *
  64245. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  64246. */
  64247. convertIrradianceToLambertianRadiance(): void;
  64248. /**
  64249. * Gets the spherical harmonics from polynomial
  64250. * @param polynomial the spherical polynomial
  64251. * @returns the spherical harmonics
  64252. */
  64253. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  64254. /**
  64255. * Constructs a spherical harmonics from an array.
  64256. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  64257. * @returns the spherical harmonics
  64258. */
  64259. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  64260. }
  64261. }
  64262. declare module BABYLON {
  64263. /**
  64264. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  64265. */
  64266. export interface CubeMapInfo {
  64267. /**
  64268. * The pixel array for the front face.
  64269. * This is stored in format, left to right, up to down format.
  64270. */
  64271. front: Nullable<ArrayBufferView>;
  64272. /**
  64273. * The pixel array for the back face.
  64274. * This is stored in format, left to right, up to down format.
  64275. */
  64276. back: Nullable<ArrayBufferView>;
  64277. /**
  64278. * The pixel array for the left face.
  64279. * This is stored in format, left to right, up to down format.
  64280. */
  64281. left: Nullable<ArrayBufferView>;
  64282. /**
  64283. * The pixel array for the right face.
  64284. * This is stored in format, left to right, up to down format.
  64285. */
  64286. right: Nullable<ArrayBufferView>;
  64287. /**
  64288. * The pixel array for the up face.
  64289. * This is stored in format, left to right, up to down format.
  64290. */
  64291. up: Nullable<ArrayBufferView>;
  64292. /**
  64293. * The pixel array for the down face.
  64294. * This is stored in format, left to right, up to down format.
  64295. */
  64296. down: Nullable<ArrayBufferView>;
  64297. /**
  64298. * The size of the cubemap stored.
  64299. *
  64300. * Each faces will be size * size pixels.
  64301. */
  64302. size: number;
  64303. /**
  64304. * The format of the texture.
  64305. *
  64306. * RGBA, RGB.
  64307. */
  64308. format: number;
  64309. /**
  64310. * The type of the texture data.
  64311. *
  64312. * UNSIGNED_INT, FLOAT.
  64313. */
  64314. type: number;
  64315. /**
  64316. * Specifies whether the texture is in gamma space.
  64317. */
  64318. gammaSpace: boolean;
  64319. }
  64320. /**
  64321. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  64322. */
  64323. export class PanoramaToCubeMapTools {
  64324. private static FACE_FRONT;
  64325. private static FACE_BACK;
  64326. private static FACE_RIGHT;
  64327. private static FACE_LEFT;
  64328. private static FACE_DOWN;
  64329. private static FACE_UP;
  64330. /**
  64331. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  64332. *
  64333. * @param float32Array The source data.
  64334. * @param inputWidth The width of the input panorama.
  64335. * @param inputHeight The height of the input panorama.
  64336. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  64337. * @return The cubemap data
  64338. */
  64339. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  64340. private static CreateCubemapTexture;
  64341. private static CalcProjectionSpherical;
  64342. }
  64343. }
  64344. declare module BABYLON {
  64345. /**
  64346. * Helper class dealing with the extraction of spherical polynomial dataArray
  64347. * from a cube map.
  64348. */
  64349. export class CubeMapToSphericalPolynomialTools {
  64350. private static FileFaces;
  64351. /**
  64352. * Converts a texture to the according Spherical Polynomial data.
  64353. * This extracts the first 3 orders only as they are the only one used in the lighting.
  64354. *
  64355. * @param texture The texture to extract the information from.
  64356. * @return The Spherical Polynomial data.
  64357. */
  64358. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  64359. /**
  64360. * Converts a cubemap to the according Spherical Polynomial data.
  64361. * This extracts the first 3 orders only as they are the only one used in the lighting.
  64362. *
  64363. * @param cubeInfo The Cube map to extract the information from.
  64364. * @return The Spherical Polynomial data.
  64365. */
  64366. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  64367. }
  64368. }
  64369. declare module BABYLON {
  64370. /**
  64371. * The engine store class is responsible to hold all the instances of Engine and Scene created
  64372. * during the life time of the application.
  64373. */
  64374. export class EngineStore {
  64375. /** Gets the list of created engines */
  64376. static Instances: Engine[];
  64377. /**
  64378. * Gets the latest created engine
  64379. */
  64380. static readonly LastCreatedEngine: Nullable<Engine>;
  64381. /**
  64382. * Gets the latest created scene
  64383. */
  64384. static readonly LastCreatedScene: Nullable<Scene>;
  64385. }
  64386. }
  64387. declare module BABYLON {
  64388. /**
  64389. * Define options used to create a render target texture
  64390. */
  64391. export class RenderTargetCreationOptions {
  64392. /**
  64393. * Specifies is mipmaps must be generated
  64394. */
  64395. generateMipMaps?: boolean;
  64396. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  64397. generateDepthBuffer?: boolean;
  64398. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  64399. generateStencilBuffer?: boolean;
  64400. /** Defines texture type (int by default) */
  64401. type?: number;
  64402. /** Defines sampling mode (trilinear by default) */
  64403. samplingMode?: number;
  64404. /** Defines format (RGBA by default) */
  64405. format?: number;
  64406. }
  64407. }
  64408. declare module BABYLON {
  64409. /**
  64410. * @hidden
  64411. **/
  64412. export class _AlphaState {
  64413. private _isAlphaBlendDirty;
  64414. private _isBlendFunctionParametersDirty;
  64415. private _isBlendEquationParametersDirty;
  64416. private _isBlendConstantsDirty;
  64417. private _alphaBlend;
  64418. private _blendFunctionParameters;
  64419. private _blendEquationParameters;
  64420. private _blendConstants;
  64421. /**
  64422. * Initializes the state.
  64423. */
  64424. constructor();
  64425. readonly isDirty: boolean;
  64426. alphaBlend: boolean;
  64427. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  64428. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  64429. setAlphaEquationParameters(rgb: number, alpha: number): void;
  64430. reset(): void;
  64431. apply(gl: WebGLRenderingContext): void;
  64432. }
  64433. }
  64434. declare module BABYLON {
  64435. /**
  64436. * @hidden
  64437. **/
  64438. export class _DepthCullingState {
  64439. private _isDepthTestDirty;
  64440. private _isDepthMaskDirty;
  64441. private _isDepthFuncDirty;
  64442. private _isCullFaceDirty;
  64443. private _isCullDirty;
  64444. private _isZOffsetDirty;
  64445. private _isFrontFaceDirty;
  64446. private _depthTest;
  64447. private _depthMask;
  64448. private _depthFunc;
  64449. private _cull;
  64450. private _cullFace;
  64451. private _zOffset;
  64452. private _frontFace;
  64453. /**
  64454. * Initializes the state.
  64455. */
  64456. constructor();
  64457. readonly isDirty: boolean;
  64458. zOffset: number;
  64459. cullFace: Nullable<number>;
  64460. cull: Nullable<boolean>;
  64461. depthFunc: Nullable<number>;
  64462. depthMask: boolean;
  64463. depthTest: boolean;
  64464. frontFace: Nullable<number>;
  64465. reset(): void;
  64466. apply(gl: WebGLRenderingContext): void;
  64467. }
  64468. }
  64469. declare module BABYLON {
  64470. /**
  64471. * @hidden
  64472. **/
  64473. export class _StencilState {
  64474. /** 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 */
  64475. static readonly ALWAYS: number;
  64476. /** Passed to stencilOperation to specify that stencil value must be kept */
  64477. static readonly KEEP: number;
  64478. /** Passed to stencilOperation to specify that stencil value must be replaced */
  64479. static readonly REPLACE: number;
  64480. private _isStencilTestDirty;
  64481. private _isStencilMaskDirty;
  64482. private _isStencilFuncDirty;
  64483. private _isStencilOpDirty;
  64484. private _stencilTest;
  64485. private _stencilMask;
  64486. private _stencilFunc;
  64487. private _stencilFuncRef;
  64488. private _stencilFuncMask;
  64489. private _stencilOpStencilFail;
  64490. private _stencilOpDepthFail;
  64491. private _stencilOpStencilDepthPass;
  64492. readonly isDirty: boolean;
  64493. stencilFunc: number;
  64494. stencilFuncRef: number;
  64495. stencilFuncMask: number;
  64496. stencilOpStencilFail: number;
  64497. stencilOpDepthFail: number;
  64498. stencilOpStencilDepthPass: number;
  64499. stencilMask: number;
  64500. stencilTest: boolean;
  64501. constructor();
  64502. reset(): void;
  64503. apply(gl: WebGLRenderingContext): void;
  64504. }
  64505. }
  64506. declare module BABYLON {
  64507. /**
  64508. * @hidden
  64509. **/
  64510. export class _TimeToken {
  64511. _startTimeQuery: Nullable<WebGLQuery>;
  64512. _endTimeQuery: Nullable<WebGLQuery>;
  64513. _timeElapsedQuery: Nullable<WebGLQuery>;
  64514. _timeElapsedQueryEnded: boolean;
  64515. }
  64516. }
  64517. declare module BABYLON {
  64518. /**
  64519. * Internal interface used to track InternalTexture already bound to the GL context
  64520. */
  64521. export interface IInternalTextureTracker {
  64522. /**
  64523. * Gets or set the previous tracker in the list
  64524. */
  64525. previous: Nullable<IInternalTextureTracker>;
  64526. /**
  64527. * Gets or set the next tracker in the list
  64528. */
  64529. next: Nullable<IInternalTextureTracker>;
  64530. }
  64531. /**
  64532. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  64533. */
  64534. export class DummyInternalTextureTracker {
  64535. /**
  64536. * Gets or set the previous tracker in the list
  64537. */
  64538. previous: Nullable<IInternalTextureTracker>;
  64539. /**
  64540. * Gets or set the next tracker in the list
  64541. */
  64542. next: Nullable<IInternalTextureTracker>;
  64543. }
  64544. }
  64545. declare module BABYLON {
  64546. /**
  64547. * Class used to store data associated with WebGL texture data for the engine
  64548. * This class should not be used directly
  64549. */
  64550. export class InternalTexture implements IInternalTextureTracker {
  64551. /** hidden */
  64552. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  64553. /**
  64554. * The source of the texture data is unknown
  64555. */
  64556. static DATASOURCE_UNKNOWN: number;
  64557. /**
  64558. * Texture data comes from an URL
  64559. */
  64560. static DATASOURCE_URL: number;
  64561. /**
  64562. * Texture data is only used for temporary storage
  64563. */
  64564. static DATASOURCE_TEMP: number;
  64565. /**
  64566. * Texture data comes from raw data (ArrayBuffer)
  64567. */
  64568. static DATASOURCE_RAW: number;
  64569. /**
  64570. * Texture content is dynamic (video or dynamic texture)
  64571. */
  64572. static DATASOURCE_DYNAMIC: number;
  64573. /**
  64574. * Texture content is generated by rendering to it
  64575. */
  64576. static DATASOURCE_RENDERTARGET: number;
  64577. /**
  64578. * Texture content is part of a multi render target process
  64579. */
  64580. static DATASOURCE_MULTIRENDERTARGET: number;
  64581. /**
  64582. * Texture data comes from a cube data file
  64583. */
  64584. static DATASOURCE_CUBE: number;
  64585. /**
  64586. * Texture data comes from a raw cube data
  64587. */
  64588. static DATASOURCE_CUBERAW: number;
  64589. /**
  64590. * Texture data come from a prefiltered cube data file
  64591. */
  64592. static DATASOURCE_CUBEPREFILTERED: number;
  64593. /**
  64594. * Texture content is raw 3D data
  64595. */
  64596. static DATASOURCE_RAW3D: number;
  64597. /**
  64598. * Texture content is a depth texture
  64599. */
  64600. static DATASOURCE_DEPTHTEXTURE: number;
  64601. /**
  64602. * Texture data comes from a raw cube data encoded with RGBD
  64603. */
  64604. static DATASOURCE_CUBERAW_RGBD: number;
  64605. /**
  64606. * Defines if the texture is ready
  64607. */
  64608. isReady: boolean;
  64609. /**
  64610. * Defines if the texture is a cube texture
  64611. */
  64612. isCube: boolean;
  64613. /**
  64614. * Defines if the texture contains 3D data
  64615. */
  64616. is3D: boolean;
  64617. /**
  64618. * Gets the URL used to load this texture
  64619. */
  64620. url: string;
  64621. /**
  64622. * Gets the sampling mode of the texture
  64623. */
  64624. samplingMode: number;
  64625. /**
  64626. * Gets a boolean indicating if the texture needs mipmaps generation
  64627. */
  64628. generateMipMaps: boolean;
  64629. /**
  64630. * Gets the number of samples used by the texture (WebGL2+ only)
  64631. */
  64632. samples: number;
  64633. /**
  64634. * Gets the type of the texture (int, float...)
  64635. */
  64636. type: number;
  64637. /**
  64638. * Gets the format of the texture (RGB, RGBA...)
  64639. */
  64640. format: number;
  64641. /**
  64642. * Observable called when the texture is loaded
  64643. */
  64644. onLoadedObservable: Observable<InternalTexture>;
  64645. /**
  64646. * Gets the width of the texture
  64647. */
  64648. width: number;
  64649. /**
  64650. * Gets the height of the texture
  64651. */
  64652. height: number;
  64653. /**
  64654. * Gets the depth of the texture
  64655. */
  64656. depth: number;
  64657. /**
  64658. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  64659. */
  64660. baseWidth: number;
  64661. /**
  64662. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  64663. */
  64664. baseHeight: number;
  64665. /**
  64666. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  64667. */
  64668. baseDepth: number;
  64669. /**
  64670. * Gets a boolean indicating if the texture is inverted on Y axis
  64671. */
  64672. invertY: boolean;
  64673. /**
  64674. * Gets or set the previous tracker in the list
  64675. */
  64676. previous: Nullable<IInternalTextureTracker>;
  64677. /**
  64678. * Gets or set the next tracker in the list
  64679. */
  64680. next: Nullable<IInternalTextureTracker>;
  64681. /** @hidden */
  64682. _invertVScale: boolean;
  64683. /** @hidden */
  64684. _initialSlot: number;
  64685. /** @hidden */
  64686. _designatedSlot: number;
  64687. /** @hidden */
  64688. _dataSource: number;
  64689. /** @hidden */
  64690. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  64691. /** @hidden */
  64692. _bufferView: Nullable<ArrayBufferView>;
  64693. /** @hidden */
  64694. _bufferViewArray: Nullable<ArrayBufferView[]>;
  64695. /** @hidden */
  64696. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  64697. /** @hidden */
  64698. _size: number;
  64699. /** @hidden */
  64700. _extension: string;
  64701. /** @hidden */
  64702. _files: Nullable<string[]>;
  64703. /** @hidden */
  64704. _workingCanvas: HTMLCanvasElement;
  64705. /** @hidden */
  64706. _workingContext: CanvasRenderingContext2D;
  64707. /** @hidden */
  64708. _framebuffer: Nullable<WebGLFramebuffer>;
  64709. /** @hidden */
  64710. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  64711. /** @hidden */
  64712. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  64713. /** @hidden */
  64714. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  64715. /** @hidden */
  64716. _attachments: Nullable<number[]>;
  64717. /** @hidden */
  64718. _cachedCoordinatesMode: Nullable<number>;
  64719. /** @hidden */
  64720. _cachedWrapU: Nullable<number>;
  64721. /** @hidden */
  64722. _cachedWrapV: Nullable<number>;
  64723. /** @hidden */
  64724. _cachedWrapR: Nullable<number>;
  64725. /** @hidden */
  64726. _cachedAnisotropicFilteringLevel: Nullable<number>;
  64727. /** @hidden */
  64728. _isDisabled: boolean;
  64729. /** @hidden */
  64730. _compression: Nullable<string>;
  64731. /** @hidden */
  64732. _generateStencilBuffer: boolean;
  64733. /** @hidden */
  64734. _generateDepthBuffer: boolean;
  64735. /** @hidden */
  64736. _comparisonFunction: number;
  64737. /** @hidden */
  64738. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  64739. /** @hidden */
  64740. _lodGenerationScale: number;
  64741. /** @hidden */
  64742. _lodGenerationOffset: number;
  64743. /** @hidden */
  64744. _lodTextureHigh: BaseTexture;
  64745. /** @hidden */
  64746. _lodTextureMid: BaseTexture;
  64747. /** @hidden */
  64748. _lodTextureLow: BaseTexture;
  64749. /** @hidden */
  64750. _isRGBD: boolean;
  64751. /** @hidden */
  64752. _webGLTexture: Nullable<WebGLTexture>;
  64753. /** @hidden */
  64754. _references: number;
  64755. private _engine;
  64756. /**
  64757. * Gets the Engine the texture belongs to.
  64758. * @returns The babylon engine
  64759. */
  64760. getEngine(): Engine;
  64761. /**
  64762. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  64763. */
  64764. readonly dataSource: number;
  64765. /**
  64766. * Creates a new InternalTexture
  64767. * @param engine defines the engine to use
  64768. * @param dataSource defines the type of data that will be used
  64769. * @param delayAllocation if the texture allocation should be delayed (default: false)
  64770. */
  64771. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  64772. /**
  64773. * Increments the number of references (ie. the number of Texture that point to it)
  64774. */
  64775. incrementReferences(): void;
  64776. /**
  64777. * Change the size of the texture (not the size of the content)
  64778. * @param width defines the new width
  64779. * @param height defines the new height
  64780. * @param depth defines the new depth (1 by default)
  64781. */
  64782. updateSize(width: int, height: int, depth?: int): void;
  64783. /** @hidden */
  64784. _rebuild(): void;
  64785. /** @hidden */
  64786. _swapAndDie(target: InternalTexture): void;
  64787. /**
  64788. * Dispose the current allocated resources
  64789. */
  64790. dispose(): void;
  64791. }
  64792. }
  64793. declare module BABYLON {
  64794. /**
  64795. * This represents the main contract an easing function should follow.
  64796. * Easing functions are used throughout the animation system.
  64797. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64798. */
  64799. export interface IEasingFunction {
  64800. /**
  64801. * Given an input gradient between 0 and 1, this returns the corrseponding value
  64802. * of the easing function.
  64803. * The link below provides some of the most common examples of easing functions.
  64804. * @see https://easings.net/
  64805. * @param gradient Defines the value between 0 and 1 we want the easing value for
  64806. * @returns the corresponding value on the curve defined by the easing function
  64807. */
  64808. ease(gradient: number): number;
  64809. }
  64810. /**
  64811. * Base class used for every default easing function.
  64812. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64813. */
  64814. export class EasingFunction implements IEasingFunction {
  64815. /**
  64816. * Interpolation follows the mathematical formula associated with the easing function.
  64817. */
  64818. static readonly EASINGMODE_EASEIN: number;
  64819. /**
  64820. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  64821. */
  64822. static readonly EASINGMODE_EASEOUT: number;
  64823. /**
  64824. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  64825. */
  64826. static readonly EASINGMODE_EASEINOUT: number;
  64827. private _easingMode;
  64828. /**
  64829. * Sets the easing mode of the current function.
  64830. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  64831. */
  64832. setEasingMode(easingMode: number): void;
  64833. /**
  64834. * Gets the current easing mode.
  64835. * @returns the easing mode
  64836. */
  64837. getEasingMode(): number;
  64838. /**
  64839. * @hidden
  64840. */
  64841. easeInCore(gradient: number): number;
  64842. /**
  64843. * Given an input gradient between 0 and 1, this returns the corrseponding value
  64844. * of the easing function.
  64845. * @param gradient Defines the value between 0 and 1 we want the easing value for
  64846. * @returns the corresponding value on the curve defined by the easing function
  64847. */
  64848. ease(gradient: number): number;
  64849. }
  64850. /**
  64851. * Easing function with a circle shape (see link below).
  64852. * @see https://easings.net/#easeInCirc
  64853. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64854. */
  64855. export class CircleEase extends EasingFunction implements IEasingFunction {
  64856. /** @hidden */
  64857. easeInCore(gradient: number): number;
  64858. }
  64859. /**
  64860. * Easing function with a ease back shape (see link below).
  64861. * @see https://easings.net/#easeInBack
  64862. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64863. */
  64864. export class BackEase extends EasingFunction implements IEasingFunction {
  64865. /** Defines the amplitude of the function */
  64866. amplitude: number;
  64867. /**
  64868. * Instantiates a back ease easing
  64869. * @see https://easings.net/#easeInBack
  64870. * @param amplitude Defines the amplitude of the function
  64871. */
  64872. constructor(
  64873. /** Defines the amplitude of the function */
  64874. amplitude?: number);
  64875. /** @hidden */
  64876. easeInCore(gradient: number): number;
  64877. }
  64878. /**
  64879. * Easing function with a bouncing shape (see link below).
  64880. * @see https://easings.net/#easeInBounce
  64881. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64882. */
  64883. export class BounceEase extends EasingFunction implements IEasingFunction {
  64884. /** Defines the number of bounces */
  64885. bounces: number;
  64886. /** Defines the amplitude of the bounce */
  64887. bounciness: number;
  64888. /**
  64889. * Instantiates a bounce easing
  64890. * @see https://easings.net/#easeInBounce
  64891. * @param bounces Defines the number of bounces
  64892. * @param bounciness Defines the amplitude of the bounce
  64893. */
  64894. constructor(
  64895. /** Defines the number of bounces */
  64896. bounces?: number,
  64897. /** Defines the amplitude of the bounce */
  64898. bounciness?: number);
  64899. /** @hidden */
  64900. easeInCore(gradient: number): number;
  64901. }
  64902. /**
  64903. * Easing function with a power of 3 shape (see link below).
  64904. * @see https://easings.net/#easeInCubic
  64905. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64906. */
  64907. export class CubicEase extends EasingFunction implements IEasingFunction {
  64908. /** @hidden */
  64909. easeInCore(gradient: number): number;
  64910. }
  64911. /**
  64912. * Easing function with an elastic shape (see link below).
  64913. * @see https://easings.net/#easeInElastic
  64914. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64915. */
  64916. export class ElasticEase extends EasingFunction implements IEasingFunction {
  64917. /** Defines the number of oscillations*/
  64918. oscillations: number;
  64919. /** Defines the amplitude of the oscillations*/
  64920. springiness: number;
  64921. /**
  64922. * Instantiates an elastic easing function
  64923. * @see https://easings.net/#easeInElastic
  64924. * @param oscillations Defines the number of oscillations
  64925. * @param springiness Defines the amplitude of the oscillations
  64926. */
  64927. constructor(
  64928. /** Defines the number of oscillations*/
  64929. oscillations?: number,
  64930. /** Defines the amplitude of the oscillations*/
  64931. springiness?: number);
  64932. /** @hidden */
  64933. easeInCore(gradient: number): number;
  64934. }
  64935. /**
  64936. * Easing function with an exponential shape (see link below).
  64937. * @see https://easings.net/#easeInExpo
  64938. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64939. */
  64940. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  64941. /** Defines the exponent of the function */
  64942. exponent: number;
  64943. /**
  64944. * Instantiates an exponential easing function
  64945. * @see https://easings.net/#easeInExpo
  64946. * @param exponent Defines the exponent of the function
  64947. */
  64948. constructor(
  64949. /** Defines the exponent of the function */
  64950. exponent?: number);
  64951. /** @hidden */
  64952. easeInCore(gradient: number): number;
  64953. }
  64954. /**
  64955. * Easing function with a power shape (see link below).
  64956. * @see https://easings.net/#easeInQuad
  64957. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64958. */
  64959. export class PowerEase extends EasingFunction implements IEasingFunction {
  64960. /** Defines the power of the function */
  64961. power: number;
  64962. /**
  64963. * Instantiates an power base easing function
  64964. * @see https://easings.net/#easeInQuad
  64965. * @param power Defines the power of the function
  64966. */
  64967. constructor(
  64968. /** Defines the power of the function */
  64969. power?: number);
  64970. /** @hidden */
  64971. easeInCore(gradient: number): number;
  64972. }
  64973. /**
  64974. * Easing function with a power of 2 shape (see link below).
  64975. * @see https://easings.net/#easeInQuad
  64976. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64977. */
  64978. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  64979. /** @hidden */
  64980. easeInCore(gradient: number): number;
  64981. }
  64982. /**
  64983. * Easing function with a power of 4 shape (see link below).
  64984. * @see https://easings.net/#easeInQuart
  64985. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64986. */
  64987. export class QuarticEase extends EasingFunction implements IEasingFunction {
  64988. /** @hidden */
  64989. easeInCore(gradient: number): number;
  64990. }
  64991. /**
  64992. * Easing function with a power of 5 shape (see link below).
  64993. * @see https://easings.net/#easeInQuint
  64994. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  64995. */
  64996. export class QuinticEase extends EasingFunction implements IEasingFunction {
  64997. /** @hidden */
  64998. easeInCore(gradient: number): number;
  64999. }
  65000. /**
  65001. * Easing function with a sin shape (see link below).
  65002. * @see https://easings.net/#easeInSine
  65003. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65004. */
  65005. export class SineEase extends EasingFunction implements IEasingFunction {
  65006. /** @hidden */
  65007. easeInCore(gradient: number): number;
  65008. }
  65009. /**
  65010. * Easing function with a bezier shape (see link below).
  65011. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  65012. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65013. */
  65014. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  65015. /** Defines the x component of the start tangent in the bezier curve */
  65016. x1: number;
  65017. /** Defines the y component of the start tangent in the bezier curve */
  65018. y1: number;
  65019. /** Defines the x component of the end tangent in the bezier curve */
  65020. x2: number;
  65021. /** Defines the y component of the end tangent in the bezier curve */
  65022. y2: number;
  65023. /**
  65024. * Instantiates a bezier function
  65025. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  65026. * @param x1 Defines the x component of the start tangent in the bezier curve
  65027. * @param y1 Defines the y component of the start tangent in the bezier curve
  65028. * @param x2 Defines the x component of the end tangent in the bezier curve
  65029. * @param y2 Defines the y component of the end tangent in the bezier curve
  65030. */
  65031. constructor(
  65032. /** Defines the x component of the start tangent in the bezier curve */
  65033. x1?: number,
  65034. /** Defines the y component of the start tangent in the bezier curve */
  65035. y1?: number,
  65036. /** Defines the x component of the end tangent in the bezier curve */
  65037. x2?: number,
  65038. /** Defines the y component of the end tangent in the bezier curve */
  65039. y2?: number);
  65040. /** @hidden */
  65041. easeInCore(gradient: number): number;
  65042. }
  65043. }
  65044. declare module BABYLON {
  65045. /**
  65046. * Defines an interface which represents an animation key frame
  65047. */
  65048. export interface IAnimationKey {
  65049. /**
  65050. * Frame of the key frame
  65051. */
  65052. frame: number;
  65053. /**
  65054. * Value at the specifies key frame
  65055. */
  65056. value: any;
  65057. /**
  65058. * The input tangent for the cubic hermite spline
  65059. */
  65060. inTangent?: any;
  65061. /**
  65062. * The output tangent for the cubic hermite spline
  65063. */
  65064. outTangent?: any;
  65065. /**
  65066. * The animation interpolation type
  65067. */
  65068. interpolation?: AnimationKeyInterpolation;
  65069. }
  65070. /**
  65071. * Enum for the animation key frame interpolation type
  65072. */
  65073. export enum AnimationKeyInterpolation {
  65074. /**
  65075. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  65076. */
  65077. STEP = 1
  65078. }
  65079. }
  65080. declare module BABYLON {
  65081. /**
  65082. * Represents the range of an animation
  65083. */
  65084. export class AnimationRange {
  65085. /**The name of the animation range**/
  65086. name: string;
  65087. /**The starting frame of the animation */
  65088. from: number;
  65089. /**The ending frame of the animation*/
  65090. to: number;
  65091. /**
  65092. * Initializes the range of an animation
  65093. * @param name The name of the animation range
  65094. * @param from The starting frame of the animation
  65095. * @param to The ending frame of the animation
  65096. */
  65097. constructor(
  65098. /**The name of the animation range**/
  65099. name: string,
  65100. /**The starting frame of the animation */
  65101. from: number,
  65102. /**The ending frame of the animation*/
  65103. to: number);
  65104. /**
  65105. * Makes a copy of the animation range
  65106. * @returns A copy of the animation range
  65107. */
  65108. clone(): AnimationRange;
  65109. }
  65110. }
  65111. declare module BABYLON {
  65112. /**
  65113. * Composed of a frame, and an action function
  65114. */
  65115. export class AnimationEvent {
  65116. /** The frame for which the event is triggered **/
  65117. frame: number;
  65118. /** The event to perform when triggered **/
  65119. action: (currentFrame: number) => void;
  65120. /** Specifies if the event should be triggered only once**/
  65121. onlyOnce?: boolean | undefined;
  65122. /**
  65123. * Specifies if the animation event is done
  65124. */
  65125. isDone: boolean;
  65126. /**
  65127. * Initializes the animation event
  65128. * @param frame The frame for which the event is triggered
  65129. * @param action The event to perform when triggered
  65130. * @param onlyOnce Specifies if the event should be triggered only once
  65131. */
  65132. constructor(
  65133. /** The frame for which the event is triggered **/
  65134. frame: number,
  65135. /** The event to perform when triggered **/
  65136. action: (currentFrame: number) => void,
  65137. /** Specifies if the event should be triggered only once**/
  65138. onlyOnce?: boolean | undefined);
  65139. /** @hidden */
  65140. _clone(): AnimationEvent;
  65141. }
  65142. }
  65143. declare module BABYLON {
  65144. /**
  65145. * Interface used to define a behavior
  65146. */
  65147. export interface Behavior<T> {
  65148. /** gets or sets behavior's name */
  65149. name: string;
  65150. /**
  65151. * Function called when the behavior needs to be initialized (after attaching it to a target)
  65152. */
  65153. init(): void;
  65154. /**
  65155. * Called when the behavior is attached to a target
  65156. * @param target defines the target where the behavior is attached to
  65157. */
  65158. attach(target: T): void;
  65159. /**
  65160. * Called when the behavior is detached from its target
  65161. */
  65162. detach(): void;
  65163. }
  65164. /**
  65165. * Interface implemented by classes supporting behaviors
  65166. */
  65167. export interface IBehaviorAware<T> {
  65168. /**
  65169. * Attach a behavior
  65170. * @param behavior defines the behavior to attach
  65171. * @returns the current host
  65172. */
  65173. addBehavior(behavior: Behavior<T>): T;
  65174. /**
  65175. * Remove a behavior from the current object
  65176. * @param behavior defines the behavior to detach
  65177. * @returns the current host
  65178. */
  65179. removeBehavior(behavior: Behavior<T>): T;
  65180. /**
  65181. * Gets a behavior using its name to search
  65182. * @param name defines the name to search
  65183. * @returns the behavior or null if not found
  65184. */
  65185. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  65186. }
  65187. }
  65188. declare module BABYLON {
  65189. /**
  65190. * @hidden
  65191. */
  65192. export class IntersectionInfo {
  65193. bu: Nullable<number>;
  65194. bv: Nullable<number>;
  65195. distance: number;
  65196. faceId: number;
  65197. subMeshId: number;
  65198. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  65199. }
  65200. }
  65201. declare module BABYLON {
  65202. /**
  65203. * Class used to store bounding sphere information
  65204. */
  65205. export class BoundingSphere {
  65206. /**
  65207. * Gets the center of the bounding sphere in local space
  65208. */
  65209. readonly center: Vector3;
  65210. /**
  65211. * Radius of the bounding sphere in local space
  65212. */
  65213. radius: number;
  65214. /**
  65215. * Gets the center of the bounding sphere in world space
  65216. */
  65217. readonly centerWorld: Vector3;
  65218. /**
  65219. * Radius of the bounding sphere in world space
  65220. */
  65221. radiusWorld: number;
  65222. /**
  65223. * Gets the minimum vector in local space
  65224. */
  65225. readonly minimum: Vector3;
  65226. /**
  65227. * Gets the maximum vector in local space
  65228. */
  65229. readonly maximum: Vector3;
  65230. private _worldMatrix;
  65231. private static readonly TmpVector3;
  65232. /**
  65233. * Creates a new bounding sphere
  65234. * @param min defines the minimum vector (in local space)
  65235. * @param max defines the maximum vector (in local space)
  65236. * @param worldMatrix defines the new world matrix
  65237. */
  65238. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65239. /**
  65240. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  65241. * @param min defines the new minimum vector (in local space)
  65242. * @param max defines the new maximum vector (in local space)
  65243. * @param worldMatrix defines the new world matrix
  65244. */
  65245. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  65246. /**
  65247. * Scale the current bounding sphere by applying a scale factor
  65248. * @param factor defines the scale factor to apply
  65249. * @returns the current bounding box
  65250. */
  65251. scale(factor: number): BoundingSphere;
  65252. /**
  65253. * Gets the world matrix of the bounding box
  65254. * @returns a matrix
  65255. */
  65256. getWorldMatrix(): DeepImmutable<Matrix>;
  65257. /** @hidden */
  65258. _update(worldMatrix: DeepImmutable<Matrix>): void;
  65259. /**
  65260. * Tests if the bounding sphere is intersecting the frustum planes
  65261. * @param frustumPlanes defines the frustum planes to test
  65262. * @returns true if there is an intersection
  65263. */
  65264. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65265. /**
  65266. * Tests if the bounding sphere center is in between the frustum planes.
  65267. * Used for optimistic fast inclusion.
  65268. * @param frustumPlanes defines the frustum planes to test
  65269. * @returns true if the sphere center is in between the frustum planes
  65270. */
  65271. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65272. /**
  65273. * Tests if a point is inside the bounding sphere
  65274. * @param point defines the point to test
  65275. * @returns true if the point is inside the bounding sphere
  65276. */
  65277. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  65278. /**
  65279. * Checks if two sphere intersct
  65280. * @param sphere0 sphere 0
  65281. * @param sphere1 sphere 1
  65282. * @returns true if the speres intersect
  65283. */
  65284. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  65285. }
  65286. }
  65287. declare module BABYLON {
  65288. /**
  65289. * Class used to store bounding box information
  65290. */
  65291. export class BoundingBox implements ICullable {
  65292. /**
  65293. * Gets the 8 vectors representing the bounding box in local space
  65294. */
  65295. readonly vectors: Vector3[];
  65296. /**
  65297. * Gets the center of the bounding box in local space
  65298. */
  65299. readonly center: Vector3;
  65300. /**
  65301. * Gets the center of the bounding box in world space
  65302. */
  65303. readonly centerWorld: Vector3;
  65304. /**
  65305. * Gets the extend size in local space
  65306. */
  65307. readonly extendSize: Vector3;
  65308. /**
  65309. * Gets the extend size in world space
  65310. */
  65311. readonly extendSizeWorld: Vector3;
  65312. /**
  65313. * Gets the OBB (object bounding box) directions
  65314. */
  65315. readonly directions: Vector3[];
  65316. /**
  65317. * Gets the 8 vectors representing the bounding box in world space
  65318. */
  65319. readonly vectorsWorld: Vector3[];
  65320. /**
  65321. * Gets the minimum vector in world space
  65322. */
  65323. readonly minimumWorld: Vector3;
  65324. /**
  65325. * Gets the maximum vector in world space
  65326. */
  65327. readonly maximumWorld: Vector3;
  65328. /**
  65329. * Gets the minimum vector in local space
  65330. */
  65331. readonly minimum: Vector3;
  65332. /**
  65333. * Gets the maximum vector in local space
  65334. */
  65335. readonly maximum: Vector3;
  65336. private _worldMatrix;
  65337. private static readonly TmpVector3;
  65338. /**
  65339. * @hidden
  65340. */
  65341. _tag: number;
  65342. /**
  65343. * Creates a new bounding box
  65344. * @param min defines the minimum vector (in local space)
  65345. * @param max defines the maximum vector (in local space)
  65346. * @param worldMatrix defines the new world matrix
  65347. */
  65348. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65349. /**
  65350. * Recreates the entire bounding box from scratch as if we call the constructor in place
  65351. * @param min defines the new minimum vector (in local space)
  65352. * @param max defines the new maximum vector (in local space)
  65353. * @param worldMatrix defines the new world matrix
  65354. */
  65355. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  65356. /**
  65357. * Scale the current bounding box by applying a scale factor
  65358. * @param factor defines the scale factor to apply
  65359. * @returns the current bounding box
  65360. */
  65361. scale(factor: number): BoundingBox;
  65362. /**
  65363. * Gets the world matrix of the bounding box
  65364. * @returns a matrix
  65365. */
  65366. getWorldMatrix(): DeepImmutable<Matrix>;
  65367. /** @hidden */
  65368. _update(world: DeepImmutable<Matrix>): void;
  65369. /**
  65370. * Tests if the bounding box is intersecting the frustum planes
  65371. * @param frustumPlanes defines the frustum planes to test
  65372. * @returns true if there is an intersection
  65373. */
  65374. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65375. /**
  65376. * Tests if the bounding box is entirely inside the frustum planes
  65377. * @param frustumPlanes defines the frustum planes to test
  65378. * @returns true if there is an inclusion
  65379. */
  65380. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65381. /**
  65382. * Tests if a point is inside the bounding box
  65383. * @param point defines the point to test
  65384. * @returns true if the point is inside the bounding box
  65385. */
  65386. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  65387. /**
  65388. * Tests if the bounding box intersects with a bounding sphere
  65389. * @param sphere defines the sphere to test
  65390. * @returns true if there is an intersection
  65391. */
  65392. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  65393. /**
  65394. * Tests if the bounding box intersects with a box defined by a min and max vectors
  65395. * @param min defines the min vector to use
  65396. * @param max defines the max vector to use
  65397. * @returns true if there is an intersection
  65398. */
  65399. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  65400. /**
  65401. * Tests if two bounding boxes are intersections
  65402. * @param box0 defines the first box to test
  65403. * @param box1 defines the second box to test
  65404. * @returns true if there is an intersection
  65405. */
  65406. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  65407. /**
  65408. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  65409. * @param minPoint defines the minimum vector of the bounding box
  65410. * @param maxPoint defines the maximum vector of the bounding box
  65411. * @param sphereCenter defines the sphere center
  65412. * @param sphereRadius defines the sphere radius
  65413. * @returns true if there is an intersection
  65414. */
  65415. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  65416. /**
  65417. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  65418. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  65419. * @param frustumPlanes defines the frustum planes to test
  65420. * @return true if there is an inclusion
  65421. */
  65422. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65423. /**
  65424. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  65425. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  65426. * @param frustumPlanes defines the frustum planes to test
  65427. * @return true if there is an intersection
  65428. */
  65429. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65430. }
  65431. }
  65432. declare module BABYLON {
  65433. /** @hidden */
  65434. export class Collider {
  65435. /** Define if a collision was found */
  65436. collisionFound: boolean;
  65437. /**
  65438. * Define last intersection point in local space
  65439. */
  65440. intersectionPoint: Vector3;
  65441. /**
  65442. * Define last collided mesh
  65443. */
  65444. collidedMesh: Nullable<AbstractMesh>;
  65445. private _collisionPoint;
  65446. private _planeIntersectionPoint;
  65447. private _tempVector;
  65448. private _tempVector2;
  65449. private _tempVector3;
  65450. private _tempVector4;
  65451. private _edge;
  65452. private _baseToVertex;
  65453. private _destinationPoint;
  65454. private _slidePlaneNormal;
  65455. private _displacementVector;
  65456. /** @hidden */
  65457. _radius: Vector3;
  65458. /** @hidden */
  65459. _retry: number;
  65460. private _velocity;
  65461. private _basePoint;
  65462. private _epsilon;
  65463. /** @hidden */
  65464. _velocityWorldLength: number;
  65465. /** @hidden */
  65466. _basePointWorld: Vector3;
  65467. private _velocityWorld;
  65468. private _normalizedVelocity;
  65469. /** @hidden */
  65470. _initialVelocity: Vector3;
  65471. /** @hidden */
  65472. _initialPosition: Vector3;
  65473. private _nearestDistance;
  65474. private _collisionMask;
  65475. collisionMask: number;
  65476. /**
  65477. * Gets the plane normal used to compute the sliding response (in local space)
  65478. */
  65479. readonly slidePlaneNormal: Vector3;
  65480. /** @hidden */
  65481. _initialize(source: Vector3, dir: Vector3, e: number): void;
  65482. /** @hidden */
  65483. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  65484. /** @hidden */
  65485. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  65486. /** @hidden */
  65487. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  65488. /** @hidden */
  65489. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  65490. /** @hidden */
  65491. _getResponse(pos: Vector3, vel: Vector3): void;
  65492. }
  65493. }
  65494. declare module BABYLON {
  65495. /**
  65496. * Interface for cullable objects
  65497. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  65498. */
  65499. export interface ICullable {
  65500. /**
  65501. * Checks if the object or part of the object is in the frustum
  65502. * @param frustumPlanes Camera near/planes
  65503. * @returns true if the object is in frustum otherwise false
  65504. */
  65505. isInFrustum(frustumPlanes: Plane[]): boolean;
  65506. /**
  65507. * Checks if a cullable object (mesh...) is in the camera frustum
  65508. * Unlike isInFrustum this cheks the full bounding box
  65509. * @param frustumPlanes Camera near/planes
  65510. * @returns true if the object is in frustum otherwise false
  65511. */
  65512. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  65513. }
  65514. /**
  65515. * Info for a bounding data of a mesh
  65516. */
  65517. export class BoundingInfo implements ICullable {
  65518. /**
  65519. * Bounding box for the mesh
  65520. */
  65521. readonly boundingBox: BoundingBox;
  65522. /**
  65523. * Bounding sphere for the mesh
  65524. */
  65525. readonly boundingSphere: BoundingSphere;
  65526. private _isLocked;
  65527. private static readonly TmpVector3;
  65528. /**
  65529. * Constructs bounding info
  65530. * @param minimum min vector of the bounding box/sphere
  65531. * @param maximum max vector of the bounding box/sphere
  65532. * @param worldMatrix defines the new world matrix
  65533. */
  65534. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  65535. /**
  65536. * Recreates the entire bounding info from scratch as if we call the constructor in place
  65537. * @param min defines the new minimum vector (in local space)
  65538. * @param max defines the new maximum vector (in local space)
  65539. * @param worldMatrix defines the new world matrix
  65540. */
  65541. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  65542. /**
  65543. * min vector of the bounding box/sphere
  65544. */
  65545. readonly minimum: Vector3;
  65546. /**
  65547. * max vector of the bounding box/sphere
  65548. */
  65549. readonly maximum: Vector3;
  65550. /**
  65551. * If the info is locked and won't be updated to avoid perf overhead
  65552. */
  65553. isLocked: boolean;
  65554. /**
  65555. * Updates the bounding sphere and box
  65556. * @param world world matrix to be used to update
  65557. */
  65558. update(world: DeepImmutable<Matrix>): void;
  65559. /**
  65560. * Recreate the bounding info to be centered around a specific point given a specific extend.
  65561. * @param center New center of the bounding info
  65562. * @param extend New extend of the bounding info
  65563. * @returns the current bounding info
  65564. */
  65565. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  65566. /**
  65567. * Scale the current bounding info by applying a scale factor
  65568. * @param factor defines the scale factor to apply
  65569. * @returns the current bounding info
  65570. */
  65571. scale(factor: number): BoundingInfo;
  65572. /**
  65573. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  65574. * @param frustumPlanes defines the frustum to test
  65575. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  65576. * @returns true if the bounding info is in the frustum planes
  65577. */
  65578. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  65579. /**
  65580. * Gets the world distance between the min and max points of the bounding box
  65581. */
  65582. readonly diagonalLength: number;
  65583. /**
  65584. * Checks if a cullable object (mesh...) is in the camera frustum
  65585. * Unlike isInFrustum this cheks the full bounding box
  65586. * @param frustumPlanes Camera near/planes
  65587. * @returns true if the object is in frustum otherwise false
  65588. */
  65589. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  65590. /** @hidden */
  65591. _checkCollision(collider: Collider): boolean;
  65592. /**
  65593. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  65594. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  65595. * @param point the point to check intersection with
  65596. * @returns if the point intersects
  65597. */
  65598. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  65599. /**
  65600. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  65601. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  65602. * @param boundingInfo the bounding info to check intersection with
  65603. * @param precise if the intersection should be done using OBB
  65604. * @returns if the bounding info intersects
  65605. */
  65606. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  65607. }
  65608. }
  65609. declare module BABYLON {
  65610. /**
  65611. * Defines an array and its length.
  65612. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  65613. */
  65614. export interface ISmartArrayLike<T> {
  65615. /**
  65616. * The data of the array.
  65617. */
  65618. data: Array<T>;
  65619. /**
  65620. * The active length of the array.
  65621. */
  65622. length: number;
  65623. }
  65624. /**
  65625. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  65626. */
  65627. export class SmartArray<T> implements ISmartArrayLike<T> {
  65628. /**
  65629. * The full set of data from the array.
  65630. */
  65631. data: Array<T>;
  65632. /**
  65633. * The active length of the array.
  65634. */
  65635. length: number;
  65636. protected _id: number;
  65637. /**
  65638. * Instantiates a Smart Array.
  65639. * @param capacity defines the default capacity of the array.
  65640. */
  65641. constructor(capacity: number);
  65642. /**
  65643. * Pushes a value at the end of the active data.
  65644. * @param value defines the object to push in the array.
  65645. */
  65646. push(value: T): void;
  65647. /**
  65648. * Iterates over the active data and apply the lambda to them.
  65649. * @param func defines the action to apply on each value.
  65650. */
  65651. forEach(func: (content: T) => void): void;
  65652. /**
  65653. * Sorts the full sets of data.
  65654. * @param compareFn defines the comparison function to apply.
  65655. */
  65656. sort(compareFn: (a: T, b: T) => number): void;
  65657. /**
  65658. * Resets the active data to an empty array.
  65659. */
  65660. reset(): void;
  65661. /**
  65662. * Releases all the data from the array as well as the array.
  65663. */
  65664. dispose(): void;
  65665. /**
  65666. * Concats the active data with a given array.
  65667. * @param array defines the data to concatenate with.
  65668. */
  65669. concat(array: any): void;
  65670. /**
  65671. * Returns the position of a value in the active data.
  65672. * @param value defines the value to find the index for
  65673. * @returns the index if found in the active data otherwise -1
  65674. */
  65675. indexOf(value: T): number;
  65676. /**
  65677. * Returns whether an element is part of the active data.
  65678. * @param value defines the value to look for
  65679. * @returns true if found in the active data otherwise false
  65680. */
  65681. contains(value: T): boolean;
  65682. private static _GlobalId;
  65683. }
  65684. /**
  65685. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  65686. * The data in this array can only be present once
  65687. */
  65688. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  65689. private _duplicateId;
  65690. /**
  65691. * Pushes a value at the end of the active data.
  65692. * THIS DOES NOT PREVENT DUPPLICATE DATA
  65693. * @param value defines the object to push in the array.
  65694. */
  65695. push(value: T): void;
  65696. /**
  65697. * Pushes a value at the end of the active data.
  65698. * If the data is already present, it won t be added again
  65699. * @param value defines the object to push in the array.
  65700. * @returns true if added false if it was already present
  65701. */
  65702. pushNoDuplicate(value: T): boolean;
  65703. /**
  65704. * Resets the active data to an empty array.
  65705. */
  65706. reset(): void;
  65707. /**
  65708. * Concats the active data with a given array.
  65709. * This ensures no dupplicate will be present in the result.
  65710. * @param array defines the data to concatenate with.
  65711. */
  65712. concatWithNoDuplicate(array: any): void;
  65713. }
  65714. }
  65715. declare module BABYLON {
  65716. /**
  65717. * A multi-material is used to apply different materials to different parts of the same object without the need of
  65718. * separate meshes. This can be use to improve performances.
  65719. * @see http://doc.babylonjs.com/how_to/multi_materials
  65720. */
  65721. export class MultiMaterial extends Material {
  65722. private _subMaterials;
  65723. /**
  65724. * Gets or Sets the list of Materials used within the multi material.
  65725. * They need to be ordered according to the submeshes order in the associated mesh
  65726. */
  65727. subMaterials: Nullable<Material>[];
  65728. /**
  65729. * Function used to align with Node.getChildren()
  65730. * @returns the list of Materials used within the multi material
  65731. */
  65732. getChildren(): Nullable<Material>[];
  65733. /**
  65734. * Instantiates a new Multi Material
  65735. * A multi-material is used to apply different materials to different parts of the same object without the need of
  65736. * separate meshes. This can be use to improve performances.
  65737. * @see http://doc.babylonjs.com/how_to/multi_materials
  65738. * @param name Define the name in the scene
  65739. * @param scene Define the scene the material belongs to
  65740. */
  65741. constructor(name: string, scene: Scene);
  65742. private _hookArray;
  65743. /**
  65744. * Get one of the submaterial by its index in the submaterials array
  65745. * @param index The index to look the sub material at
  65746. * @returns The Material if the index has been defined
  65747. */
  65748. getSubMaterial(index: number): Nullable<Material>;
  65749. /**
  65750. * Get the list of active textures for the whole sub materials list.
  65751. * @returns All the textures that will be used during the rendering
  65752. */
  65753. getActiveTextures(): BaseTexture[];
  65754. /**
  65755. * Gets the current class name of the material e.g. "MultiMaterial"
  65756. * Mainly use in serialization.
  65757. * @returns the class name
  65758. */
  65759. getClassName(): string;
  65760. /**
  65761. * Checks if the material is ready to render the requested sub mesh
  65762. * @param mesh Define the mesh the submesh belongs to
  65763. * @param subMesh Define the sub mesh to look readyness for
  65764. * @param useInstances Define whether or not the material is used with instances
  65765. * @returns true if ready, otherwise false
  65766. */
  65767. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  65768. /**
  65769. * Clones the current material and its related sub materials
  65770. * @param name Define the name of the newly cloned material
  65771. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  65772. * @returns the cloned material
  65773. */
  65774. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  65775. /**
  65776. * Serializes the materials into a JSON representation.
  65777. * @returns the JSON representation
  65778. */
  65779. serialize(): any;
  65780. /**
  65781. * Dispose the material and release its associated resources
  65782. * @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)
  65783. * @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)
  65784. * @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)
  65785. */
  65786. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  65787. /**
  65788. * Creates a MultiMaterial from parsed MultiMaterial data.
  65789. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  65790. * @param scene defines the hosting scene
  65791. * @returns a new MultiMaterial
  65792. */
  65793. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  65794. }
  65795. }
  65796. declare module BABYLON {
  65797. /**
  65798. * Class used to represent data loading progression
  65799. */
  65800. export class SceneLoaderFlags {
  65801. private static _ForceFullSceneLoadingForIncremental;
  65802. private static _ShowLoadingScreen;
  65803. private static _CleanBoneMatrixWeights;
  65804. private static _loggingLevel;
  65805. /**
  65806. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  65807. */
  65808. static ForceFullSceneLoadingForIncremental: boolean;
  65809. /**
  65810. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  65811. */
  65812. static ShowLoadingScreen: boolean;
  65813. /**
  65814. * Defines the current logging level (while loading the scene)
  65815. * @ignorenaming
  65816. */
  65817. static loggingLevel: number;
  65818. /**
  65819. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  65820. */
  65821. static CleanBoneMatrixWeights: boolean;
  65822. }
  65823. }
  65824. declare module BABYLON {
  65825. /**
  65826. * 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.
  65827. * @see https://doc.babylonjs.com/how_to/transformnode
  65828. */
  65829. export class TransformNode extends Node {
  65830. /**
  65831. * Object will not rotate to face the camera
  65832. */
  65833. static BILLBOARDMODE_NONE: number;
  65834. /**
  65835. * Object will rotate to face the camera but only on the x axis
  65836. */
  65837. static BILLBOARDMODE_X: number;
  65838. /**
  65839. * Object will rotate to face the camera but only on the y axis
  65840. */
  65841. static BILLBOARDMODE_Y: number;
  65842. /**
  65843. * Object will rotate to face the camera but only on the z axis
  65844. */
  65845. static BILLBOARDMODE_Z: number;
  65846. /**
  65847. * Object will rotate to face the camera
  65848. */
  65849. static BILLBOARDMODE_ALL: number;
  65850. private _forward;
  65851. private _forwardInverted;
  65852. private _up;
  65853. private _right;
  65854. private _rightInverted;
  65855. private _position;
  65856. private _rotation;
  65857. private _rotationQuaternion;
  65858. protected _scaling: Vector3;
  65859. protected _isDirty: boolean;
  65860. private _transformToBoneReferal;
  65861. /**
  65862. * Set the billboard mode. Default is 0.
  65863. *
  65864. * | Value | Type | Description |
  65865. * | --- | --- | --- |
  65866. * | 0 | BILLBOARDMODE_NONE | |
  65867. * | 1 | BILLBOARDMODE_X | |
  65868. * | 2 | BILLBOARDMODE_Y | |
  65869. * | 4 | BILLBOARDMODE_Z | |
  65870. * | 7 | BILLBOARDMODE_ALL | |
  65871. *
  65872. */
  65873. billboardMode: number;
  65874. /**
  65875. * 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
  65876. */
  65877. scalingDeterminant: number;
  65878. /**
  65879. * Sets the distance of the object to max, often used by skybox
  65880. */
  65881. infiniteDistance: boolean;
  65882. /**
  65883. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  65884. * By default the system will update normals to compensate
  65885. */
  65886. ignoreNonUniformScaling: boolean;
  65887. /** @hidden */
  65888. _poseMatrix: Matrix;
  65889. /** @hidden */
  65890. _localMatrix: Matrix;
  65891. private _absolutePosition;
  65892. private _pivotMatrix;
  65893. private _pivotMatrixInverse;
  65894. protected _postMultiplyPivotMatrix: boolean;
  65895. private _tempMatrix;
  65896. private _tempMatrix2;
  65897. protected _isWorldMatrixFrozen: boolean;
  65898. /** @hidden */
  65899. _indexInSceneTransformNodesArray: number;
  65900. /**
  65901. * An event triggered after the world matrix is updated
  65902. */
  65903. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  65904. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  65905. /**
  65906. * Gets a string identifying the name of the class
  65907. * @returns "TransformNode" string
  65908. */
  65909. getClassName(): string;
  65910. /**
  65911. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  65912. */
  65913. position: Vector3;
  65914. /**
  65915. * 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)).
  65916. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  65917. */
  65918. rotation: Vector3;
  65919. /**
  65920. * 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)).
  65921. */
  65922. scaling: Vector3;
  65923. /**
  65924. * 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).
  65925. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  65926. */
  65927. rotationQuaternion: Nullable<Quaternion>;
  65928. /**
  65929. * The forward direction of that transform in world space.
  65930. */
  65931. readonly forward: Vector3;
  65932. /**
  65933. * The up direction of that transform in world space.
  65934. */
  65935. readonly up: Vector3;
  65936. /**
  65937. * The right direction of that transform in world space.
  65938. */
  65939. readonly right: Vector3;
  65940. /**
  65941. * Copies the parameter passed Matrix into the mesh Pose matrix.
  65942. * @param matrix the matrix to copy the pose from
  65943. * @returns this TransformNode.
  65944. */
  65945. updatePoseMatrix(matrix: Matrix): TransformNode;
  65946. /**
  65947. * Returns the mesh Pose matrix.
  65948. * @returns the pose matrix
  65949. */
  65950. getPoseMatrix(): Matrix;
  65951. /** @hidden */
  65952. _isSynchronized(): boolean;
  65953. /** @hidden */
  65954. _initCache(): void;
  65955. /**
  65956. * Flag the transform node as dirty (Forcing it to update everything)
  65957. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  65958. * @returns this transform node
  65959. */
  65960. markAsDirty(property: string): TransformNode;
  65961. /**
  65962. * Returns the current mesh absolute position.
  65963. * Returns a Vector3.
  65964. */
  65965. readonly absolutePosition: Vector3;
  65966. /**
  65967. * Sets a new matrix to apply before all other transformation
  65968. * @param matrix defines the transform matrix
  65969. * @returns the current TransformNode
  65970. */
  65971. setPreTransformMatrix(matrix: Matrix): TransformNode;
  65972. /**
  65973. * Sets a new pivot matrix to the current node
  65974. * @param matrix defines the new pivot matrix to use
  65975. * @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
  65976. * @returns the current TransformNode
  65977. */
  65978. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  65979. /**
  65980. * Returns the mesh pivot matrix.
  65981. * Default : Identity.
  65982. * @returns the matrix
  65983. */
  65984. getPivotMatrix(): Matrix;
  65985. /**
  65986. * Prevents the World matrix to be computed any longer.
  65987. * @returns the TransformNode.
  65988. */
  65989. freezeWorldMatrix(): TransformNode;
  65990. /**
  65991. * Allows back the World matrix computation.
  65992. * @returns the TransformNode.
  65993. */
  65994. unfreezeWorldMatrix(): this;
  65995. /**
  65996. * True if the World matrix has been frozen.
  65997. */
  65998. readonly isWorldMatrixFrozen: boolean;
  65999. /**
  66000. * Retuns the mesh absolute position in the World.
  66001. * @returns a Vector3.
  66002. */
  66003. getAbsolutePosition(): Vector3;
  66004. /**
  66005. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  66006. * @param absolutePosition the absolute position to set
  66007. * @returns the TransformNode.
  66008. */
  66009. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  66010. /**
  66011. * Sets the mesh position in its local space.
  66012. * @param vector3 the position to set in localspace
  66013. * @returns the TransformNode.
  66014. */
  66015. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  66016. /**
  66017. * Returns the mesh position in the local space from the current World matrix values.
  66018. * @returns a new Vector3.
  66019. */
  66020. getPositionExpressedInLocalSpace(): Vector3;
  66021. /**
  66022. * Translates the mesh along the passed Vector3 in its local space.
  66023. * @param vector3 the distance to translate in localspace
  66024. * @returns the TransformNode.
  66025. */
  66026. locallyTranslate(vector3: Vector3): TransformNode;
  66027. private static _lookAtVectorCache;
  66028. /**
  66029. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  66030. * @param targetPoint the position (must be in same space as current mesh) to look at
  66031. * @param yawCor optional yaw (y-axis) correction in radians
  66032. * @param pitchCor optional pitch (x-axis) correction in radians
  66033. * @param rollCor optional roll (z-axis) correction in radians
  66034. * @param space the choosen space of the target
  66035. * @returns the TransformNode.
  66036. */
  66037. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  66038. /**
  66039. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  66040. * This Vector3 is expressed in the World space.
  66041. * @param localAxis axis to rotate
  66042. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  66043. */
  66044. getDirection(localAxis: Vector3): Vector3;
  66045. /**
  66046. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  66047. * localAxis is expressed in the mesh local space.
  66048. * result is computed in the Wordl space from the mesh World matrix.
  66049. * @param localAxis axis to rotate
  66050. * @param result the resulting transformnode
  66051. * @returns this TransformNode.
  66052. */
  66053. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  66054. /**
  66055. * Sets this transform node rotation to the given local axis.
  66056. * @param localAxis the axis in local space
  66057. * @param yawCor optional yaw (y-axis) correction in radians
  66058. * @param pitchCor optional pitch (x-axis) correction in radians
  66059. * @param rollCor optional roll (z-axis) correction in radians
  66060. * @returns this TransformNode
  66061. */
  66062. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  66063. /**
  66064. * Sets a new pivot point to the current node
  66065. * @param point defines the new pivot point to use
  66066. * @param space defines if the point is in world or local space (local by default)
  66067. * @returns the current TransformNode
  66068. */
  66069. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  66070. /**
  66071. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  66072. * @returns the pivot point
  66073. */
  66074. getPivotPoint(): Vector3;
  66075. /**
  66076. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  66077. * @param result the vector3 to store the result
  66078. * @returns this TransformNode.
  66079. */
  66080. getPivotPointToRef(result: Vector3): TransformNode;
  66081. /**
  66082. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  66083. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  66084. */
  66085. getAbsolutePivotPoint(): Vector3;
  66086. /**
  66087. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  66088. * @param result vector3 to store the result
  66089. * @returns this TransformNode.
  66090. */
  66091. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  66092. /**
  66093. * Defines the passed node as the parent of the current node.
  66094. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  66095. * @param node the node ot set as the parent
  66096. * @returns this TransformNode.
  66097. */
  66098. setParent(node: Nullable<Node>): TransformNode;
  66099. private _nonUniformScaling;
  66100. /**
  66101. * True if the scaling property of this object is non uniform eg. (1,2,1)
  66102. */
  66103. readonly nonUniformScaling: boolean;
  66104. /** @hidden */
  66105. _updateNonUniformScalingState(value: boolean): boolean;
  66106. /**
  66107. * Attach the current TransformNode to another TransformNode associated with a bone
  66108. * @param bone Bone affecting the TransformNode
  66109. * @param affectedTransformNode TransformNode associated with the bone
  66110. * @returns this object
  66111. */
  66112. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  66113. /**
  66114. * Detach the transform node if its associated with a bone
  66115. * @returns this object
  66116. */
  66117. detachFromBone(): TransformNode;
  66118. private static _rotationAxisCache;
  66119. /**
  66120. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  66121. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  66122. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  66123. * The passed axis is also normalized.
  66124. * @param axis the axis to rotate around
  66125. * @param amount the amount to rotate in radians
  66126. * @param space Space to rotate in (Default: local)
  66127. * @returns the TransformNode.
  66128. */
  66129. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  66130. /**
  66131. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  66132. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  66133. * The passed axis is also normalized. .
  66134. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  66135. * @param point the point to rotate around
  66136. * @param axis the axis to rotate around
  66137. * @param amount the amount to rotate in radians
  66138. * @returns the TransformNode
  66139. */
  66140. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  66141. /**
  66142. * Translates the mesh along the axis vector for the passed distance in the given space.
  66143. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  66144. * @param axis the axis to translate in
  66145. * @param distance the distance to translate
  66146. * @param space Space to rotate in (Default: local)
  66147. * @returns the TransformNode.
  66148. */
  66149. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  66150. /**
  66151. * Adds a rotation step to the mesh current rotation.
  66152. * x, y, z are Euler angles expressed in radians.
  66153. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  66154. * This means this rotation is made in the mesh local space only.
  66155. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  66156. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  66157. * ```javascript
  66158. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  66159. * ```
  66160. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  66161. * 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.
  66162. * @param x Rotation to add
  66163. * @param y Rotation to add
  66164. * @param z Rotation to add
  66165. * @returns the TransformNode.
  66166. */
  66167. addRotation(x: number, y: number, z: number): TransformNode;
  66168. /**
  66169. * Computes the world matrix of the node
  66170. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  66171. * @returns the world matrix
  66172. */
  66173. computeWorldMatrix(force?: boolean): Matrix;
  66174. protected _afterComputeWorldMatrix(): void;
  66175. /**
  66176. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  66177. * @param func callback function to add
  66178. *
  66179. * @returns the TransformNode.
  66180. */
  66181. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  66182. /**
  66183. * Removes a registered callback function.
  66184. * @param func callback function to remove
  66185. * @returns the TransformNode.
  66186. */
  66187. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  66188. /**
  66189. * Gets the position of the current mesh in camera space
  66190. * @param camera defines the camera to use
  66191. * @returns a position
  66192. */
  66193. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  66194. /**
  66195. * Returns the distance from the mesh to the active camera
  66196. * @param camera defines the camera to use
  66197. * @returns the distance
  66198. */
  66199. getDistanceToCamera(camera?: Nullable<Camera>): number;
  66200. /**
  66201. * Clone the current transform node
  66202. * @param name Name of the new clone
  66203. * @param newParent New parent for the clone
  66204. * @param doNotCloneChildren Do not clone children hierarchy
  66205. * @returns the new transform node
  66206. */
  66207. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  66208. /**
  66209. * Serializes the objects information.
  66210. * @param currentSerializationObject defines the object to serialize in
  66211. * @returns the serialized object
  66212. */
  66213. serialize(currentSerializationObject?: any): any;
  66214. /**
  66215. * Returns a new TransformNode object parsed from the source provided.
  66216. * @param parsedTransformNode is the source.
  66217. * @param scene the scne the object belongs to
  66218. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  66219. * @returns a new TransformNode object parsed from the source provided.
  66220. */
  66221. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  66222. /**
  66223. * Get all child-transformNodes of this node
  66224. * @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
  66225. * @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
  66226. * @returns an array of TransformNode
  66227. */
  66228. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  66229. /**
  66230. * Releases resources associated with this transform node.
  66231. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  66232. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  66233. */
  66234. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  66235. }
  66236. }
  66237. declare module BABYLON {
  66238. /**
  66239. * Class used to override all child animations of a given target
  66240. */
  66241. export class AnimationPropertiesOverride {
  66242. /**
  66243. * Gets or sets a value indicating if animation blending must be used
  66244. */
  66245. enableBlending: boolean;
  66246. /**
  66247. * Gets or sets the blending speed to use when enableBlending is true
  66248. */
  66249. blendingSpeed: number;
  66250. /**
  66251. * Gets or sets the default loop mode to use
  66252. */
  66253. loopMode: number;
  66254. }
  66255. }
  66256. declare module BABYLON {
  66257. /**
  66258. * Class used to store bone information
  66259. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  66260. */
  66261. export class Bone extends Node {
  66262. /**
  66263. * defines the bone name
  66264. */
  66265. name: string;
  66266. private static _tmpVecs;
  66267. private static _tmpQuat;
  66268. private static _tmpMats;
  66269. /**
  66270. * Gets the list of child bones
  66271. */
  66272. children: Bone[];
  66273. /** Gets the animations associated with this bone */
  66274. animations: Animation[];
  66275. /**
  66276. * Gets or sets bone length
  66277. */
  66278. length: number;
  66279. /**
  66280. * @hidden Internal only
  66281. * Set this value to map this bone to a different index in the transform matrices
  66282. * Set this value to -1 to exclude the bone from the transform matrices
  66283. */
  66284. _index: Nullable<number>;
  66285. private _skeleton;
  66286. private _localMatrix;
  66287. private _restPose;
  66288. private _baseMatrix;
  66289. private _absoluteTransform;
  66290. private _invertedAbsoluteTransform;
  66291. private _parent;
  66292. private _scalingDeterminant;
  66293. private _worldTransform;
  66294. private _localScaling;
  66295. private _localRotation;
  66296. private _localPosition;
  66297. private _needToDecompose;
  66298. private _needToCompose;
  66299. /** @hidden */
  66300. _linkedTransformNode: Nullable<TransformNode>;
  66301. /** @hidden */
  66302. /** @hidden */
  66303. _matrix: Matrix;
  66304. /**
  66305. * Create a new bone
  66306. * @param name defines the bone name
  66307. * @param skeleton defines the parent skeleton
  66308. * @param parentBone defines the parent (can be null if the bone is the root)
  66309. * @param localMatrix defines the local matrix
  66310. * @param restPose defines the rest pose matrix
  66311. * @param baseMatrix defines the base matrix
  66312. * @param index defines index of the bone in the hiearchy
  66313. */
  66314. constructor(
  66315. /**
  66316. * defines the bone name
  66317. */
  66318. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  66319. /**
  66320. * Gets the current object class name.
  66321. * @return the class name
  66322. */
  66323. getClassName(): string;
  66324. /**
  66325. * Gets the parent skeleton
  66326. * @returns a skeleton
  66327. */
  66328. getSkeleton(): Skeleton;
  66329. /**
  66330. * Gets parent bone
  66331. * @returns a bone or null if the bone is the root of the bone hierarchy
  66332. */
  66333. getParent(): Nullable<Bone>;
  66334. /**
  66335. * Returns an array containing the root bones
  66336. * @returns an array containing the root bones
  66337. */
  66338. getChildren(): Array<Bone>;
  66339. /**
  66340. * Sets the parent bone
  66341. * @param parent defines the parent (can be null if the bone is the root)
  66342. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  66343. */
  66344. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  66345. /**
  66346. * Gets the local matrix
  66347. * @returns a matrix
  66348. */
  66349. getLocalMatrix(): Matrix;
  66350. /**
  66351. * Gets the base matrix (initial matrix which remains unchanged)
  66352. * @returns a matrix
  66353. */
  66354. getBaseMatrix(): Matrix;
  66355. /**
  66356. * Gets the rest pose matrix
  66357. * @returns a matrix
  66358. */
  66359. getRestPose(): Matrix;
  66360. /**
  66361. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  66362. */
  66363. getWorldMatrix(): Matrix;
  66364. /**
  66365. * Sets the local matrix to rest pose matrix
  66366. */
  66367. returnToRest(): void;
  66368. /**
  66369. * Gets the inverse of the absolute transform matrix.
  66370. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  66371. * @returns a matrix
  66372. */
  66373. getInvertedAbsoluteTransform(): Matrix;
  66374. /**
  66375. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  66376. * @returns a matrix
  66377. */
  66378. getAbsoluteTransform(): Matrix;
  66379. /**
  66380. * Links with the given transform node.
  66381. * The local matrix of this bone is copied from the transform node every frame.
  66382. * @param transformNode defines the transform node to link to
  66383. */
  66384. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  66385. /** Gets or sets current position (in local space) */
  66386. position: Vector3;
  66387. /** Gets or sets current rotation (in local space) */
  66388. rotation: Vector3;
  66389. /** Gets or sets current rotation quaternion (in local space) */
  66390. rotationQuaternion: Quaternion;
  66391. /** Gets or sets current scaling (in local space) */
  66392. scaling: Vector3;
  66393. /**
  66394. * Gets the animation properties override
  66395. */
  66396. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  66397. private _decompose;
  66398. private _compose;
  66399. /**
  66400. * Update the base and local matrices
  66401. * @param matrix defines the new base or local matrix
  66402. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  66403. * @param updateLocalMatrix defines if the local matrix should be updated
  66404. */
  66405. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  66406. /** @hidden */
  66407. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  66408. /**
  66409. * Flag the bone as dirty (Forcing it to update everything)
  66410. */
  66411. markAsDirty(): void;
  66412. private _markAsDirtyAndCompose;
  66413. private _markAsDirtyAndDecompose;
  66414. /**
  66415. * Translate the bone in local or world space
  66416. * @param vec The amount to translate the bone
  66417. * @param space The space that the translation is in
  66418. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66419. */
  66420. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  66421. /**
  66422. * Set the postion of the bone in local or world space
  66423. * @param position The position to set the bone
  66424. * @param space The space that the position is in
  66425. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66426. */
  66427. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  66428. /**
  66429. * Set the absolute position of the bone (world space)
  66430. * @param position The position to set the bone
  66431. * @param mesh The mesh that this bone is attached to
  66432. */
  66433. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  66434. /**
  66435. * Scale the bone on the x, y and z axes (in local space)
  66436. * @param x The amount to scale the bone on the x axis
  66437. * @param y The amount to scale the bone on the y axis
  66438. * @param z The amount to scale the bone on the z axis
  66439. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  66440. */
  66441. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  66442. /**
  66443. * Set the bone scaling in local space
  66444. * @param scale defines the scaling vector
  66445. */
  66446. setScale(scale: Vector3): void;
  66447. /**
  66448. * Gets the current scaling in local space
  66449. * @returns the current scaling vector
  66450. */
  66451. getScale(): Vector3;
  66452. /**
  66453. * Gets the current scaling in local space and stores it in a target vector
  66454. * @param result defines the target vector
  66455. */
  66456. getScaleToRef(result: Vector3): void;
  66457. /**
  66458. * Set the yaw, pitch, and roll of the bone in local or world space
  66459. * @param yaw The rotation of the bone on the y axis
  66460. * @param pitch The rotation of the bone on the x axis
  66461. * @param roll The rotation of the bone on the z axis
  66462. * @param space The space that the axes of rotation are in
  66463. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66464. */
  66465. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  66466. /**
  66467. * Add a rotation to the bone on an axis in local or world space
  66468. * @param axis The axis to rotate the bone on
  66469. * @param amount The amount to rotate the bone
  66470. * @param space The space that the axis is in
  66471. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66472. */
  66473. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  66474. /**
  66475. * Set the rotation of the bone to a particular axis angle in local or world space
  66476. * @param axis The axis to rotate the bone on
  66477. * @param angle The angle that the bone should be rotated to
  66478. * @param space The space that the axis is in
  66479. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66480. */
  66481. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  66482. /**
  66483. * Set the euler rotation of the bone in local of world space
  66484. * @param rotation The euler rotation that the bone should be set to
  66485. * @param space The space that the rotation is in
  66486. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66487. */
  66488. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  66489. /**
  66490. * Set the quaternion rotation of the bone in local of world space
  66491. * @param quat The quaternion rotation that the bone should be set to
  66492. * @param space The space that the rotation is in
  66493. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66494. */
  66495. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  66496. /**
  66497. * Set the rotation matrix of the bone in local of world space
  66498. * @param rotMat The rotation matrix that the bone should be set to
  66499. * @param space The space that the rotation is in
  66500. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66501. */
  66502. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  66503. private _rotateWithMatrix;
  66504. private _getNegativeRotationToRef;
  66505. /**
  66506. * Get the position of the bone in local or world space
  66507. * @param space The space that the returned position is in
  66508. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66509. * @returns The position of the bone
  66510. */
  66511. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  66512. /**
  66513. * Copy the position of the bone to a vector3 in local or world space
  66514. * @param space The space that the returned position is in
  66515. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66516. * @param result The vector3 to copy the position to
  66517. */
  66518. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  66519. /**
  66520. * Get the absolute position of the bone (world space)
  66521. * @param mesh The mesh that this bone is attached to
  66522. * @returns The absolute position of the bone
  66523. */
  66524. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  66525. /**
  66526. * Copy the absolute position of the bone (world space) to the result param
  66527. * @param mesh The mesh that this bone is attached to
  66528. * @param result The vector3 to copy the absolute position to
  66529. */
  66530. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  66531. /**
  66532. * Compute the absolute transforms of this bone and its children
  66533. */
  66534. computeAbsoluteTransforms(): void;
  66535. /**
  66536. * Get the world direction from an axis that is in the local space of the bone
  66537. * @param localAxis The local direction that is used to compute the world direction
  66538. * @param mesh The mesh that this bone is attached to
  66539. * @returns The world direction
  66540. */
  66541. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66542. /**
  66543. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  66544. * @param localAxis The local direction that is used to compute the world direction
  66545. * @param mesh The mesh that this bone is attached to
  66546. * @param result The vector3 that the world direction will be copied to
  66547. */
  66548. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66549. /**
  66550. * Get the euler rotation of the bone in local or world space
  66551. * @param space The space that the rotation should be in
  66552. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66553. * @returns The euler rotation
  66554. */
  66555. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  66556. /**
  66557. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  66558. * @param space The space that the rotation should be in
  66559. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66560. * @param result The vector3 that the rotation should be copied to
  66561. */
  66562. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66563. /**
  66564. * Get the quaternion rotation of the bone in either local or world space
  66565. * @param space The space that the rotation should be in
  66566. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66567. * @returns The quaternion rotation
  66568. */
  66569. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  66570. /**
  66571. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  66572. * @param space The space that the rotation should be in
  66573. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66574. * @param result The quaternion that the rotation should be copied to
  66575. */
  66576. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  66577. /**
  66578. * Get the rotation matrix of the bone in local or world space
  66579. * @param space The space that the rotation should be in
  66580. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66581. * @returns The rotation matrix
  66582. */
  66583. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  66584. /**
  66585. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  66586. * @param space The space that the rotation should be in
  66587. * @param mesh The mesh that this bone is attached to. This is only used in world space
  66588. * @param result The quaternion that the rotation should be copied to
  66589. */
  66590. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  66591. /**
  66592. * Get the world position of a point that is in the local space of the bone
  66593. * @param position The local position
  66594. * @param mesh The mesh that this bone is attached to
  66595. * @returns The world position
  66596. */
  66597. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66598. /**
  66599. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  66600. * @param position The local position
  66601. * @param mesh The mesh that this bone is attached to
  66602. * @param result The vector3 that the world position should be copied to
  66603. */
  66604. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66605. /**
  66606. * Get the local position of a point that is in world space
  66607. * @param position The world position
  66608. * @param mesh The mesh that this bone is attached to
  66609. * @returns The local position
  66610. */
  66611. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  66612. /**
  66613. * Get the local position of a point that is in world space and copy it to the result param
  66614. * @param position The world position
  66615. * @param mesh The mesh that this bone is attached to
  66616. * @param result The vector3 that the local position should be copied to
  66617. */
  66618. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  66619. }
  66620. }
  66621. declare module BABYLON {
  66622. /**
  66623. * Enum that determines the text-wrapping mode to use.
  66624. */
  66625. export enum InspectableType {
  66626. /**
  66627. * Checkbox for booleans
  66628. */
  66629. Checkbox = 0,
  66630. /**
  66631. * Sliders for numbers
  66632. */
  66633. Slider = 1,
  66634. /**
  66635. * Vector3
  66636. */
  66637. Vector3 = 2,
  66638. /**
  66639. * Quaternions
  66640. */
  66641. Quaternion = 3,
  66642. /**
  66643. * Color3
  66644. */
  66645. Color3 = 4
  66646. }
  66647. /**
  66648. * Interface used to define custom inspectable properties.
  66649. * This interface is used by the inspector to display custom property grids
  66650. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  66651. */
  66652. export interface IInspectable {
  66653. /**
  66654. * Gets the label to display
  66655. */
  66656. label: string;
  66657. /**
  66658. * Gets the name of the property to edit
  66659. */
  66660. propertyName: string;
  66661. /**
  66662. * Gets the type of the editor to use
  66663. */
  66664. type: InspectableType;
  66665. /**
  66666. * Gets the minimum value of the property when using in "slider" mode
  66667. */
  66668. min?: number;
  66669. /**
  66670. * Gets the maximum value of the property when using in "slider" mode
  66671. */
  66672. max?: number;
  66673. /**
  66674. * Gets the setp to use when using in "slider" mode
  66675. */
  66676. step?: number;
  66677. }
  66678. }
  66679. declare module BABYLON {
  66680. /**
  66681. * Class for creating a cube texture
  66682. */
  66683. export class CubeTexture extends BaseTexture {
  66684. private _delayedOnLoad;
  66685. /**
  66686. * The url of the texture
  66687. */
  66688. url: string;
  66689. /**
  66690. * Gets or sets the center of the bounding box associated with the cube texture.
  66691. * It must define where the camera used to render the texture was set
  66692. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  66693. */
  66694. boundingBoxPosition: Vector3;
  66695. private _boundingBoxSize;
  66696. /**
  66697. * Gets or sets the size of the bounding box associated with the cube texture
  66698. * When defined, the cubemap will switch to local mode
  66699. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  66700. * @example https://www.babylonjs-playground.com/#RNASML
  66701. */
  66702. /**
  66703. * Returns the bounding box size
  66704. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  66705. */
  66706. boundingBoxSize: Vector3;
  66707. protected _rotationY: number;
  66708. /**
  66709. * Sets texture matrix rotation angle around Y axis in radians.
  66710. */
  66711. /**
  66712. * Gets texture matrix rotation angle around Y axis radians.
  66713. */
  66714. rotationY: number;
  66715. /**
  66716. * Are mip maps generated for this texture or not.
  66717. */
  66718. readonly noMipmap: boolean;
  66719. private _noMipmap;
  66720. private _files;
  66721. private _extensions;
  66722. private _textureMatrix;
  66723. private _format;
  66724. private _createPolynomials;
  66725. /** @hidden */
  66726. _prefiltered: boolean;
  66727. /**
  66728. * Creates a cube texture from an array of image urls
  66729. * @param files defines an array of image urls
  66730. * @param scene defines the hosting scene
  66731. * @param noMipmap specifies if mip maps are not used
  66732. * @returns a cube texture
  66733. */
  66734. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  66735. /**
  66736. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  66737. * @param url defines the url of the prefiltered texture
  66738. * @param scene defines the scene the texture is attached to
  66739. * @param forcedExtension defines the extension of the file if different from the url
  66740. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  66741. * @return the prefiltered texture
  66742. */
  66743. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  66744. /**
  66745. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  66746. * as prefiltered data.
  66747. * @param rootUrl defines the url of the texture or the root name of the six images
  66748. * @param scene defines the scene the texture is attached to
  66749. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  66750. * @param noMipmap defines if mipmaps should be created or not
  66751. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  66752. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  66753. * @param onError defines a callback triggered in case of error during load
  66754. * @param format defines the internal format to use for the texture once loaded
  66755. * @param prefiltered defines whether or not the texture is created from prefiltered data
  66756. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  66757. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  66758. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66759. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66760. * @return the cube texture
  66761. */
  66762. 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);
  66763. /**
  66764. * Get the current class name of the texture useful for serialization or dynamic coding.
  66765. * @returns "CubeTexture"
  66766. */
  66767. getClassName(): string;
  66768. /**
  66769. * Update the url (and optional buffer) of this texture if url was null during construction.
  66770. * @param url the url of the texture
  66771. * @param forcedExtension defines the extension to use
  66772. * @param onLoad callback called when the texture is loaded (defaults to null)
  66773. */
  66774. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  66775. /**
  66776. * Delays loading of the cube texture
  66777. * @param forcedExtension defines the extension to use
  66778. */
  66779. delayLoad(forcedExtension?: string): void;
  66780. /**
  66781. * Returns the reflection texture matrix
  66782. * @returns the reflection texture matrix
  66783. */
  66784. getReflectionTextureMatrix(): Matrix;
  66785. /**
  66786. * Sets the reflection texture matrix
  66787. * @param value Reflection texture matrix
  66788. */
  66789. setReflectionTextureMatrix(value: Matrix): void;
  66790. /**
  66791. * Parses text to create a cube texture
  66792. * @param parsedTexture define the serialized text to read from
  66793. * @param scene defines the hosting scene
  66794. * @param rootUrl defines the root url of the cube texture
  66795. * @returns a cube texture
  66796. */
  66797. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  66798. /**
  66799. * Makes a clone, or deep copy, of the cube texture
  66800. * @returns a new cube texture
  66801. */
  66802. clone(): CubeTexture;
  66803. }
  66804. }
  66805. declare module BABYLON {
  66806. /** @hidden */
  66807. export var postprocessVertexShader: {
  66808. name: string;
  66809. shader: string;
  66810. };
  66811. }
  66812. declare module BABYLON {
  66813. /**
  66814. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  66815. * This is the base of the follow, arc rotate cameras and Free camera
  66816. * @see http://doc.babylonjs.com/features/cameras
  66817. */
  66818. export class TargetCamera extends Camera {
  66819. private static _RigCamTransformMatrix;
  66820. private static _TargetTransformMatrix;
  66821. private static _TargetFocalPoint;
  66822. /**
  66823. * Define the current direction the camera is moving to
  66824. */
  66825. cameraDirection: Vector3;
  66826. /**
  66827. * Define the current rotation the camera is rotating to
  66828. */
  66829. cameraRotation: Vector2;
  66830. /**
  66831. * When set, the up vector of the camera will be updated by the rotation of the camera
  66832. */
  66833. updateUpVectorFromRotation: boolean;
  66834. private _tmpQuaternion;
  66835. /**
  66836. * Define the current rotation of the camera
  66837. */
  66838. rotation: Vector3;
  66839. /**
  66840. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  66841. */
  66842. rotationQuaternion: Quaternion;
  66843. /**
  66844. * Define the current speed of the camera
  66845. */
  66846. speed: number;
  66847. /**
  66848. * Add cconstraint to the camera to prevent it to move freely in all directions and
  66849. * around all axis.
  66850. */
  66851. noRotationConstraint: boolean;
  66852. /**
  66853. * Define the current target of the camera as an object or a position.
  66854. */
  66855. lockedTarget: any;
  66856. /** @hidden */
  66857. _currentTarget: Vector3;
  66858. /** @hidden */
  66859. _initialFocalDistance: number;
  66860. /** @hidden */
  66861. _viewMatrix: Matrix;
  66862. /** @hidden */
  66863. _camMatrix: Matrix;
  66864. /** @hidden */
  66865. _cameraTransformMatrix: Matrix;
  66866. /** @hidden */
  66867. _cameraRotationMatrix: Matrix;
  66868. /** @hidden */
  66869. _referencePoint: Vector3;
  66870. /** @hidden */
  66871. _transformedReferencePoint: Vector3;
  66872. protected _globalCurrentTarget: Vector3;
  66873. protected _globalCurrentUpVector: Vector3;
  66874. /** @hidden */
  66875. _reset: () => void;
  66876. private _defaultUp;
  66877. /**
  66878. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  66879. * This is the base of the follow, arc rotate cameras and Free camera
  66880. * @see http://doc.babylonjs.com/features/cameras
  66881. * @param name Defines the name of the camera in the scene
  66882. * @param position Defines the start position of the camera in the scene
  66883. * @param scene Defines the scene the camera belongs to
  66884. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  66885. */
  66886. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  66887. /**
  66888. * Gets the position in front of the camera at a given distance.
  66889. * @param distance The distance from the camera we want the position to be
  66890. * @returns the position
  66891. */
  66892. getFrontPosition(distance: number): Vector3;
  66893. /** @hidden */
  66894. _getLockedTargetPosition(): Nullable<Vector3>;
  66895. private _storedPosition;
  66896. private _storedRotation;
  66897. private _storedRotationQuaternion;
  66898. /**
  66899. * Store current camera state of the camera (fov, position, rotation, etc..)
  66900. * @returns the camera
  66901. */
  66902. storeState(): Camera;
  66903. /**
  66904. * Restored camera state. You must call storeState() first
  66905. * @returns whether it was successful or not
  66906. * @hidden
  66907. */
  66908. _restoreStateValues(): boolean;
  66909. /** @hidden */
  66910. _initCache(): void;
  66911. /** @hidden */
  66912. _updateCache(ignoreParentClass?: boolean): void;
  66913. /** @hidden */
  66914. _isSynchronizedViewMatrix(): boolean;
  66915. /** @hidden */
  66916. _computeLocalCameraSpeed(): number;
  66917. /**
  66918. * Defines the target the camera should look at.
  66919. * This will automatically adapt alpha beta and radius to fit within the new target.
  66920. * @param target Defines the new target as a Vector or a mesh
  66921. */
  66922. setTarget(target: Vector3): void;
  66923. /**
  66924. * Return the current target position of the camera. This value is expressed in local space.
  66925. * @returns the target position
  66926. */
  66927. getTarget(): Vector3;
  66928. /** @hidden */
  66929. _decideIfNeedsToMove(): boolean;
  66930. /** @hidden */
  66931. _updatePosition(): void;
  66932. /** @hidden */
  66933. _checkInputs(): void;
  66934. protected _updateCameraRotationMatrix(): void;
  66935. /**
  66936. * 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)
  66937. * @returns the current camera
  66938. */
  66939. private _rotateUpVectorWithCameraRotationMatrix;
  66940. private _cachedRotationZ;
  66941. private _cachedQuaternionRotationZ;
  66942. /** @hidden */
  66943. _getViewMatrix(): Matrix;
  66944. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  66945. /**
  66946. * @hidden
  66947. */
  66948. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  66949. /**
  66950. * @hidden
  66951. */
  66952. _updateRigCameras(): void;
  66953. private _getRigCamPositionAndTarget;
  66954. /**
  66955. * Gets the current object class name.
  66956. * @return the class name
  66957. */
  66958. getClassName(): string;
  66959. }
  66960. }
  66961. declare module BABYLON {
  66962. /**
  66963. * @ignore
  66964. * This is a list of all the different input types that are available in the application.
  66965. * Fo instance: ArcRotateCameraGamepadInput...
  66966. */
  66967. export var CameraInputTypes: {};
  66968. /**
  66969. * This is the contract to implement in order to create a new input class.
  66970. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  66971. */
  66972. export interface ICameraInput<TCamera extends Camera> {
  66973. /**
  66974. * Defines the camera the input is attached to.
  66975. */
  66976. camera: Nullable<TCamera>;
  66977. /**
  66978. * Gets the class name of the current intput.
  66979. * @returns the class name
  66980. */
  66981. getClassName(): string;
  66982. /**
  66983. * Get the friendly name associated with the input class.
  66984. * @returns the input friendly name
  66985. */
  66986. getSimpleName(): string;
  66987. /**
  66988. * Attach the input controls to a specific dom element to get the input from.
  66989. * @param element Defines the element the controls should be listened from
  66990. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  66991. */
  66992. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  66993. /**
  66994. * Detach the current controls from the specified dom element.
  66995. * @param element Defines the element to stop listening the inputs from
  66996. */
  66997. detachControl(element: Nullable<HTMLElement>): void;
  66998. /**
  66999. * Update the current camera state depending on the inputs that have been used this frame.
  67000. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67001. */
  67002. checkInputs?: () => void;
  67003. }
  67004. /**
  67005. * Represents a map of input types to input instance or input index to input instance.
  67006. */
  67007. export interface CameraInputsMap<TCamera extends Camera> {
  67008. /**
  67009. * Accessor to the input by input type.
  67010. */
  67011. [name: string]: ICameraInput<TCamera>;
  67012. /**
  67013. * Accessor to the input by input index.
  67014. */
  67015. [idx: number]: ICameraInput<TCamera>;
  67016. }
  67017. /**
  67018. * This represents the input manager used within a camera.
  67019. * It helps dealing with all the different kind of input attached to a camera.
  67020. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67021. */
  67022. export class CameraInputsManager<TCamera extends Camera> {
  67023. /**
  67024. * Defines the list of inputs attahed to the camera.
  67025. */
  67026. attached: CameraInputsMap<TCamera>;
  67027. /**
  67028. * Defines the dom element the camera is collecting inputs from.
  67029. * This is null if the controls have not been attached.
  67030. */
  67031. attachedElement: Nullable<HTMLElement>;
  67032. /**
  67033. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67034. */
  67035. noPreventDefault: boolean;
  67036. /**
  67037. * Defined the camera the input manager belongs to.
  67038. */
  67039. camera: TCamera;
  67040. /**
  67041. * Update the current camera state depending on the inputs that have been used this frame.
  67042. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67043. */
  67044. checkInputs: () => void;
  67045. /**
  67046. * Instantiate a new Camera Input Manager.
  67047. * @param camera Defines the camera the input manager blongs to
  67048. */
  67049. constructor(camera: TCamera);
  67050. /**
  67051. * Add an input method to a camera
  67052. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67053. * @param input camera input method
  67054. */
  67055. add(input: ICameraInput<TCamera>): void;
  67056. /**
  67057. * Remove a specific input method from a camera
  67058. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  67059. * @param inputToRemove camera input method
  67060. */
  67061. remove(inputToRemove: ICameraInput<TCamera>): void;
  67062. /**
  67063. * Remove a specific input type from a camera
  67064. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  67065. * @param inputType the type of the input to remove
  67066. */
  67067. removeByType(inputType: string): void;
  67068. private _addCheckInputs;
  67069. /**
  67070. * Attach the input controls to the currently attached dom element to listen the events from.
  67071. * @param input Defines the input to attach
  67072. */
  67073. attachInput(input: ICameraInput<TCamera>): void;
  67074. /**
  67075. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  67076. * @param element Defines the dom element to collect the events from
  67077. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67078. */
  67079. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  67080. /**
  67081. * Detach the current manager inputs controls from a specific dom element.
  67082. * @param element Defines the dom element to collect the events from
  67083. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  67084. */
  67085. detachElement(element: HTMLElement, disconnect?: boolean): void;
  67086. /**
  67087. * Rebuild the dynamic inputCheck function from the current list of
  67088. * defined inputs in the manager.
  67089. */
  67090. rebuildInputCheck(): void;
  67091. /**
  67092. * Remove all attached input methods from a camera
  67093. */
  67094. clear(): void;
  67095. /**
  67096. * Serialize the current input manager attached to a camera.
  67097. * This ensures than once parsed,
  67098. * the input associated to the camera will be identical to the current ones
  67099. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  67100. */
  67101. serialize(serializedCamera: any): void;
  67102. /**
  67103. * Parses an input manager serialized JSON to restore the previous list of inputs
  67104. * and states associated to a camera.
  67105. * @param parsedCamera Defines the JSON to parse
  67106. */
  67107. parse(parsedCamera: any): void;
  67108. }
  67109. }
  67110. declare module BABYLON {
  67111. /**
  67112. * Gather the list of keyboard event types as constants.
  67113. */
  67114. export class KeyboardEventTypes {
  67115. /**
  67116. * The keydown event is fired when a key becomes active (pressed).
  67117. */
  67118. static readonly KEYDOWN: number;
  67119. /**
  67120. * The keyup event is fired when a key has been released.
  67121. */
  67122. static readonly KEYUP: number;
  67123. }
  67124. /**
  67125. * This class is used to store keyboard related info for the onKeyboardObservable event.
  67126. */
  67127. export class KeyboardInfo {
  67128. /**
  67129. * Defines the type of event (KeyboardEventTypes)
  67130. */
  67131. type: number;
  67132. /**
  67133. * Defines the related dom event
  67134. */
  67135. event: KeyboardEvent;
  67136. /**
  67137. * Instantiates a new keyboard info.
  67138. * This class is used to store keyboard related info for the onKeyboardObservable event.
  67139. * @param type Defines the type of event (KeyboardEventTypes)
  67140. * @param event Defines the related dom event
  67141. */
  67142. constructor(
  67143. /**
  67144. * Defines the type of event (KeyboardEventTypes)
  67145. */
  67146. type: number,
  67147. /**
  67148. * Defines the related dom event
  67149. */
  67150. event: KeyboardEvent);
  67151. }
  67152. /**
  67153. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  67154. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  67155. */
  67156. export class KeyboardInfoPre extends KeyboardInfo {
  67157. /**
  67158. * Defines the type of event (KeyboardEventTypes)
  67159. */
  67160. type: number;
  67161. /**
  67162. * Defines the related dom event
  67163. */
  67164. event: KeyboardEvent;
  67165. /**
  67166. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  67167. */
  67168. skipOnPointerObservable: boolean;
  67169. /**
  67170. * Instantiates a new keyboard pre info.
  67171. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  67172. * @param type Defines the type of event (KeyboardEventTypes)
  67173. * @param event Defines the related dom event
  67174. */
  67175. constructor(
  67176. /**
  67177. * Defines the type of event (KeyboardEventTypes)
  67178. */
  67179. type: number,
  67180. /**
  67181. * Defines the related dom event
  67182. */
  67183. event: KeyboardEvent);
  67184. }
  67185. }
  67186. declare module BABYLON {
  67187. /**
  67188. * Manage the keyboard inputs to control the movement of a free camera.
  67189. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  67190. */
  67191. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  67192. /**
  67193. * Defines the camera the input is attached to.
  67194. */
  67195. camera: FreeCamera;
  67196. /**
  67197. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  67198. */
  67199. keysUp: number[];
  67200. /**
  67201. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  67202. */
  67203. keysDown: number[];
  67204. /**
  67205. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  67206. */
  67207. keysLeft: number[];
  67208. /**
  67209. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  67210. */
  67211. keysRight: number[];
  67212. private _keys;
  67213. private _onCanvasBlurObserver;
  67214. private _onKeyboardObserver;
  67215. private _engine;
  67216. private _scene;
  67217. /**
  67218. * Attach the input controls to a specific dom element to get the input from.
  67219. * @param element Defines the element the controls should be listened from
  67220. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  67221. */
  67222. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  67223. /**
  67224. * Detach the current controls from the specified dom element.
  67225. * @param element Defines the element to stop listening the inputs from
  67226. */
  67227. detachControl(element: Nullable<HTMLElement>): void;
  67228. /**
  67229. * Update the current camera state depending on the inputs that have been used this frame.
  67230. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  67231. */
  67232. checkInputs(): void;
  67233. /**
  67234. * Gets the class name of the current intput.
  67235. * @returns the class name
  67236. */
  67237. getClassName(): string;
  67238. /** @hidden */
  67239. _onLostFocus(): void;
  67240. /**
  67241. * Get the friendly name associated with the input class.
  67242. * @returns the input friendly name
  67243. */
  67244. getSimpleName(): string;
  67245. }
  67246. }
  67247. declare module BABYLON {
  67248. /**
  67249. * Interface describing all the common properties and methods a shadow light needs to implement.
  67250. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  67251. * as well as binding the different shadow properties to the effects.
  67252. */
  67253. export interface IShadowLight extends Light {
  67254. /**
  67255. * The light id in the scene (used in scene.findLighById for instance)
  67256. */
  67257. id: string;
  67258. /**
  67259. * The position the shdow will be casted from.
  67260. */
  67261. position: Vector3;
  67262. /**
  67263. * In 2d mode (needCube being false), the direction used to cast the shadow.
  67264. */
  67265. direction: Vector3;
  67266. /**
  67267. * The transformed position. Position of the light in world space taking parenting in account.
  67268. */
  67269. transformedPosition: Vector3;
  67270. /**
  67271. * The transformed direction. Direction of the light in world space taking parenting in account.
  67272. */
  67273. transformedDirection: Vector3;
  67274. /**
  67275. * The friendly name of the light in the scene.
  67276. */
  67277. name: string;
  67278. /**
  67279. * Defines the shadow projection clipping minimum z value.
  67280. */
  67281. shadowMinZ: number;
  67282. /**
  67283. * Defines the shadow projection clipping maximum z value.
  67284. */
  67285. shadowMaxZ: number;
  67286. /**
  67287. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  67288. * @returns true if the information has been computed, false if it does not need to (no parenting)
  67289. */
  67290. computeTransformedInformation(): boolean;
  67291. /**
  67292. * Gets the scene the light belongs to.
  67293. * @returns The scene
  67294. */
  67295. getScene(): Scene;
  67296. /**
  67297. * Callback defining a custom Projection Matrix Builder.
  67298. * This can be used to override the default projection matrix computation.
  67299. */
  67300. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  67301. /**
  67302. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  67303. * @param matrix The materix to updated with the projection information
  67304. * @param viewMatrix The transform matrix of the light
  67305. * @param renderList The list of mesh to render in the map
  67306. * @returns The current light
  67307. */
  67308. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  67309. /**
  67310. * Gets the current depth scale used in ESM.
  67311. * @returns The scale
  67312. */
  67313. getDepthScale(): number;
  67314. /**
  67315. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  67316. * @returns true if a cube texture needs to be use
  67317. */
  67318. needCube(): boolean;
  67319. /**
  67320. * Detects if the projection matrix requires to be recomputed this frame.
  67321. * @returns true if it requires to be recomputed otherwise, false.
  67322. */
  67323. needProjectionMatrixCompute(): boolean;
  67324. /**
  67325. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  67326. */
  67327. forceProjectionMatrixCompute(): void;
  67328. /**
  67329. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  67330. * @param faceIndex The index of the face we are computed the direction to generate shadow
  67331. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  67332. */
  67333. getShadowDirection(faceIndex?: number): Vector3;
  67334. /**
  67335. * Gets the minZ used for shadow according to both the scene and the light.
  67336. * @param activeCamera The camera we are returning the min for
  67337. * @returns the depth min z
  67338. */
  67339. getDepthMinZ(activeCamera: Camera): number;
  67340. /**
  67341. * Gets the maxZ used for shadow according to both the scene and the light.
  67342. * @param activeCamera The camera we are returning the max for
  67343. * @returns the depth max z
  67344. */
  67345. getDepthMaxZ(activeCamera: Camera): number;
  67346. }
  67347. /**
  67348. * Base implementation IShadowLight
  67349. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  67350. */
  67351. export abstract class ShadowLight extends Light implements IShadowLight {
  67352. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  67353. protected _position: Vector3;
  67354. protected _setPosition(value: Vector3): void;
  67355. /**
  67356. * Sets the position the shadow will be casted from. Also use as the light position for both
  67357. * point and spot lights.
  67358. */
  67359. /**
  67360. * Sets the position the shadow will be casted from. Also use as the light position for both
  67361. * point and spot lights.
  67362. */
  67363. position: Vector3;
  67364. protected _direction: Vector3;
  67365. protected _setDirection(value: Vector3): void;
  67366. /**
  67367. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  67368. * Also use as the light direction on spot and directional lights.
  67369. */
  67370. /**
  67371. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  67372. * Also use as the light direction on spot and directional lights.
  67373. */
  67374. direction: Vector3;
  67375. private _shadowMinZ;
  67376. /**
  67377. * Gets the shadow projection clipping minimum z value.
  67378. */
  67379. /**
  67380. * Sets the shadow projection clipping minimum z value.
  67381. */
  67382. shadowMinZ: number;
  67383. private _shadowMaxZ;
  67384. /**
  67385. * Sets the shadow projection clipping maximum z value.
  67386. */
  67387. /**
  67388. * Gets the shadow projection clipping maximum z value.
  67389. */
  67390. shadowMaxZ: number;
  67391. /**
  67392. * Callback defining a custom Projection Matrix Builder.
  67393. * This can be used to override the default projection matrix computation.
  67394. */
  67395. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  67396. /**
  67397. * The transformed position. Position of the light in world space taking parenting in account.
  67398. */
  67399. transformedPosition: Vector3;
  67400. /**
  67401. * The transformed direction. Direction of the light in world space taking parenting in account.
  67402. */
  67403. transformedDirection: Vector3;
  67404. private _needProjectionMatrixCompute;
  67405. /**
  67406. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  67407. * @returns true if the information has been computed, false if it does not need to (no parenting)
  67408. */
  67409. computeTransformedInformation(): boolean;
  67410. /**
  67411. * Return the depth scale used for the shadow map.
  67412. * @returns the depth scale.
  67413. */
  67414. getDepthScale(): number;
  67415. /**
  67416. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  67417. * @param faceIndex The index of the face we are computed the direction to generate shadow
  67418. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  67419. */
  67420. getShadowDirection(faceIndex?: number): Vector3;
  67421. /**
  67422. * Returns the ShadowLight absolute position in the World.
  67423. * @returns the position vector in world space
  67424. */
  67425. getAbsolutePosition(): Vector3;
  67426. /**
  67427. * Sets the ShadowLight direction toward the passed target.
  67428. * @param target The point to target in local space
  67429. * @returns the updated ShadowLight direction
  67430. */
  67431. setDirectionToTarget(target: Vector3): Vector3;
  67432. /**
  67433. * Returns the light rotation in euler definition.
  67434. * @returns the x y z rotation in local space.
  67435. */
  67436. getRotation(): Vector3;
  67437. /**
  67438. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  67439. * @returns true if a cube texture needs to be use
  67440. */
  67441. needCube(): boolean;
  67442. /**
  67443. * Detects if the projection matrix requires to be recomputed this frame.
  67444. * @returns true if it requires to be recomputed otherwise, false.
  67445. */
  67446. needProjectionMatrixCompute(): boolean;
  67447. /**
  67448. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  67449. */
  67450. forceProjectionMatrixCompute(): void;
  67451. /** @hidden */
  67452. _initCache(): void;
  67453. /** @hidden */
  67454. _isSynchronized(): boolean;
  67455. /**
  67456. * Computes the world matrix of the node
  67457. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67458. * @returns the world matrix
  67459. */
  67460. computeWorldMatrix(force?: boolean): Matrix;
  67461. /**
  67462. * Gets the minZ used for shadow according to both the scene and the light.
  67463. * @param activeCamera The camera we are returning the min for
  67464. * @returns the depth min z
  67465. */
  67466. getDepthMinZ(activeCamera: Camera): number;
  67467. /**
  67468. * Gets the maxZ used for shadow according to both the scene and the light.
  67469. * @param activeCamera The camera we are returning the max for
  67470. * @returns the depth max z
  67471. */
  67472. getDepthMaxZ(activeCamera: Camera): number;
  67473. /**
  67474. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  67475. * @param matrix The materix to updated with the projection information
  67476. * @param viewMatrix The transform matrix of the light
  67477. * @param renderList The list of mesh to render in the map
  67478. * @returns The current light
  67479. */
  67480. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  67481. }
  67482. }
  67483. declare module BABYLON {
  67484. /**
  67485. * "Static Class" containing the most commonly used helper while dealing with material for
  67486. * rendering purpose.
  67487. *
  67488. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  67489. *
  67490. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  67491. */
  67492. export class MaterialHelper {
  67493. /**
  67494. * Bind the current view position to an effect.
  67495. * @param effect The effect to be bound
  67496. * @param scene The scene the eyes position is used from
  67497. */
  67498. static BindEyePosition(effect: Effect, scene: Scene): void;
  67499. /**
  67500. * Helps preparing the defines values about the UVs in used in the effect.
  67501. * UVs are shared as much as we can accross channels in the shaders.
  67502. * @param texture The texture we are preparing the UVs for
  67503. * @param defines The defines to update
  67504. * @param key The channel key "diffuse", "specular"... used in the shader
  67505. */
  67506. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  67507. /**
  67508. * Binds a texture matrix value to its corrsponding uniform
  67509. * @param texture The texture to bind the matrix for
  67510. * @param uniformBuffer The uniform buffer receivin the data
  67511. * @param key The channel key "diffuse", "specular"... used in the shader
  67512. */
  67513. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  67514. /**
  67515. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  67516. * @param mesh defines the current mesh
  67517. * @param scene defines the current scene
  67518. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  67519. * @param pointsCloud defines if point cloud rendering has to be turned on
  67520. * @param fogEnabled defines if fog has to be turned on
  67521. * @param alphaTest defines if alpha testing has to be turned on
  67522. * @param defines defines the current list of defines
  67523. */
  67524. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  67525. /**
  67526. * Helper used to prepare the list of defines associated with frame values for shader compilation
  67527. * @param scene defines the current scene
  67528. * @param engine defines the current engine
  67529. * @param defines specifies the list of active defines
  67530. * @param useInstances defines if instances have to be turned on
  67531. * @param useClipPlane defines if clip plane have to be turned on
  67532. */
  67533. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  67534. /**
  67535. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  67536. * @param mesh The mesh containing the geometry data we will draw
  67537. * @param defines The defines to update
  67538. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  67539. * @param useBones Precise whether bones should be used or not (override mesh info)
  67540. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  67541. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  67542. * @returns false if defines are considered not dirty and have not been checked
  67543. */
  67544. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  67545. /**
  67546. * Prepares the defines related to the light information passed in parameter
  67547. * @param scene The scene we are intending to draw
  67548. * @param mesh The mesh the effect is compiling for
  67549. * @param defines The defines to update
  67550. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  67551. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  67552. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  67553. * @returns true if normals will be required for the rest of the effect
  67554. */
  67555. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  67556. /**
  67557. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  67558. * that won t be acctive due to defines being turned off.
  67559. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  67560. * @param samplersList The samplers list
  67561. * @param defines The defines helping in the list generation
  67562. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  67563. */
  67564. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  67565. /**
  67566. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  67567. * @param defines The defines to update while falling back
  67568. * @param fallbacks The authorized effect fallbacks
  67569. * @param maxSimultaneousLights The maximum number of lights allowed
  67570. * @param rank the current rank of the Effect
  67571. * @returns The newly affected rank
  67572. */
  67573. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  67574. /**
  67575. * Prepares the list of attributes required for morph targets according to the effect defines.
  67576. * @param attribs The current list of supported attribs
  67577. * @param mesh The mesh to prepare the morph targets attributes for
  67578. * @param defines The current Defines of the effect
  67579. */
  67580. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  67581. /**
  67582. * Prepares the list of attributes required for bones according to the effect defines.
  67583. * @param attribs The current list of supported attribs
  67584. * @param mesh The mesh to prepare the bones attributes for
  67585. * @param defines The current Defines of the effect
  67586. * @param fallbacks The current efffect fallback strategy
  67587. */
  67588. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  67589. /**
  67590. * Prepares the list of attributes required for instances according to the effect defines.
  67591. * @param attribs The current list of supported attribs
  67592. * @param defines The current Defines of the effect
  67593. */
  67594. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  67595. /**
  67596. * Binds the light shadow information to the effect for the given mesh.
  67597. * @param light The light containing the generator
  67598. * @param scene The scene the lights belongs to
  67599. * @param mesh The mesh we are binding the information to render
  67600. * @param lightIndex The light index in the effect used to render the mesh
  67601. * @param effect The effect we are binding the data to
  67602. */
  67603. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  67604. /**
  67605. * Binds the light information to the effect.
  67606. * @param light The light containing the generator
  67607. * @param effect The effect we are binding the data to
  67608. * @param lightIndex The light index in the effect used to render
  67609. */
  67610. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  67611. /**
  67612. * Binds the lights information from the scene to the effect for the given mesh.
  67613. * @param scene The scene the lights belongs to
  67614. * @param mesh The mesh we are binding the information to render
  67615. * @param effect The effect we are binding the data to
  67616. * @param defines The generated defines for the effect
  67617. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  67618. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  67619. */
  67620. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  67621. private static _tempFogColor;
  67622. /**
  67623. * Binds the fog information from the scene to the effect for the given mesh.
  67624. * @param scene The scene the lights belongs to
  67625. * @param mesh The mesh we are binding the information to render
  67626. * @param effect The effect we are binding the data to
  67627. * @param linearSpace Defines if the fog effect is applied in linear space
  67628. */
  67629. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  67630. /**
  67631. * Binds the bones information from the mesh to the effect.
  67632. * @param mesh The mesh we are binding the information to render
  67633. * @param effect The effect we are binding the data to
  67634. */
  67635. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  67636. /**
  67637. * Binds the morph targets information from the mesh to the effect.
  67638. * @param abstractMesh The mesh we are binding the information to render
  67639. * @param effect The effect we are binding the data to
  67640. */
  67641. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  67642. /**
  67643. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  67644. * @param defines The generated defines used in the effect
  67645. * @param effect The effect we are binding the data to
  67646. * @param scene The scene we are willing to render with logarithmic scale for
  67647. */
  67648. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  67649. /**
  67650. * Binds the clip plane information from the scene to the effect.
  67651. * @param scene The scene the clip plane information are extracted from
  67652. * @param effect The effect we are binding the data to
  67653. */
  67654. static BindClipPlane(effect: Effect, scene: Scene): void;
  67655. }
  67656. }
  67657. declare module BABYLON {
  67658. /** @hidden */
  67659. export var kernelBlurVaryingDeclaration: {
  67660. name: string;
  67661. shader: string;
  67662. };
  67663. }
  67664. declare module BABYLON {
  67665. /** @hidden */
  67666. export var kernelBlurFragment: {
  67667. name: string;
  67668. shader: string;
  67669. };
  67670. }
  67671. declare module BABYLON {
  67672. /** @hidden */
  67673. export var kernelBlurFragment2: {
  67674. name: string;
  67675. shader: string;
  67676. };
  67677. }
  67678. declare module BABYLON {
  67679. /** @hidden */
  67680. export var kernelBlurPixelShader: {
  67681. name: string;
  67682. shader: string;
  67683. };
  67684. }
  67685. declare module BABYLON {
  67686. /** @hidden */
  67687. export var kernelBlurVertex: {
  67688. name: string;
  67689. shader: string;
  67690. };
  67691. }
  67692. declare module BABYLON {
  67693. /** @hidden */
  67694. export var kernelBlurVertexShader: {
  67695. name: string;
  67696. shader: string;
  67697. };
  67698. }
  67699. declare module BABYLON {
  67700. /**
  67701. * The Blur Post Process which blurs an image based on a kernel and direction.
  67702. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  67703. */
  67704. export class BlurPostProcess extends PostProcess {
  67705. /** The direction in which to blur the image. */
  67706. direction: Vector2;
  67707. private blockCompilation;
  67708. protected _kernel: number;
  67709. protected _idealKernel: number;
  67710. protected _packedFloat: boolean;
  67711. private _staticDefines;
  67712. /**
  67713. * Sets the length in pixels of the blur sample region
  67714. */
  67715. /**
  67716. * Gets the length in pixels of the blur sample region
  67717. */
  67718. kernel: number;
  67719. /**
  67720. * Sets wether or not the blur needs to unpack/repack floats
  67721. */
  67722. /**
  67723. * Gets wether or not the blur is unpacking/repacking floats
  67724. */
  67725. packedFloat: boolean;
  67726. /**
  67727. * Creates a new instance BlurPostProcess
  67728. * @param name The name of the effect.
  67729. * @param direction The direction in which to blur the image.
  67730. * @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.
  67731. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  67732. * @param camera The camera to apply the render pass to.
  67733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67734. * @param engine The engine which the post process will be applied. (default: current engine)
  67735. * @param reusable If the post process can be reused on the same frame. (default: false)
  67736. * @param textureType Type of textures used when performing the post process. (default: 0)
  67737. * @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)
  67738. */
  67739. constructor(name: string,
  67740. /** The direction in which to blur the image. */
  67741. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  67742. /**
  67743. * Updates the effect with the current post process compile time values and recompiles the shader.
  67744. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67745. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67746. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67747. * @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
  67748. * @param onCompiled Called when the shader has been compiled.
  67749. * @param onError Called if there is an error when compiling a shader.
  67750. */
  67751. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67752. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67753. /**
  67754. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  67755. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  67756. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  67757. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  67758. * The gaps between physical kernels are compensated for in the weighting of the samples
  67759. * @param idealKernel Ideal blur kernel.
  67760. * @return Nearest best kernel.
  67761. */
  67762. protected _nearestBestKernel(idealKernel: number): number;
  67763. /**
  67764. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  67765. * @param x The point on the Gaussian distribution to sample.
  67766. * @return the value of the Gaussian function at x.
  67767. */
  67768. protected _gaussianWeight(x: number): number;
  67769. /**
  67770. * Generates a string that can be used as a floating point number in GLSL.
  67771. * @param x Value to print.
  67772. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  67773. * @return GLSL float string.
  67774. */
  67775. protected _glslFloat(x: number, decimalFigures?: number): string;
  67776. }
  67777. }
  67778. declare module BABYLON {
  67779. /** @hidden */
  67780. export var shadowMapPixelShader: {
  67781. name: string;
  67782. shader: string;
  67783. };
  67784. }
  67785. declare module BABYLON {
  67786. /** @hidden */
  67787. export var bonesDeclaration: {
  67788. name: string;
  67789. shader: string;
  67790. };
  67791. }
  67792. declare module BABYLON {
  67793. /** @hidden */
  67794. export var morphTargetsVertexGlobalDeclaration: {
  67795. name: string;
  67796. shader: string;
  67797. };
  67798. }
  67799. declare module BABYLON {
  67800. /** @hidden */
  67801. export var morphTargetsVertexDeclaration: {
  67802. name: string;
  67803. shader: string;
  67804. };
  67805. }
  67806. declare module BABYLON {
  67807. /** @hidden */
  67808. export var instancesDeclaration: {
  67809. name: string;
  67810. shader: string;
  67811. };
  67812. }
  67813. declare module BABYLON {
  67814. /** @hidden */
  67815. export var helperFunctions: {
  67816. name: string;
  67817. shader: string;
  67818. };
  67819. }
  67820. declare module BABYLON {
  67821. /** @hidden */
  67822. export var morphTargetsVertex: {
  67823. name: string;
  67824. shader: string;
  67825. };
  67826. }
  67827. declare module BABYLON {
  67828. /** @hidden */
  67829. export var instancesVertex: {
  67830. name: string;
  67831. shader: string;
  67832. };
  67833. }
  67834. declare module BABYLON {
  67835. /** @hidden */
  67836. export var bonesVertex: {
  67837. name: string;
  67838. shader: string;
  67839. };
  67840. }
  67841. declare module BABYLON {
  67842. /** @hidden */
  67843. export var shadowMapVertexShader: {
  67844. name: string;
  67845. shader: string;
  67846. };
  67847. }
  67848. declare module BABYLON {
  67849. /** @hidden */
  67850. export var depthBoxBlurPixelShader: {
  67851. name: string;
  67852. shader: string;
  67853. };
  67854. }
  67855. declare module BABYLON {
  67856. /**
  67857. * Defines the options associated with the creation of a custom shader for a shadow generator.
  67858. */
  67859. export interface ICustomShaderOptions {
  67860. /**
  67861. * Gets or sets the custom shader name to use
  67862. */
  67863. shaderName: string;
  67864. /**
  67865. * The list of attribute names used in the shader
  67866. */
  67867. attributes?: string[];
  67868. /**
  67869. * The list of unifrom names used in the shader
  67870. */
  67871. uniforms?: string[];
  67872. /**
  67873. * The list of sampler names used in the shader
  67874. */
  67875. samplers?: string[];
  67876. /**
  67877. * The list of defines used in the shader
  67878. */
  67879. defines?: string[];
  67880. }
  67881. /**
  67882. * Interface to implement to create a shadow generator compatible with BJS.
  67883. */
  67884. export interface IShadowGenerator {
  67885. /**
  67886. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  67887. * @returns The render target texture if present otherwise, null
  67888. */
  67889. getShadowMap(): Nullable<RenderTargetTexture>;
  67890. /**
  67891. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  67892. * @returns The render target texture if the shadow map is present otherwise, null
  67893. */
  67894. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  67895. /**
  67896. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  67897. * @param subMesh The submesh we want to render in the shadow map
  67898. * @param useInstances Defines wether will draw in the map using instances
  67899. * @returns true if ready otherwise, false
  67900. */
  67901. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67902. /**
  67903. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  67904. * @param defines Defines of the material we want to update
  67905. * @param lightIndex Index of the light in the enabled light list of the material
  67906. */
  67907. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  67908. /**
  67909. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  67910. * defined in the generator but impacting the effect).
  67911. * It implies the unifroms available on the materials are the standard BJS ones.
  67912. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  67913. * @param effect The effect we are binfing the information for
  67914. */
  67915. bindShadowLight(lightIndex: string, effect: Effect): void;
  67916. /**
  67917. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  67918. * (eq to shadow prjection matrix * light transform matrix)
  67919. * @returns The transform matrix used to create the shadow map
  67920. */
  67921. getTransformMatrix(): Matrix;
  67922. /**
  67923. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  67924. * Cube and 2D textures for instance.
  67925. */
  67926. recreateShadowMap(): void;
  67927. /**
  67928. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67929. * @param onCompiled Callback triggered at the and of the effects compilation
  67930. * @param options Sets of optional options forcing the compilation with different modes
  67931. */
  67932. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  67933. useInstances: boolean;
  67934. }>): void;
  67935. /**
  67936. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  67937. * @param options Sets of optional options forcing the compilation with different modes
  67938. * @returns A promise that resolves when the compilation completes
  67939. */
  67940. forceCompilationAsync(options?: Partial<{
  67941. useInstances: boolean;
  67942. }>): Promise<void>;
  67943. /**
  67944. * Serializes the shadow generator setup to a json object.
  67945. * @returns The serialized JSON object
  67946. */
  67947. serialize(): any;
  67948. /**
  67949. * Disposes the Shadow map and related Textures and effects.
  67950. */
  67951. dispose(): void;
  67952. }
  67953. /**
  67954. * Default implementation IShadowGenerator.
  67955. * This is the main object responsible of generating shadows in the framework.
  67956. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  67957. */
  67958. export class ShadowGenerator implements IShadowGenerator {
  67959. /**
  67960. * Shadow generator mode None: no filtering applied.
  67961. */
  67962. static readonly FILTER_NONE: number;
  67963. /**
  67964. * Shadow generator mode ESM: Exponential Shadow Mapping.
  67965. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67966. */
  67967. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  67968. /**
  67969. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  67970. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  67971. */
  67972. static readonly FILTER_POISSONSAMPLING: number;
  67973. /**
  67974. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  67975. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67976. */
  67977. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  67978. /**
  67979. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  67980. * edge artifacts on steep falloff.
  67981. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67982. */
  67983. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  67984. /**
  67985. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  67986. * edge artifacts on steep falloff.
  67987. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  67988. */
  67989. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  67990. /**
  67991. * Shadow generator mode PCF: Percentage Closer Filtering
  67992. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  67993. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  67994. */
  67995. static readonly FILTER_PCF: number;
  67996. /**
  67997. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  67998. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  67999. * Contact Hardening
  68000. */
  68001. static readonly FILTER_PCSS: number;
  68002. /**
  68003. * Reserved for PCF and PCSS
  68004. * Highest Quality.
  68005. *
  68006. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  68007. *
  68008. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  68009. */
  68010. static readonly QUALITY_HIGH: number;
  68011. /**
  68012. * Reserved for PCF and PCSS
  68013. * Good tradeoff for quality/perf cross devices
  68014. *
  68015. * Execute PCF on a 3*3 kernel.
  68016. *
  68017. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  68018. */
  68019. static readonly QUALITY_MEDIUM: number;
  68020. /**
  68021. * Reserved for PCF and PCSS
  68022. * The lowest quality but the fastest.
  68023. *
  68024. * Execute PCF on a 1*1 kernel.
  68025. *
  68026. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  68027. */
  68028. static readonly QUALITY_LOW: number;
  68029. /** Gets or sets the custom shader name to use */
  68030. customShaderOptions: ICustomShaderOptions;
  68031. /**
  68032. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  68033. */
  68034. onBeforeShadowMapRenderObservable: Observable<Effect>;
  68035. /**
  68036. * Observable triggered before a mesh is rendered in the shadow map.
  68037. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  68038. */
  68039. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  68040. private _bias;
  68041. /**
  68042. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  68043. */
  68044. /**
  68045. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  68046. */
  68047. bias: number;
  68048. private _normalBias;
  68049. /**
  68050. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  68051. */
  68052. /**
  68053. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  68054. */
  68055. normalBias: number;
  68056. private _blurBoxOffset;
  68057. /**
  68058. * Gets the blur box offset: offset applied during the blur pass.
  68059. * Only useful if useKernelBlur = false
  68060. */
  68061. /**
  68062. * Sets the blur box offset: offset applied during the blur pass.
  68063. * Only useful if useKernelBlur = false
  68064. */
  68065. blurBoxOffset: number;
  68066. private _blurScale;
  68067. /**
  68068. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  68069. * 2 means half of the size.
  68070. */
  68071. /**
  68072. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  68073. * 2 means half of the size.
  68074. */
  68075. blurScale: number;
  68076. private _blurKernel;
  68077. /**
  68078. * Gets the blur kernel: kernel size of the blur pass.
  68079. * Only useful if useKernelBlur = true
  68080. */
  68081. /**
  68082. * Sets the blur kernel: kernel size of the blur pass.
  68083. * Only useful if useKernelBlur = true
  68084. */
  68085. blurKernel: number;
  68086. private _useKernelBlur;
  68087. /**
  68088. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  68089. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  68090. */
  68091. /**
  68092. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  68093. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  68094. */
  68095. useKernelBlur: boolean;
  68096. private _depthScale;
  68097. /**
  68098. * Gets the depth scale used in ESM mode.
  68099. */
  68100. /**
  68101. * Sets the depth scale used in ESM mode.
  68102. * This can override the scale stored on the light.
  68103. */
  68104. depthScale: number;
  68105. private _filter;
  68106. /**
  68107. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  68108. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  68109. */
  68110. /**
  68111. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  68112. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  68113. */
  68114. filter: number;
  68115. /**
  68116. * Gets if the current filter is set to Poisson Sampling.
  68117. */
  68118. /**
  68119. * Sets the current filter to Poisson Sampling.
  68120. */
  68121. usePoissonSampling: boolean;
  68122. /**
  68123. * Gets if the current filter is set to ESM.
  68124. */
  68125. /**
  68126. * Sets the current filter is to ESM.
  68127. */
  68128. useExponentialShadowMap: boolean;
  68129. /**
  68130. * Gets if the current filter is set to filtered ESM.
  68131. */
  68132. /**
  68133. * Gets if the current filter is set to filtered ESM.
  68134. */
  68135. useBlurExponentialShadowMap: boolean;
  68136. /**
  68137. * Gets if the current filter is set to "close ESM" (using the inverse of the
  68138. * exponential to prevent steep falloff artifacts).
  68139. */
  68140. /**
  68141. * Sets the current filter to "close ESM" (using the inverse of the
  68142. * exponential to prevent steep falloff artifacts).
  68143. */
  68144. useCloseExponentialShadowMap: boolean;
  68145. /**
  68146. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  68147. * exponential to prevent steep falloff artifacts).
  68148. */
  68149. /**
  68150. * Sets the current filter to filtered "close ESM" (using the inverse of the
  68151. * exponential to prevent steep falloff artifacts).
  68152. */
  68153. useBlurCloseExponentialShadowMap: boolean;
  68154. /**
  68155. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  68156. */
  68157. /**
  68158. * Sets the current filter to "PCF" (percentage closer filtering).
  68159. */
  68160. usePercentageCloserFiltering: boolean;
  68161. private _filteringQuality;
  68162. /**
  68163. * Gets the PCF or PCSS Quality.
  68164. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  68165. */
  68166. /**
  68167. * Sets the PCF or PCSS Quality.
  68168. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  68169. */
  68170. filteringQuality: number;
  68171. /**
  68172. * Gets if the current filter is set to "PCSS" (contact hardening).
  68173. */
  68174. /**
  68175. * Sets the current filter to "PCSS" (contact hardening).
  68176. */
  68177. useContactHardeningShadow: boolean;
  68178. private _contactHardeningLightSizeUVRatio;
  68179. /**
  68180. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  68181. * Using a ratio helps keeping shape stability independently of the map size.
  68182. *
  68183. * It does not account for the light projection as it was having too much
  68184. * instability during the light setup or during light position changes.
  68185. *
  68186. * Only valid if useContactHardeningShadow is true.
  68187. */
  68188. /**
  68189. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  68190. * Using a ratio helps keeping shape stability independently of the map size.
  68191. *
  68192. * It does not account for the light projection as it was having too much
  68193. * instability during the light setup or during light position changes.
  68194. *
  68195. * Only valid if useContactHardeningShadow is true.
  68196. */
  68197. contactHardeningLightSizeUVRatio: number;
  68198. private _darkness;
  68199. /**
  68200. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  68201. * 0 means strongest and 1 would means no shadow.
  68202. * @returns the darkness.
  68203. */
  68204. getDarkness(): number;
  68205. /**
  68206. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  68207. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  68208. * @returns the shadow generator allowing fluent coding.
  68209. */
  68210. setDarkness(darkness: number): ShadowGenerator;
  68211. private _transparencyShadow;
  68212. /**
  68213. * Sets the ability to have transparent shadow (boolean).
  68214. * @param transparent True if transparent else False
  68215. * @returns the shadow generator allowing fluent coding
  68216. */
  68217. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  68218. private _shadowMap;
  68219. private _shadowMap2;
  68220. /**
  68221. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  68222. * @returns The render target texture if present otherwise, null
  68223. */
  68224. getShadowMap(): Nullable<RenderTargetTexture>;
  68225. /**
  68226. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  68227. * @returns The render target texture if the shadow map is present otherwise, null
  68228. */
  68229. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  68230. /**
  68231. * Helper function to add a mesh and its descendants to the list of shadow casters.
  68232. * @param mesh Mesh to add
  68233. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  68234. * @returns the Shadow Generator itself
  68235. */
  68236. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  68237. /**
  68238. * Helper function to remove a mesh and its descendants from the list of shadow casters
  68239. * @param mesh Mesh to remove
  68240. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  68241. * @returns the Shadow Generator itself
  68242. */
  68243. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  68244. /**
  68245. * Controls the extent to which the shadows fade out at the edge of the frustum
  68246. * Used only by directionals and spots
  68247. */
  68248. frustumEdgeFalloff: number;
  68249. private _light;
  68250. /**
  68251. * Returns the associated light object.
  68252. * @returns the light generating the shadow
  68253. */
  68254. getLight(): IShadowLight;
  68255. /**
  68256. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  68257. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  68258. * It might on the other hand introduce peter panning.
  68259. */
  68260. forceBackFacesOnly: boolean;
  68261. private _scene;
  68262. private _lightDirection;
  68263. private _effect;
  68264. private _viewMatrix;
  68265. private _projectionMatrix;
  68266. private _transformMatrix;
  68267. private _cachedPosition;
  68268. private _cachedDirection;
  68269. private _cachedDefines;
  68270. private _currentRenderID;
  68271. private _boxBlurPostprocess;
  68272. private _kernelBlurXPostprocess;
  68273. private _kernelBlurYPostprocess;
  68274. private _blurPostProcesses;
  68275. private _mapSize;
  68276. private _currentFaceIndex;
  68277. private _currentFaceIndexCache;
  68278. private _textureType;
  68279. private _defaultTextureMatrix;
  68280. /** @hidden */
  68281. static _SceneComponentInitialization: (scene: Scene) => void;
  68282. /**
  68283. * Creates a ShadowGenerator object.
  68284. * A ShadowGenerator is the required tool to use the shadows.
  68285. * Each light casting shadows needs to use its own ShadowGenerator.
  68286. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  68287. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  68288. * @param light The light object generating the shadows.
  68289. * @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.
  68290. */
  68291. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  68292. private _initializeGenerator;
  68293. private _initializeShadowMap;
  68294. private _initializeBlurRTTAndPostProcesses;
  68295. private _renderForShadowMap;
  68296. private _renderSubMeshForShadowMap;
  68297. private _applyFilterValues;
  68298. /**
  68299. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68300. * @param onCompiled Callback triggered at the and of the effects compilation
  68301. * @param options Sets of optional options forcing the compilation with different modes
  68302. */
  68303. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  68304. useInstances: boolean;
  68305. }>): void;
  68306. /**
  68307. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68308. * @param options Sets of optional options forcing the compilation with different modes
  68309. * @returns A promise that resolves when the compilation completes
  68310. */
  68311. forceCompilationAsync(options?: Partial<{
  68312. useInstances: boolean;
  68313. }>): Promise<void>;
  68314. /**
  68315. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  68316. * @param subMesh The submesh we want to render in the shadow map
  68317. * @param useInstances Defines wether will draw in the map using instances
  68318. * @returns true if ready otherwise, false
  68319. */
  68320. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68321. /**
  68322. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  68323. * @param defines Defines of the material we want to update
  68324. * @param lightIndex Index of the light in the enabled light list of the material
  68325. */
  68326. prepareDefines(defines: any, lightIndex: number): void;
  68327. /**
  68328. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  68329. * defined in the generator but impacting the effect).
  68330. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  68331. * @param effect The effect we are binfing the information for
  68332. */
  68333. bindShadowLight(lightIndex: string, effect: Effect): void;
  68334. /**
  68335. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  68336. * (eq to shadow prjection matrix * light transform matrix)
  68337. * @returns The transform matrix used to create the shadow map
  68338. */
  68339. getTransformMatrix(): Matrix;
  68340. /**
  68341. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  68342. * Cube and 2D textures for instance.
  68343. */
  68344. recreateShadowMap(): void;
  68345. private _disposeBlurPostProcesses;
  68346. private _disposeRTTandPostProcesses;
  68347. /**
  68348. * Disposes the ShadowGenerator.
  68349. * Returns nothing.
  68350. */
  68351. dispose(): void;
  68352. /**
  68353. * Serializes the shadow generator setup to a json object.
  68354. * @returns The serialized JSON object
  68355. */
  68356. serialize(): any;
  68357. /**
  68358. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  68359. * @param parsedShadowGenerator The JSON object to parse
  68360. * @param scene The scene to create the shadow map for
  68361. * @returns The parsed shadow generator
  68362. */
  68363. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  68364. }
  68365. }
  68366. declare module BABYLON {
  68367. /**
  68368. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  68369. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  68370. * 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.
  68371. */
  68372. export abstract class Light extends Node {
  68373. /**
  68374. * Falloff Default: light is falling off following the material specification:
  68375. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  68376. */
  68377. static readonly FALLOFF_DEFAULT: number;
  68378. /**
  68379. * Falloff Physical: light is falling off following the inverse squared distance law.
  68380. */
  68381. static readonly FALLOFF_PHYSICAL: number;
  68382. /**
  68383. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  68384. * to enhance interoperability with other engines.
  68385. */
  68386. static readonly FALLOFF_GLTF: number;
  68387. /**
  68388. * Falloff Standard: light is falling off like in the standard material
  68389. * to enhance interoperability with other materials.
  68390. */
  68391. static readonly FALLOFF_STANDARD: number;
  68392. /**
  68393. * If every light affecting the material is in this lightmapMode,
  68394. * material.lightmapTexture adds or multiplies
  68395. * (depends on material.useLightmapAsShadowmap)
  68396. * after every other light calculations.
  68397. */
  68398. static readonly LIGHTMAP_DEFAULT: number;
  68399. /**
  68400. * material.lightmapTexture as only diffuse lighting from this light
  68401. * adds only specular lighting from this light
  68402. * adds dynamic shadows
  68403. */
  68404. static readonly LIGHTMAP_SPECULAR: number;
  68405. /**
  68406. * material.lightmapTexture as only lighting
  68407. * no light calculation from this light
  68408. * only adds dynamic shadows from this light
  68409. */
  68410. static readonly LIGHTMAP_SHADOWSONLY: number;
  68411. /**
  68412. * Each light type uses the default quantity according to its type:
  68413. * point/spot lights use luminous intensity
  68414. * directional lights use illuminance
  68415. */
  68416. static readonly INTENSITYMODE_AUTOMATIC: number;
  68417. /**
  68418. * lumen (lm)
  68419. */
  68420. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  68421. /**
  68422. * candela (lm/sr)
  68423. */
  68424. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  68425. /**
  68426. * lux (lm/m^2)
  68427. */
  68428. static readonly INTENSITYMODE_ILLUMINANCE: number;
  68429. /**
  68430. * nit (cd/m^2)
  68431. */
  68432. static readonly INTENSITYMODE_LUMINANCE: number;
  68433. /**
  68434. * Light type const id of the point light.
  68435. */
  68436. static readonly LIGHTTYPEID_POINTLIGHT: number;
  68437. /**
  68438. * Light type const id of the directional light.
  68439. */
  68440. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  68441. /**
  68442. * Light type const id of the spot light.
  68443. */
  68444. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  68445. /**
  68446. * Light type const id of the hemispheric light.
  68447. */
  68448. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  68449. /**
  68450. * Diffuse gives the basic color to an object.
  68451. */
  68452. diffuse: Color3;
  68453. /**
  68454. * Specular produces a highlight color on an object.
  68455. * Note: This is note affecting PBR materials.
  68456. */
  68457. specular: Color3;
  68458. /**
  68459. * Defines the falloff type for this light. This lets overrriding how punctual light are
  68460. * falling off base on range or angle.
  68461. * This can be set to any values in Light.FALLOFF_x.
  68462. *
  68463. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  68464. * other types of materials.
  68465. */
  68466. falloffType: number;
  68467. /**
  68468. * Strength of the light.
  68469. * Note: By default it is define in the framework own unit.
  68470. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  68471. */
  68472. intensity: number;
  68473. private _range;
  68474. protected _inverseSquaredRange: number;
  68475. /**
  68476. * Defines how far from the source the light is impacting in scene units.
  68477. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  68478. */
  68479. /**
  68480. * Defines how far from the source the light is impacting in scene units.
  68481. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  68482. */
  68483. range: number;
  68484. /**
  68485. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  68486. * of light.
  68487. */
  68488. private _photometricScale;
  68489. private _intensityMode;
  68490. /**
  68491. * Gets the photometric scale used to interpret the intensity.
  68492. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  68493. */
  68494. /**
  68495. * Sets the photometric scale used to interpret the intensity.
  68496. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  68497. */
  68498. intensityMode: number;
  68499. private _radius;
  68500. /**
  68501. * Gets the light radius used by PBR Materials to simulate soft area lights.
  68502. */
  68503. /**
  68504. * sets the light radius used by PBR Materials to simulate soft area lights.
  68505. */
  68506. radius: number;
  68507. private _renderPriority;
  68508. /**
  68509. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  68510. * exceeding the number allowed of the materials.
  68511. */
  68512. renderPriority: number;
  68513. private _shadowEnabled;
  68514. /**
  68515. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  68516. * the current shadow generator.
  68517. */
  68518. /**
  68519. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  68520. * the current shadow generator.
  68521. */
  68522. shadowEnabled: boolean;
  68523. private _includedOnlyMeshes;
  68524. /**
  68525. * Gets the only meshes impacted by this light.
  68526. */
  68527. /**
  68528. * Sets the only meshes impacted by this light.
  68529. */
  68530. includedOnlyMeshes: AbstractMesh[];
  68531. private _excludedMeshes;
  68532. /**
  68533. * Gets the meshes not impacted by this light.
  68534. */
  68535. /**
  68536. * Sets the meshes not impacted by this light.
  68537. */
  68538. excludedMeshes: AbstractMesh[];
  68539. private _excludeWithLayerMask;
  68540. /**
  68541. * Gets the layer id use to find what meshes are not impacted by the light.
  68542. * Inactive if 0
  68543. */
  68544. /**
  68545. * Sets the layer id use to find what meshes are not impacted by the light.
  68546. * Inactive if 0
  68547. */
  68548. excludeWithLayerMask: number;
  68549. private _includeOnlyWithLayerMask;
  68550. /**
  68551. * Gets the layer id use to find what meshes are impacted by the light.
  68552. * Inactive if 0
  68553. */
  68554. /**
  68555. * Sets the layer id use to find what meshes are impacted by the light.
  68556. * Inactive if 0
  68557. */
  68558. includeOnlyWithLayerMask: number;
  68559. private _lightmapMode;
  68560. /**
  68561. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  68562. */
  68563. /**
  68564. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  68565. */
  68566. lightmapMode: number;
  68567. /**
  68568. * Shadow generator associted to the light.
  68569. * @hidden Internal use only.
  68570. */
  68571. _shadowGenerator: Nullable<IShadowGenerator>;
  68572. /**
  68573. * @hidden Internal use only.
  68574. */
  68575. _excludedMeshesIds: string[];
  68576. /**
  68577. * @hidden Internal use only.
  68578. */
  68579. _includedOnlyMeshesIds: string[];
  68580. /**
  68581. * The current light unifom buffer.
  68582. * @hidden Internal use only.
  68583. */
  68584. _uniformBuffer: UniformBuffer;
  68585. /**
  68586. * Creates a Light object in the scene.
  68587. * Documentation : https://doc.babylonjs.com/babylon101/lights
  68588. * @param name The firendly name of the light
  68589. * @param scene The scene the light belongs too
  68590. */
  68591. constructor(name: string, scene: Scene);
  68592. protected abstract _buildUniformLayout(): void;
  68593. /**
  68594. * Sets the passed Effect "effect" with the Light information.
  68595. * @param effect The effect to update
  68596. * @param lightIndex The index of the light in the effect to update
  68597. * @returns The light
  68598. */
  68599. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  68600. /**
  68601. * Returns the string "Light".
  68602. * @returns the class name
  68603. */
  68604. getClassName(): string;
  68605. /** @hidden */
  68606. readonly _isLight: boolean;
  68607. /**
  68608. * Converts the light information to a readable string for debug purpose.
  68609. * @param fullDetails Supports for multiple levels of logging within scene loading
  68610. * @returns the human readable light info
  68611. */
  68612. toString(fullDetails?: boolean): string;
  68613. /** @hidden */
  68614. protected _syncParentEnabledState(): void;
  68615. /**
  68616. * Set the enabled state of this node.
  68617. * @param value - the new enabled state
  68618. */
  68619. setEnabled(value: boolean): void;
  68620. /**
  68621. * Returns the Light associated shadow generator if any.
  68622. * @return the associated shadow generator.
  68623. */
  68624. getShadowGenerator(): Nullable<IShadowGenerator>;
  68625. /**
  68626. * Returns a Vector3, the absolute light position in the World.
  68627. * @returns the world space position of the light
  68628. */
  68629. getAbsolutePosition(): Vector3;
  68630. /**
  68631. * Specifies if the light will affect the passed mesh.
  68632. * @param mesh The mesh to test against the light
  68633. * @return true the mesh is affected otherwise, false.
  68634. */
  68635. canAffectMesh(mesh: AbstractMesh): boolean;
  68636. /**
  68637. * Sort function to order lights for rendering.
  68638. * @param a First Light object to compare to second.
  68639. * @param b Second Light object to compare first.
  68640. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  68641. */
  68642. static CompareLightsPriority(a: Light, b: Light): number;
  68643. /**
  68644. * Releases resources associated with this node.
  68645. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  68646. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  68647. */
  68648. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  68649. /**
  68650. * Returns the light type ID (integer).
  68651. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  68652. */
  68653. getTypeID(): number;
  68654. /**
  68655. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  68656. * @returns the scaled intensity in intensity mode unit
  68657. */
  68658. getScaledIntensity(): number;
  68659. /**
  68660. * Returns a new Light object, named "name", from the current one.
  68661. * @param name The name of the cloned light
  68662. * @returns the new created light
  68663. */
  68664. clone(name: string): Nullable<Light>;
  68665. /**
  68666. * Serializes the current light into a Serialization object.
  68667. * @returns the serialized object.
  68668. */
  68669. serialize(): any;
  68670. /**
  68671. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  68672. * This new light is named "name" and added to the passed scene.
  68673. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  68674. * @param name The friendly name of the light
  68675. * @param scene The scene the new light will belong to
  68676. * @returns the constructor function
  68677. */
  68678. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  68679. /**
  68680. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  68681. * @param parsedLight The JSON representation of the light
  68682. * @param scene The scene to create the parsed light in
  68683. * @returns the created light after parsing
  68684. */
  68685. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  68686. private _hookArrayForExcluded;
  68687. private _hookArrayForIncludedOnly;
  68688. private _resyncMeshes;
  68689. /**
  68690. * Forces the meshes to update their light related information in their rendering used effects
  68691. * @hidden Internal Use Only
  68692. */
  68693. _markMeshesAsLightDirty(): void;
  68694. /**
  68695. * Recomputes the cached photometric scale if needed.
  68696. */
  68697. private _computePhotometricScale;
  68698. /**
  68699. * Returns the Photometric Scale according to the light type and intensity mode.
  68700. */
  68701. private _getPhotometricScale;
  68702. /**
  68703. * Reorder the light in the scene according to their defined priority.
  68704. * @hidden Internal Use Only
  68705. */
  68706. _reorderLightsInScene(): void;
  68707. /**
  68708. * Prepares the list of defines specific to the light type.
  68709. * @param defines the list of defines
  68710. * @param lightIndex defines the index of the light for the effect
  68711. */
  68712. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  68713. }
  68714. }
  68715. declare module BABYLON {
  68716. /**
  68717. * Interface used to define Action
  68718. */
  68719. export interface IAction {
  68720. /**
  68721. * Trigger for the action
  68722. */
  68723. trigger: number;
  68724. /** Options of the trigger */
  68725. triggerOptions: any;
  68726. /**
  68727. * Gets the trigger parameters
  68728. * @returns the trigger parameters
  68729. */
  68730. getTriggerParameter(): any;
  68731. /**
  68732. * Internal only - executes current action event
  68733. * @hidden
  68734. */
  68735. _executeCurrent(evt?: ActionEvent): void;
  68736. /**
  68737. * Serialize placeholder for child classes
  68738. * @param parent of child
  68739. * @returns the serialized object
  68740. */
  68741. serialize(parent: any): any;
  68742. /**
  68743. * Internal only
  68744. * @hidden
  68745. */
  68746. _prepare(): void;
  68747. /**
  68748. * Internal only - manager for action
  68749. * @hidden
  68750. */
  68751. _actionManager: AbstractActionManager;
  68752. }
  68753. /**
  68754. * The action to be carried out following a trigger
  68755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  68756. */
  68757. export class Action implements IAction {
  68758. /** the trigger, with or without parameters, for the action */
  68759. triggerOptions: any;
  68760. /**
  68761. * Trigger for the action
  68762. */
  68763. trigger: number;
  68764. /**
  68765. * Internal only - manager for action
  68766. * @hidden
  68767. */
  68768. _actionManager: ActionManager;
  68769. private _nextActiveAction;
  68770. private _child;
  68771. private _condition?;
  68772. private _triggerParameter;
  68773. /**
  68774. * An event triggered prior to action being executed.
  68775. */
  68776. onBeforeExecuteObservable: Observable<Action>;
  68777. /**
  68778. * Creates a new Action
  68779. * @param triggerOptions the trigger, with or without parameters, for the action
  68780. * @param condition an optional determinant of action
  68781. */
  68782. constructor(
  68783. /** the trigger, with or without parameters, for the action */
  68784. triggerOptions: any, condition?: Condition);
  68785. /**
  68786. * Internal only
  68787. * @hidden
  68788. */
  68789. _prepare(): void;
  68790. /**
  68791. * Gets the trigger parameters
  68792. * @returns the trigger parameters
  68793. */
  68794. getTriggerParameter(): any;
  68795. /**
  68796. * Internal only - executes current action event
  68797. * @hidden
  68798. */
  68799. _executeCurrent(evt?: ActionEvent): void;
  68800. /**
  68801. * Execute placeholder for child classes
  68802. * @param evt optional action event
  68803. */
  68804. execute(evt?: ActionEvent): void;
  68805. /**
  68806. * Skips to next active action
  68807. */
  68808. skipToNextActiveAction(): void;
  68809. /**
  68810. * Adds action to chain of actions, may be a DoNothingAction
  68811. * @param action defines the next action to execute
  68812. * @returns The action passed in
  68813. * @see https://www.babylonjs-playground.com/#1T30HR#0
  68814. */
  68815. then(action: Action): Action;
  68816. /**
  68817. * Internal only
  68818. * @hidden
  68819. */
  68820. _getProperty(propertyPath: string): string;
  68821. /**
  68822. * Internal only
  68823. * @hidden
  68824. */
  68825. _getEffectiveTarget(target: any, propertyPath: string): any;
  68826. /**
  68827. * Serialize placeholder for child classes
  68828. * @param parent of child
  68829. * @returns the serialized object
  68830. */
  68831. serialize(parent: any): any;
  68832. /**
  68833. * Internal only called by serialize
  68834. * @hidden
  68835. */
  68836. protected _serialize(serializedAction: any, parent?: any): any;
  68837. /**
  68838. * Internal only
  68839. * @hidden
  68840. */
  68841. static _SerializeValueAsString: (value: any) => string;
  68842. /**
  68843. * Internal only
  68844. * @hidden
  68845. */
  68846. static _GetTargetProperty: (target: Scene | Node) => {
  68847. name: string;
  68848. targetType: string;
  68849. value: string;
  68850. };
  68851. }
  68852. }
  68853. declare module BABYLON {
  68854. /**
  68855. * A Condition applied to an Action
  68856. */
  68857. export class Condition {
  68858. /**
  68859. * Internal only - manager for action
  68860. * @hidden
  68861. */
  68862. _actionManager: ActionManager;
  68863. /**
  68864. * Internal only
  68865. * @hidden
  68866. */
  68867. _evaluationId: number;
  68868. /**
  68869. * Internal only
  68870. * @hidden
  68871. */
  68872. _currentResult: boolean;
  68873. /**
  68874. * Creates a new Condition
  68875. * @param actionManager the manager of the action the condition is applied to
  68876. */
  68877. constructor(actionManager: ActionManager);
  68878. /**
  68879. * Check if the current condition is valid
  68880. * @returns a boolean
  68881. */
  68882. isValid(): boolean;
  68883. /**
  68884. * Internal only
  68885. * @hidden
  68886. */
  68887. _getProperty(propertyPath: string): string;
  68888. /**
  68889. * Internal only
  68890. * @hidden
  68891. */
  68892. _getEffectiveTarget(target: any, propertyPath: string): any;
  68893. /**
  68894. * Serialize placeholder for child classes
  68895. * @returns the serialized object
  68896. */
  68897. serialize(): any;
  68898. /**
  68899. * Internal only
  68900. * @hidden
  68901. */
  68902. protected _serialize(serializedCondition: any): any;
  68903. }
  68904. /**
  68905. * Defines specific conditional operators as extensions of Condition
  68906. */
  68907. export class ValueCondition extends Condition {
  68908. /** path to specify the property of the target the conditional operator uses */
  68909. propertyPath: string;
  68910. /** the value compared by the conditional operator against the current value of the property */
  68911. value: any;
  68912. /** the conditional operator, default ValueCondition.IsEqual */
  68913. operator: number;
  68914. /**
  68915. * Internal only
  68916. * @hidden
  68917. */
  68918. private static _IsEqual;
  68919. /**
  68920. * Internal only
  68921. * @hidden
  68922. */
  68923. private static _IsDifferent;
  68924. /**
  68925. * Internal only
  68926. * @hidden
  68927. */
  68928. private static _IsGreater;
  68929. /**
  68930. * Internal only
  68931. * @hidden
  68932. */
  68933. private static _IsLesser;
  68934. /**
  68935. * returns the number for IsEqual
  68936. */
  68937. static readonly IsEqual: number;
  68938. /**
  68939. * Returns the number for IsDifferent
  68940. */
  68941. static readonly IsDifferent: number;
  68942. /**
  68943. * Returns the number for IsGreater
  68944. */
  68945. static readonly IsGreater: number;
  68946. /**
  68947. * Returns the number for IsLesser
  68948. */
  68949. static readonly IsLesser: number;
  68950. /**
  68951. * Internal only The action manager for the condition
  68952. * @hidden
  68953. */
  68954. _actionManager: ActionManager;
  68955. /**
  68956. * Internal only
  68957. * @hidden
  68958. */
  68959. private _target;
  68960. /**
  68961. * Internal only
  68962. * @hidden
  68963. */
  68964. private _effectiveTarget;
  68965. /**
  68966. * Internal only
  68967. * @hidden
  68968. */
  68969. private _property;
  68970. /**
  68971. * Creates a new ValueCondition
  68972. * @param actionManager manager for the action the condition applies to
  68973. * @param target for the action
  68974. * @param propertyPath path to specify the property of the target the conditional operator uses
  68975. * @param value the value compared by the conditional operator against the current value of the property
  68976. * @param operator the conditional operator, default ValueCondition.IsEqual
  68977. */
  68978. constructor(actionManager: ActionManager, target: any,
  68979. /** path to specify the property of the target the conditional operator uses */
  68980. propertyPath: string,
  68981. /** the value compared by the conditional operator against the current value of the property */
  68982. value: any,
  68983. /** the conditional operator, default ValueCondition.IsEqual */
  68984. operator?: number);
  68985. /**
  68986. * Compares the given value with the property value for the specified conditional operator
  68987. * @returns the result of the comparison
  68988. */
  68989. isValid(): boolean;
  68990. /**
  68991. * Serialize the ValueCondition into a JSON compatible object
  68992. * @returns serialization object
  68993. */
  68994. serialize(): any;
  68995. /**
  68996. * Gets the name of the conditional operator for the ValueCondition
  68997. * @param operator the conditional operator
  68998. * @returns the name
  68999. */
  69000. static GetOperatorName(operator: number): string;
  69001. }
  69002. /**
  69003. * Defines a predicate condition as an extension of Condition
  69004. */
  69005. export class PredicateCondition extends Condition {
  69006. /** defines the predicate function used to validate the condition */
  69007. predicate: () => boolean;
  69008. /**
  69009. * Internal only - manager for action
  69010. * @hidden
  69011. */
  69012. _actionManager: ActionManager;
  69013. /**
  69014. * Creates a new PredicateCondition
  69015. * @param actionManager manager for the action the condition applies to
  69016. * @param predicate defines the predicate function used to validate the condition
  69017. */
  69018. constructor(actionManager: ActionManager,
  69019. /** defines the predicate function used to validate the condition */
  69020. predicate: () => boolean);
  69021. /**
  69022. * @returns the validity of the predicate condition
  69023. */
  69024. isValid(): boolean;
  69025. }
  69026. /**
  69027. * Defines a state condition as an extension of Condition
  69028. */
  69029. export class StateCondition extends Condition {
  69030. /** Value to compare with target state */
  69031. value: string;
  69032. /**
  69033. * Internal only - manager for action
  69034. * @hidden
  69035. */
  69036. _actionManager: ActionManager;
  69037. /**
  69038. * Internal only
  69039. * @hidden
  69040. */
  69041. private _target;
  69042. /**
  69043. * Creates a new StateCondition
  69044. * @param actionManager manager for the action the condition applies to
  69045. * @param target of the condition
  69046. * @param value to compare with target state
  69047. */
  69048. constructor(actionManager: ActionManager, target: any,
  69049. /** Value to compare with target state */
  69050. value: string);
  69051. /**
  69052. * Gets a boolean indicating if the current condition is met
  69053. * @returns the validity of the state
  69054. */
  69055. isValid(): boolean;
  69056. /**
  69057. * Serialize the StateCondition into a JSON compatible object
  69058. * @returns serialization object
  69059. */
  69060. serialize(): any;
  69061. }
  69062. }
  69063. declare module BABYLON {
  69064. /**
  69065. * This defines an action responsible to toggle a boolean once triggered.
  69066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69067. */
  69068. export class SwitchBooleanAction extends Action {
  69069. /**
  69070. * The path to the boolean property in the target object
  69071. */
  69072. propertyPath: string;
  69073. private _target;
  69074. private _effectiveTarget;
  69075. private _property;
  69076. /**
  69077. * Instantiate the action
  69078. * @param triggerOptions defines the trigger options
  69079. * @param target defines the object containing the boolean
  69080. * @param propertyPath defines the path to the boolean property in the target object
  69081. * @param condition defines the trigger related conditions
  69082. */
  69083. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  69084. /** @hidden */
  69085. _prepare(): void;
  69086. /**
  69087. * Execute the action toggle the boolean value.
  69088. */
  69089. execute(): void;
  69090. /**
  69091. * Serializes the actions and its related information.
  69092. * @param parent defines the object to serialize in
  69093. * @returns the serialized object
  69094. */
  69095. serialize(parent: any): any;
  69096. }
  69097. /**
  69098. * This defines an action responsible to set a the state field of the target
  69099. * to a desired value once triggered.
  69100. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69101. */
  69102. export class SetStateAction extends Action {
  69103. /**
  69104. * The value to store in the state field.
  69105. */
  69106. value: string;
  69107. private _target;
  69108. /**
  69109. * Instantiate the action
  69110. * @param triggerOptions defines the trigger options
  69111. * @param target defines the object containing the state property
  69112. * @param value defines the value to store in the state field
  69113. * @param condition defines the trigger related conditions
  69114. */
  69115. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  69116. /**
  69117. * Execute the action and store the value on the target state property.
  69118. */
  69119. execute(): void;
  69120. /**
  69121. * Serializes the actions and its related information.
  69122. * @param parent defines the object to serialize in
  69123. * @returns the serialized object
  69124. */
  69125. serialize(parent: any): any;
  69126. }
  69127. /**
  69128. * This defines an action responsible to set a property of the target
  69129. * to a desired value once triggered.
  69130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69131. */
  69132. export class SetValueAction extends Action {
  69133. /**
  69134. * The path of the property to set in the target.
  69135. */
  69136. propertyPath: string;
  69137. /**
  69138. * The value to set in the property
  69139. */
  69140. value: any;
  69141. private _target;
  69142. private _effectiveTarget;
  69143. private _property;
  69144. /**
  69145. * Instantiate the action
  69146. * @param triggerOptions defines the trigger options
  69147. * @param target defines the object containing the property
  69148. * @param propertyPath defines the path of the property to set in the target
  69149. * @param value defines the value to set in the property
  69150. * @param condition defines the trigger related conditions
  69151. */
  69152. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  69153. /** @hidden */
  69154. _prepare(): void;
  69155. /**
  69156. * Execute the action and set the targetted property to the desired value.
  69157. */
  69158. execute(): void;
  69159. /**
  69160. * Serializes the actions and its related information.
  69161. * @param parent defines the object to serialize in
  69162. * @returns the serialized object
  69163. */
  69164. serialize(parent: any): any;
  69165. }
  69166. /**
  69167. * This defines an action responsible to increment the target value
  69168. * to a desired value once triggered.
  69169. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69170. */
  69171. export class IncrementValueAction extends Action {
  69172. /**
  69173. * The path of the property to increment in the target.
  69174. */
  69175. propertyPath: string;
  69176. /**
  69177. * The value we should increment the property by.
  69178. */
  69179. value: any;
  69180. private _target;
  69181. private _effectiveTarget;
  69182. private _property;
  69183. /**
  69184. * Instantiate the action
  69185. * @param triggerOptions defines the trigger options
  69186. * @param target defines the object containing the property
  69187. * @param propertyPath defines the path of the property to increment in the target
  69188. * @param value defines the value value we should increment the property by
  69189. * @param condition defines the trigger related conditions
  69190. */
  69191. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  69192. /** @hidden */
  69193. _prepare(): void;
  69194. /**
  69195. * Execute the action and increment the target of the value amount.
  69196. */
  69197. execute(): void;
  69198. /**
  69199. * Serializes the actions and its related information.
  69200. * @param parent defines the object to serialize in
  69201. * @returns the serialized object
  69202. */
  69203. serialize(parent: any): any;
  69204. }
  69205. /**
  69206. * This defines an action responsible to start an animation once triggered.
  69207. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69208. */
  69209. export class PlayAnimationAction extends Action {
  69210. /**
  69211. * Where the animation should start (animation frame)
  69212. */
  69213. from: number;
  69214. /**
  69215. * Where the animation should stop (animation frame)
  69216. */
  69217. to: number;
  69218. /**
  69219. * Define if the animation should loop or stop after the first play.
  69220. */
  69221. loop?: boolean;
  69222. private _target;
  69223. /**
  69224. * Instantiate the action
  69225. * @param triggerOptions defines the trigger options
  69226. * @param target defines the target animation or animation name
  69227. * @param from defines from where the animation should start (animation frame)
  69228. * @param end defines where the animation should stop (animation frame)
  69229. * @param loop defines if the animation should loop or stop after the first play
  69230. * @param condition defines the trigger related conditions
  69231. */
  69232. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  69233. /** @hidden */
  69234. _prepare(): void;
  69235. /**
  69236. * Execute the action and play the animation.
  69237. */
  69238. execute(): void;
  69239. /**
  69240. * Serializes the actions and its related information.
  69241. * @param parent defines the object to serialize in
  69242. * @returns the serialized object
  69243. */
  69244. serialize(parent: any): any;
  69245. }
  69246. /**
  69247. * This defines an action responsible to stop an animation once triggered.
  69248. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69249. */
  69250. export class StopAnimationAction extends Action {
  69251. private _target;
  69252. /**
  69253. * Instantiate the action
  69254. * @param triggerOptions defines the trigger options
  69255. * @param target defines the target animation or animation name
  69256. * @param condition defines the trigger related conditions
  69257. */
  69258. constructor(triggerOptions: any, target: any, condition?: Condition);
  69259. /** @hidden */
  69260. _prepare(): void;
  69261. /**
  69262. * Execute the action and stop the animation.
  69263. */
  69264. execute(): void;
  69265. /**
  69266. * Serializes the actions and its related information.
  69267. * @param parent defines the object to serialize in
  69268. * @returns the serialized object
  69269. */
  69270. serialize(parent: any): any;
  69271. }
  69272. /**
  69273. * This defines an action responsible that does nothing once triggered.
  69274. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69275. */
  69276. export class DoNothingAction extends Action {
  69277. /**
  69278. * Instantiate the action
  69279. * @param triggerOptions defines the trigger options
  69280. * @param condition defines the trigger related conditions
  69281. */
  69282. constructor(triggerOptions?: any, condition?: Condition);
  69283. /**
  69284. * Execute the action and do nothing.
  69285. */
  69286. execute(): void;
  69287. /**
  69288. * Serializes the actions and its related information.
  69289. * @param parent defines the object to serialize in
  69290. * @returns the serialized object
  69291. */
  69292. serialize(parent: any): any;
  69293. }
  69294. /**
  69295. * This defines an action responsible to trigger several actions once triggered.
  69296. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69297. */
  69298. export class CombineAction extends Action {
  69299. /**
  69300. * The list of aggregated animations to run.
  69301. */
  69302. children: Action[];
  69303. /**
  69304. * Instantiate the action
  69305. * @param triggerOptions defines the trigger options
  69306. * @param children defines the list of aggregated animations to run
  69307. * @param condition defines the trigger related conditions
  69308. */
  69309. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  69310. /** @hidden */
  69311. _prepare(): void;
  69312. /**
  69313. * Execute the action and executes all the aggregated actions.
  69314. */
  69315. execute(evt: ActionEvent): void;
  69316. /**
  69317. * Serializes the actions and its related information.
  69318. * @param parent defines the object to serialize in
  69319. * @returns the serialized object
  69320. */
  69321. serialize(parent: any): any;
  69322. }
  69323. /**
  69324. * This defines an action responsible to run code (external event) once triggered.
  69325. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69326. */
  69327. export class ExecuteCodeAction extends Action {
  69328. /**
  69329. * The callback function to run.
  69330. */
  69331. func: (evt: ActionEvent) => void;
  69332. /**
  69333. * Instantiate the action
  69334. * @param triggerOptions defines the trigger options
  69335. * @param func defines the callback function to run
  69336. * @param condition defines the trigger related conditions
  69337. */
  69338. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  69339. /**
  69340. * Execute the action and run the attached code.
  69341. */
  69342. execute(evt: ActionEvent): void;
  69343. }
  69344. /**
  69345. * This defines an action responsible to set the parent property of the target once triggered.
  69346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69347. */
  69348. export class SetParentAction extends Action {
  69349. private _parent;
  69350. private _target;
  69351. /**
  69352. * Instantiate the action
  69353. * @param triggerOptions defines the trigger options
  69354. * @param target defines the target containing the parent property
  69355. * @param parent defines from where the animation should start (animation frame)
  69356. * @param condition defines the trigger related conditions
  69357. */
  69358. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  69359. /** @hidden */
  69360. _prepare(): void;
  69361. /**
  69362. * Execute the action and set the parent property.
  69363. */
  69364. execute(): void;
  69365. /**
  69366. * Serializes the actions and its related information.
  69367. * @param parent defines the object to serialize in
  69368. * @returns the serialized object
  69369. */
  69370. serialize(parent: any): any;
  69371. }
  69372. }
  69373. declare module BABYLON {
  69374. /**
  69375. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  69376. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  69377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  69378. */
  69379. export class ActionManager extends AbstractActionManager {
  69380. /**
  69381. * Nothing
  69382. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69383. */
  69384. static readonly NothingTrigger: number;
  69385. /**
  69386. * On pick
  69387. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69388. */
  69389. static readonly OnPickTrigger: number;
  69390. /**
  69391. * On left pick
  69392. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69393. */
  69394. static readonly OnLeftPickTrigger: number;
  69395. /**
  69396. * On right pick
  69397. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69398. */
  69399. static readonly OnRightPickTrigger: number;
  69400. /**
  69401. * On center pick
  69402. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69403. */
  69404. static readonly OnCenterPickTrigger: number;
  69405. /**
  69406. * On pick down
  69407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69408. */
  69409. static readonly OnPickDownTrigger: number;
  69410. /**
  69411. * On double pick
  69412. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69413. */
  69414. static readonly OnDoublePickTrigger: number;
  69415. /**
  69416. * On pick up
  69417. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69418. */
  69419. static readonly OnPickUpTrigger: number;
  69420. /**
  69421. * On pick out.
  69422. * This trigger will only be raised if you also declared a OnPickDown
  69423. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69424. */
  69425. static readonly OnPickOutTrigger: number;
  69426. /**
  69427. * On long press
  69428. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69429. */
  69430. static readonly OnLongPressTrigger: number;
  69431. /**
  69432. * On pointer over
  69433. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69434. */
  69435. static readonly OnPointerOverTrigger: number;
  69436. /**
  69437. * On pointer out
  69438. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69439. */
  69440. static readonly OnPointerOutTrigger: number;
  69441. /**
  69442. * On every frame
  69443. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69444. */
  69445. static readonly OnEveryFrameTrigger: number;
  69446. /**
  69447. * On intersection enter
  69448. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69449. */
  69450. static readonly OnIntersectionEnterTrigger: number;
  69451. /**
  69452. * On intersection exit
  69453. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69454. */
  69455. static readonly OnIntersectionExitTrigger: number;
  69456. /**
  69457. * On key down
  69458. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69459. */
  69460. static readonly OnKeyDownTrigger: number;
  69461. /**
  69462. * On key up
  69463. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  69464. */
  69465. static readonly OnKeyUpTrigger: number;
  69466. private _scene;
  69467. /**
  69468. * Creates a new action manager
  69469. * @param scene defines the hosting scene
  69470. */
  69471. constructor(scene: Scene);
  69472. /**
  69473. * Releases all associated resources
  69474. */
  69475. dispose(): void;
  69476. /**
  69477. * Gets hosting scene
  69478. * @returns the hosting scene
  69479. */
  69480. getScene(): Scene;
  69481. /**
  69482. * Does this action manager handles actions of any of the given triggers
  69483. * @param triggers defines the triggers to be tested
  69484. * @return a boolean indicating whether one (or more) of the triggers is handled
  69485. */
  69486. hasSpecificTriggers(triggers: number[]): boolean;
  69487. /**
  69488. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  69489. * speed.
  69490. * @param triggerA defines the trigger to be tested
  69491. * @param triggerB defines the trigger to be tested
  69492. * @return a boolean indicating whether one (or more) of the triggers is handled
  69493. */
  69494. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  69495. /**
  69496. * Does this action manager handles actions of a given trigger
  69497. * @param trigger defines the trigger to be tested
  69498. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  69499. * @return whether the trigger is handled
  69500. */
  69501. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  69502. /**
  69503. * Does this action manager has pointer triggers
  69504. */
  69505. readonly hasPointerTriggers: boolean;
  69506. /**
  69507. * Does this action manager has pick triggers
  69508. */
  69509. readonly hasPickTriggers: boolean;
  69510. /**
  69511. * Registers an action to this action manager
  69512. * @param action defines the action to be registered
  69513. * @return the action amended (prepared) after registration
  69514. */
  69515. registerAction(action: IAction): Nullable<IAction>;
  69516. /**
  69517. * Unregisters an action to this action manager
  69518. * @param action defines the action to be unregistered
  69519. * @return a boolean indicating whether the action has been unregistered
  69520. */
  69521. unregisterAction(action: IAction): Boolean;
  69522. /**
  69523. * Process a specific trigger
  69524. * @param trigger defines the trigger to process
  69525. * @param evt defines the event details to be processed
  69526. */
  69527. processTrigger(trigger: number, evt?: IActionEvent): void;
  69528. /** @hidden */
  69529. _getEffectiveTarget(target: any, propertyPath: string): any;
  69530. /** @hidden */
  69531. _getProperty(propertyPath: string): string;
  69532. /**
  69533. * Serialize this manager to a JSON object
  69534. * @param name defines the property name to store this manager
  69535. * @returns a JSON representation of this manager
  69536. */
  69537. serialize(name: string): any;
  69538. /**
  69539. * Creates a new ActionManager from a JSON data
  69540. * @param parsedActions defines the JSON data to read from
  69541. * @param object defines the hosting mesh
  69542. * @param scene defines the hosting scene
  69543. */
  69544. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  69545. /**
  69546. * Get a trigger name by index
  69547. * @param trigger defines the trigger index
  69548. * @returns a trigger name
  69549. */
  69550. static GetTriggerName(trigger: number): string;
  69551. }
  69552. }
  69553. declare module BABYLON {
  69554. /**
  69555. * Class representing a ray with position and direction
  69556. */
  69557. export class Ray {
  69558. /** origin point */
  69559. origin: Vector3;
  69560. /** direction */
  69561. direction: Vector3;
  69562. /** length of the ray */
  69563. length: number;
  69564. private static readonly TmpVector3;
  69565. private _tmpRay;
  69566. /**
  69567. * Creates a new ray
  69568. * @param origin origin point
  69569. * @param direction direction
  69570. * @param length length of the ray
  69571. */
  69572. constructor(
  69573. /** origin point */
  69574. origin: Vector3,
  69575. /** direction */
  69576. direction: Vector3,
  69577. /** length of the ray */
  69578. length?: number);
  69579. /**
  69580. * Checks if the ray intersects a box
  69581. * @param minimum bound of the box
  69582. * @param maximum bound of the box
  69583. * @param intersectionTreshold extra extend to be added to the box in all direction
  69584. * @returns if the box was hit
  69585. */
  69586. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  69587. /**
  69588. * Checks if the ray intersects a box
  69589. * @param box the bounding box to check
  69590. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  69591. * @returns if the box was hit
  69592. */
  69593. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  69594. /**
  69595. * If the ray hits a sphere
  69596. * @param sphere the bounding sphere to check
  69597. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  69598. * @returns true if it hits the sphere
  69599. */
  69600. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  69601. /**
  69602. * If the ray hits a triange
  69603. * @param vertex0 triangle vertex
  69604. * @param vertex1 triangle vertex
  69605. * @param vertex2 triangle vertex
  69606. * @returns intersection information if hit
  69607. */
  69608. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  69609. /**
  69610. * Checks if ray intersects a plane
  69611. * @param plane the plane to check
  69612. * @returns the distance away it was hit
  69613. */
  69614. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  69615. /**
  69616. * Checks if ray intersects a mesh
  69617. * @param mesh the mesh to check
  69618. * @param fastCheck if only the bounding box should checked
  69619. * @returns picking info of the intersecton
  69620. */
  69621. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  69622. /**
  69623. * Checks if ray intersects a mesh
  69624. * @param meshes the meshes to check
  69625. * @param fastCheck if only the bounding box should checked
  69626. * @param results array to store result in
  69627. * @returns Array of picking infos
  69628. */
  69629. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  69630. private _comparePickingInfo;
  69631. private static smallnum;
  69632. private static rayl;
  69633. /**
  69634. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  69635. * @param sega the first point of the segment to test the intersection against
  69636. * @param segb the second point of the segment to test the intersection against
  69637. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  69638. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  69639. */
  69640. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  69641. /**
  69642. * Update the ray from viewport position
  69643. * @param x position
  69644. * @param y y position
  69645. * @param viewportWidth viewport width
  69646. * @param viewportHeight viewport height
  69647. * @param world world matrix
  69648. * @param view view matrix
  69649. * @param projection projection matrix
  69650. * @returns this ray updated
  69651. */
  69652. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  69653. /**
  69654. * Creates a ray with origin and direction of 0,0,0
  69655. * @returns the new ray
  69656. */
  69657. static Zero(): Ray;
  69658. /**
  69659. * Creates a new ray from screen space and viewport
  69660. * @param x position
  69661. * @param y y position
  69662. * @param viewportWidth viewport width
  69663. * @param viewportHeight viewport height
  69664. * @param world world matrix
  69665. * @param view view matrix
  69666. * @param projection projection matrix
  69667. * @returns new ray
  69668. */
  69669. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  69670. /**
  69671. * 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
  69672. * transformed to the given world matrix.
  69673. * @param origin The origin point
  69674. * @param end The end point
  69675. * @param world a matrix to transform the ray to. Default is the identity matrix.
  69676. * @returns the new ray
  69677. */
  69678. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  69679. /**
  69680. * Transforms a ray by a matrix
  69681. * @param ray ray to transform
  69682. * @param matrix matrix to apply
  69683. * @returns the resulting new ray
  69684. */
  69685. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  69686. /**
  69687. * Transforms a ray by a matrix
  69688. * @param ray ray to transform
  69689. * @param matrix matrix to apply
  69690. * @param result ray to store result in
  69691. */
  69692. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  69693. /**
  69694. * Unproject a ray from screen space to object space
  69695. * @param sourceX defines the screen space x coordinate to use
  69696. * @param sourceY defines the screen space y coordinate to use
  69697. * @param viewportWidth defines the current width of the viewport
  69698. * @param viewportHeight defines the current height of the viewport
  69699. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69700. * @param view defines the view matrix to use
  69701. * @param projection defines the projection matrix to use
  69702. */
  69703. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  69704. }
  69705. /**
  69706. * Type used to define predicate used to select faces when a mesh intersection is detected
  69707. */
  69708. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  69709. interface Scene {
  69710. /** @hidden */
  69711. _tempPickingRay: Nullable<Ray>;
  69712. /** @hidden */
  69713. _cachedRayForTransform: Ray;
  69714. /** @hidden */
  69715. _pickWithRayInverseMatrix: Matrix;
  69716. /** @hidden */
  69717. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  69718. /** @hidden */
  69719. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  69720. }
  69721. }
  69722. declare module BABYLON {
  69723. /**
  69724. * Groups all the scene component constants in one place to ease maintenance.
  69725. * @hidden
  69726. */
  69727. export class SceneComponentConstants {
  69728. static readonly NAME_EFFECTLAYER: string;
  69729. static readonly NAME_LAYER: string;
  69730. static readonly NAME_LENSFLARESYSTEM: string;
  69731. static readonly NAME_BOUNDINGBOXRENDERER: string;
  69732. static readonly NAME_PARTICLESYSTEM: string;
  69733. static readonly NAME_GAMEPAD: string;
  69734. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  69735. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  69736. static readonly NAME_DEPTHRENDERER: string;
  69737. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  69738. static readonly NAME_SPRITE: string;
  69739. static readonly NAME_OUTLINERENDERER: string;
  69740. static readonly NAME_PROCEDURALTEXTURE: string;
  69741. static readonly NAME_SHADOWGENERATOR: string;
  69742. static readonly NAME_OCTREE: string;
  69743. static readonly NAME_PHYSICSENGINE: string;
  69744. static readonly NAME_AUDIO: string;
  69745. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  69746. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  69747. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  69748. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  69749. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  69750. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  69751. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  69752. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  69753. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  69754. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  69755. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  69756. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  69757. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  69758. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  69759. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  69760. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  69761. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  69762. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  69763. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  69764. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  69765. static readonly STEP_AFTERRENDER_AUDIO: number;
  69766. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  69767. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  69768. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  69769. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  69770. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  69771. static readonly STEP_POINTERMOVE_SPRITE: number;
  69772. static readonly STEP_POINTERDOWN_SPRITE: number;
  69773. static readonly STEP_POINTERUP_SPRITE: number;
  69774. }
  69775. /**
  69776. * This represents a scene component.
  69777. *
  69778. * This is used to decouple the dependency the scene is having on the different workloads like
  69779. * layers, post processes...
  69780. */
  69781. export interface ISceneComponent {
  69782. /**
  69783. * The name of the component. Each component must have a unique name.
  69784. */
  69785. name: string;
  69786. /**
  69787. * The scene the component belongs to.
  69788. */
  69789. scene: Scene;
  69790. /**
  69791. * Register the component to one instance of a scene.
  69792. */
  69793. register(): void;
  69794. /**
  69795. * Rebuilds the elements related to this component in case of
  69796. * context lost for instance.
  69797. */
  69798. rebuild(): void;
  69799. /**
  69800. * Disposes the component and the associated ressources.
  69801. */
  69802. dispose(): void;
  69803. }
  69804. /**
  69805. * This represents a SERIALIZABLE scene component.
  69806. *
  69807. * This extends Scene Component to add Serialization methods on top.
  69808. */
  69809. export interface ISceneSerializableComponent extends ISceneComponent {
  69810. /**
  69811. * Adds all the element from the container to the scene
  69812. * @param container the container holding the elements
  69813. */
  69814. addFromContainer(container: AbstractScene): void;
  69815. /**
  69816. * Removes all the elements in the container from the scene
  69817. * @param container contains the elements to remove
  69818. */
  69819. removeFromContainer(container: AbstractScene): void;
  69820. /**
  69821. * Serializes the component data to the specified json object
  69822. * @param serializationObject The object to serialize to
  69823. */
  69824. serialize(serializationObject: any): void;
  69825. }
  69826. /**
  69827. * Strong typing of a Mesh related stage step action
  69828. */
  69829. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  69830. /**
  69831. * Strong typing of a Evaluate Sub Mesh related stage step action
  69832. */
  69833. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  69834. /**
  69835. * Strong typing of a Active Mesh related stage step action
  69836. */
  69837. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  69838. /**
  69839. * Strong typing of a Camera related stage step action
  69840. */
  69841. export type CameraStageAction = (camera: Camera) => void;
  69842. /**
  69843. * Strong typing of a Render Target related stage step action
  69844. */
  69845. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  69846. /**
  69847. * Strong typing of a RenderingGroup related stage step action
  69848. */
  69849. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  69850. /**
  69851. * Strong typing of a Mesh Render related stage step action
  69852. */
  69853. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  69854. /**
  69855. * Strong typing of a simple stage step action
  69856. */
  69857. export type SimpleStageAction = () => void;
  69858. /**
  69859. * Strong typing of a render target action.
  69860. */
  69861. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  69862. /**
  69863. * Strong typing of a pointer move action.
  69864. */
  69865. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  69866. /**
  69867. * Strong typing of a pointer up/down action.
  69868. */
  69869. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  69870. /**
  69871. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  69872. * @hidden
  69873. */
  69874. export class Stage<T extends Function> extends Array<{
  69875. index: number;
  69876. component: ISceneComponent;
  69877. action: T;
  69878. }> {
  69879. /**
  69880. * Hide ctor from the rest of the world.
  69881. * @param items The items to add.
  69882. */
  69883. private constructor();
  69884. /**
  69885. * Creates a new Stage.
  69886. * @returns A new instance of a Stage
  69887. */
  69888. static Create<T extends Function>(): Stage<T>;
  69889. /**
  69890. * Registers a step in an ordered way in the targeted stage.
  69891. * @param index Defines the position to register the step in
  69892. * @param component Defines the component attached to the step
  69893. * @param action Defines the action to launch during the step
  69894. */
  69895. registerStep(index: number, component: ISceneComponent, action: T): void;
  69896. /**
  69897. * Clears all the steps from the stage.
  69898. */
  69899. clear(): void;
  69900. }
  69901. }
  69902. declare module BABYLON {
  69903. interface Scene {
  69904. /** @hidden */
  69905. _pointerOverSprite: Nullable<Sprite>;
  69906. /** @hidden */
  69907. _pickedDownSprite: Nullable<Sprite>;
  69908. /** @hidden */
  69909. _tempSpritePickingRay: Nullable<Ray>;
  69910. /**
  69911. * All of the sprite managers added to this scene
  69912. * @see http://doc.babylonjs.com/babylon101/sprites
  69913. */
  69914. spriteManagers: Array<ISpriteManager>;
  69915. /**
  69916. * An event triggered when sprites rendering is about to start
  69917. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  69918. */
  69919. onBeforeSpritesRenderingObservable: Observable<Scene>;
  69920. /**
  69921. * An event triggered when sprites rendering is done
  69922. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  69923. */
  69924. onAfterSpritesRenderingObservable: Observable<Scene>;
  69925. /** @hidden */
  69926. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69927. /** Launch a ray to try to pick a sprite in the scene
  69928. * @param x position on screen
  69929. * @param y position on screen
  69930. * @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
  69931. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  69932. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  69933. * @returns a PickingInfo
  69934. */
  69935. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69936. /** Use the given ray to pick a sprite in the scene
  69937. * @param ray The ray (in world space) to use to pick meshes
  69938. * @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
  69939. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  69940. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  69941. * @returns a PickingInfo
  69942. */
  69943. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  69944. /**
  69945. * Force the sprite under the pointer
  69946. * @param sprite defines the sprite to use
  69947. */
  69948. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  69949. /**
  69950. * Gets the sprite under the pointer
  69951. * @returns a Sprite or null if no sprite is under the pointer
  69952. */
  69953. getPointerOverSprite(): Nullable<Sprite>;
  69954. }
  69955. /**
  69956. * Defines the sprite scene component responsible to manage sprites
  69957. * in a given scene.
  69958. */
  69959. export class SpriteSceneComponent implements ISceneComponent {
  69960. /**
  69961. * The component name helpfull to identify the component in the list of scene components.
  69962. */
  69963. readonly name: string;
  69964. /**
  69965. * The scene the component belongs to.
  69966. */
  69967. scene: Scene;
  69968. /** @hidden */
  69969. private _spritePredicate;
  69970. /**
  69971. * Creates a new instance of the component for the given scene
  69972. * @param scene Defines the scene to register the component in
  69973. */
  69974. constructor(scene: Scene);
  69975. /**
  69976. * Registers the component in a given scene
  69977. */
  69978. register(): void;
  69979. /**
  69980. * Rebuilds the elements related to this component in case of
  69981. * context lost for instance.
  69982. */
  69983. rebuild(): void;
  69984. /**
  69985. * Disposes the component and the associated ressources.
  69986. */
  69987. dispose(): void;
  69988. private _pickSpriteButKeepRay;
  69989. private _pointerMove;
  69990. private _pointerDown;
  69991. private _pointerUp;
  69992. }
  69993. }
  69994. declare module BABYLON {
  69995. /** @hidden */
  69996. export var fogFragmentDeclaration: {
  69997. name: string;
  69998. shader: string;
  69999. };
  70000. }
  70001. declare module BABYLON {
  70002. /** @hidden */
  70003. export var fogFragment: {
  70004. name: string;
  70005. shader: string;
  70006. };
  70007. }
  70008. declare module BABYLON {
  70009. /** @hidden */
  70010. export var spritesPixelShader: {
  70011. name: string;
  70012. shader: string;
  70013. };
  70014. }
  70015. declare module BABYLON {
  70016. /** @hidden */
  70017. export var fogVertexDeclaration: {
  70018. name: string;
  70019. shader: string;
  70020. };
  70021. }
  70022. declare module BABYLON {
  70023. /** @hidden */
  70024. export var spritesVertexShader: {
  70025. name: string;
  70026. shader: string;
  70027. };
  70028. }
  70029. declare module BABYLON {
  70030. /**
  70031. * Defines the minimum interface to fullfil in order to be a sprite manager.
  70032. */
  70033. export interface ISpriteManager extends IDisposable {
  70034. /**
  70035. * Restricts the camera to viewing objects with the same layerMask.
  70036. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  70037. */
  70038. layerMask: number;
  70039. /**
  70040. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  70041. */
  70042. isPickable: boolean;
  70043. /**
  70044. * Specifies the rendering group id for this mesh (0 by default)
  70045. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  70046. */
  70047. renderingGroupId: number;
  70048. /**
  70049. * Defines the list of sprites managed by the manager.
  70050. */
  70051. sprites: Array<Sprite>;
  70052. /**
  70053. * Tests the intersection of a sprite with a specific ray.
  70054. * @param ray The ray we are sending to test the collision
  70055. * @param camera The camera space we are sending rays in
  70056. * @param predicate A predicate allowing excluding sprites from the list of object to test
  70057. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  70058. * @returns picking info or null.
  70059. */
  70060. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  70061. /**
  70062. * Renders the list of sprites on screen.
  70063. */
  70064. render(): void;
  70065. }
  70066. /**
  70067. * Class used to manage multiple sprites on the same spritesheet
  70068. * @see http://doc.babylonjs.com/babylon101/sprites
  70069. */
  70070. export class SpriteManager implements ISpriteManager {
  70071. /** defines the manager's name */
  70072. name: string;
  70073. /** Gets the list of sprites */
  70074. sprites: Sprite[];
  70075. /** Gets or sets the rendering group id (0 by default) */
  70076. renderingGroupId: number;
  70077. /** Gets or sets camera layer mask */
  70078. layerMask: number;
  70079. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  70080. fogEnabled: boolean;
  70081. /** Gets or sets a boolean indicating if the sprites are pickable */
  70082. isPickable: boolean;
  70083. /** Defines the default width of a cell in the spritesheet */
  70084. cellWidth: number;
  70085. /** Defines the default height of a cell in the spritesheet */
  70086. cellHeight: number;
  70087. /**
  70088. * An event triggered when the manager is disposed.
  70089. */
  70090. onDisposeObservable: Observable<SpriteManager>;
  70091. private _onDisposeObserver;
  70092. /**
  70093. * Callback called when the manager is disposed
  70094. */
  70095. onDispose: () => void;
  70096. private _capacity;
  70097. private _spriteTexture;
  70098. private _epsilon;
  70099. private _scene;
  70100. private _vertexData;
  70101. private _buffer;
  70102. private _vertexBuffers;
  70103. private _indexBuffer;
  70104. private _effectBase;
  70105. private _effectFog;
  70106. /**
  70107. * Gets or sets the spritesheet texture
  70108. */
  70109. texture: Texture;
  70110. /**
  70111. * Creates a new sprite manager
  70112. * @param name defines the manager's name
  70113. * @param imgUrl defines the sprite sheet url
  70114. * @param capacity defines the maximum allowed number of sprites
  70115. * @param cellSize defines the size of a sprite cell
  70116. * @param scene defines the hosting scene
  70117. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70118. * @param samplingMode defines the smapling mode to use with spritesheet
  70119. */
  70120. constructor(
  70121. /** defines the manager's name */
  70122. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  70123. private _appendSpriteVertex;
  70124. /**
  70125. * Intersects the sprites with a ray
  70126. * @param ray defines the ray to intersect with
  70127. * @param camera defines the current active camera
  70128. * @param predicate defines a predicate used to select candidate sprites
  70129. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  70130. * @returns null if no hit or a PickingInfo
  70131. */
  70132. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  70133. /**
  70134. * Render all child sprites
  70135. */
  70136. render(): void;
  70137. /**
  70138. * Release associated resources
  70139. */
  70140. dispose(): void;
  70141. }
  70142. }
  70143. declare module BABYLON {
  70144. /**
  70145. * Class used to represent a sprite
  70146. * @see http://doc.babylonjs.com/babylon101/sprites
  70147. */
  70148. export class Sprite {
  70149. /** defines the name */
  70150. name: string;
  70151. /** Gets or sets the current world position */
  70152. position: Vector3;
  70153. /** Gets or sets the main color */
  70154. color: Color4;
  70155. /** Gets or sets the width */
  70156. width: number;
  70157. /** Gets or sets the height */
  70158. height: number;
  70159. /** Gets or sets rotation angle */
  70160. angle: number;
  70161. /** Gets or sets the cell index in the sprite sheet */
  70162. cellIndex: number;
  70163. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  70164. invertU: number;
  70165. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  70166. invertV: number;
  70167. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  70168. disposeWhenFinishedAnimating: boolean;
  70169. /** Gets the list of attached animations */
  70170. animations: Animation[];
  70171. /** Gets or sets a boolean indicating if the sprite can be picked */
  70172. isPickable: boolean;
  70173. /**
  70174. * Gets or sets the associated action manager
  70175. */
  70176. actionManager: Nullable<ActionManager>;
  70177. private _animationStarted;
  70178. private _loopAnimation;
  70179. private _fromIndex;
  70180. private _toIndex;
  70181. private _delay;
  70182. private _direction;
  70183. private _manager;
  70184. private _time;
  70185. private _onAnimationEnd;
  70186. /**
  70187. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  70188. */
  70189. isVisible: boolean;
  70190. /**
  70191. * Gets or sets the sprite size
  70192. */
  70193. size: number;
  70194. /**
  70195. * Creates a new Sprite
  70196. * @param name defines the name
  70197. * @param manager defines the manager
  70198. */
  70199. constructor(
  70200. /** defines the name */
  70201. name: string, manager: ISpriteManager);
  70202. /**
  70203. * Starts an animation
  70204. * @param from defines the initial key
  70205. * @param to defines the end key
  70206. * @param loop defines if the animation must loop
  70207. * @param delay defines the start delay (in ms)
  70208. * @param onAnimationEnd defines a callback to call when animation ends
  70209. */
  70210. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  70211. /** Stops current animation (if any) */
  70212. stopAnimation(): void;
  70213. /** @hidden */
  70214. _animate(deltaTime: number): void;
  70215. /** Release associated resources */
  70216. dispose(): void;
  70217. }
  70218. }
  70219. declare module BABYLON {
  70220. /**
  70221. * Information about the result of picking within a scene
  70222. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  70223. */
  70224. export class PickingInfo {
  70225. /** @hidden */
  70226. _pickingUnavailable: boolean;
  70227. /**
  70228. * If the pick collided with an object
  70229. */
  70230. hit: boolean;
  70231. /**
  70232. * Distance away where the pick collided
  70233. */
  70234. distance: number;
  70235. /**
  70236. * The location of pick collision
  70237. */
  70238. pickedPoint: Nullable<Vector3>;
  70239. /**
  70240. * The mesh corresponding the the pick collision
  70241. */
  70242. pickedMesh: Nullable<AbstractMesh>;
  70243. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  70244. bu: number;
  70245. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  70246. bv: number;
  70247. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  70248. faceId: number;
  70249. /** Id of the the submesh that was picked */
  70250. subMeshId: number;
  70251. /** If a sprite was picked, this will be the sprite the pick collided with */
  70252. pickedSprite: Nullable<Sprite>;
  70253. /**
  70254. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  70255. */
  70256. originMesh: Nullable<AbstractMesh>;
  70257. /**
  70258. * The ray that was used to perform the picking.
  70259. */
  70260. ray: Nullable<Ray>;
  70261. /**
  70262. * Gets the normal correspodning to the face the pick collided with
  70263. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  70264. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  70265. * @returns The normal correspodning to the face the pick collided with
  70266. */
  70267. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  70268. /**
  70269. * Gets the texture coordinates of where the pick occured
  70270. * @returns the vector containing the coordnates of the texture
  70271. */
  70272. getTextureCoordinates(): Nullable<Vector2>;
  70273. }
  70274. }
  70275. declare module BABYLON {
  70276. /**
  70277. * Gather the list of pointer event types as constants.
  70278. */
  70279. export class PointerEventTypes {
  70280. /**
  70281. * 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.
  70282. */
  70283. static readonly POINTERDOWN: number;
  70284. /**
  70285. * The pointerup event is fired when a pointer is no longer active.
  70286. */
  70287. static readonly POINTERUP: number;
  70288. /**
  70289. * The pointermove event is fired when a pointer changes coordinates.
  70290. */
  70291. static readonly POINTERMOVE: number;
  70292. /**
  70293. * The pointerwheel event is fired when a mouse wheel has been rotated.
  70294. */
  70295. static readonly POINTERWHEEL: number;
  70296. /**
  70297. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  70298. */
  70299. static readonly POINTERPICK: number;
  70300. /**
  70301. * The pointertap event is fired when a the object has been touched and released without drag.
  70302. */
  70303. static readonly POINTERTAP: number;
  70304. /**
  70305. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  70306. */
  70307. static readonly POINTERDOUBLETAP: number;
  70308. }
  70309. /**
  70310. * Base class of pointer info types.
  70311. */
  70312. export class PointerInfoBase {
  70313. /**
  70314. * Defines the type of event (PointerEventTypes)
  70315. */
  70316. type: number;
  70317. /**
  70318. * Defines the related dom event
  70319. */
  70320. event: PointerEvent | MouseWheelEvent;
  70321. /**
  70322. * Instantiates the base class of pointers info.
  70323. * @param type Defines the type of event (PointerEventTypes)
  70324. * @param event Defines the related dom event
  70325. */
  70326. constructor(
  70327. /**
  70328. * Defines the type of event (PointerEventTypes)
  70329. */
  70330. type: number,
  70331. /**
  70332. * Defines the related dom event
  70333. */
  70334. event: PointerEvent | MouseWheelEvent);
  70335. }
  70336. /**
  70337. * This class is used to store pointer related info for the onPrePointerObservable event.
  70338. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  70339. */
  70340. export class PointerInfoPre extends PointerInfoBase {
  70341. /**
  70342. * Ray from a pointer if availible (eg. 6dof controller)
  70343. */
  70344. ray: Nullable<Ray>;
  70345. /**
  70346. * Defines the local position of the pointer on the canvas.
  70347. */
  70348. localPosition: Vector2;
  70349. /**
  70350. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  70351. */
  70352. skipOnPointerObservable: boolean;
  70353. /**
  70354. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  70355. * @param type Defines the type of event (PointerEventTypes)
  70356. * @param event Defines the related dom event
  70357. * @param localX Defines the local x coordinates of the pointer when the event occured
  70358. * @param localY Defines the local y coordinates of the pointer when the event occured
  70359. */
  70360. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  70361. }
  70362. /**
  70363. * This type contains all the data related to a pointer event in Babylon.js.
  70364. * 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.
  70365. */
  70366. export class PointerInfo extends PointerInfoBase {
  70367. /**
  70368. * Defines the picking info associated to the info (if any)\
  70369. */
  70370. pickInfo: Nullable<PickingInfo>;
  70371. /**
  70372. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  70373. * @param type Defines the type of event (PointerEventTypes)
  70374. * @param event Defines the related dom event
  70375. * @param pickInfo Defines the picking info associated to the info (if any)\
  70376. */
  70377. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  70378. /**
  70379. * Defines the picking info associated to the info (if any)\
  70380. */
  70381. pickInfo: Nullable<PickingInfo>);
  70382. }
  70383. /**
  70384. * Data relating to a touch event on the screen.
  70385. */
  70386. export interface PointerTouch {
  70387. /**
  70388. * X coordinate of touch.
  70389. */
  70390. x: number;
  70391. /**
  70392. * Y coordinate of touch.
  70393. */
  70394. y: number;
  70395. /**
  70396. * Id of touch. Unique for each finger.
  70397. */
  70398. pointerId: number;
  70399. /**
  70400. * Event type passed from DOM.
  70401. */
  70402. type: any;
  70403. }
  70404. }
  70405. declare module BABYLON {
  70406. /**
  70407. * Manage the mouse inputs to control the movement of a free camera.
  70408. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70409. */
  70410. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  70411. /**
  70412. * Define if touch is enabled in the mouse input
  70413. */
  70414. touchEnabled: boolean;
  70415. /**
  70416. * Defines the camera the input is attached to.
  70417. */
  70418. camera: FreeCamera;
  70419. /**
  70420. * Defines the buttons associated with the input to handle camera move.
  70421. */
  70422. buttons: number[];
  70423. /**
  70424. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  70425. */
  70426. angularSensibility: number;
  70427. private _pointerInput;
  70428. private _onMouseMove;
  70429. private _observer;
  70430. private previousPosition;
  70431. /**
  70432. * Manage the mouse inputs to control the movement of a free camera.
  70433. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70434. * @param touchEnabled Defines if touch is enabled or not
  70435. */
  70436. constructor(
  70437. /**
  70438. * Define if touch is enabled in the mouse input
  70439. */
  70440. touchEnabled?: boolean);
  70441. /**
  70442. * Attach the input controls to a specific dom element to get the input from.
  70443. * @param element Defines the element the controls should be listened from
  70444. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70445. */
  70446. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70447. /**
  70448. * Called on JS contextmenu event.
  70449. * Override this method to provide functionality.
  70450. */
  70451. protected onContextMenu(evt: PointerEvent): void;
  70452. /**
  70453. * Detach the current controls from the specified dom element.
  70454. * @param element Defines the element to stop listening the inputs from
  70455. */
  70456. detachControl(element: Nullable<HTMLElement>): void;
  70457. /**
  70458. * Gets the class name of the current intput.
  70459. * @returns the class name
  70460. */
  70461. getClassName(): string;
  70462. /**
  70463. * Get the friendly name associated with the input class.
  70464. * @returns the input friendly name
  70465. */
  70466. getSimpleName(): string;
  70467. }
  70468. }
  70469. declare module BABYLON {
  70470. /**
  70471. * Manage the touch inputs to control the movement of a free camera.
  70472. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70473. */
  70474. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  70475. /**
  70476. * Defines the camera the input is attached to.
  70477. */
  70478. camera: FreeCamera;
  70479. /**
  70480. * Defines the touch sensibility for rotation.
  70481. * The higher the faster.
  70482. */
  70483. touchAngularSensibility: number;
  70484. /**
  70485. * Defines the touch sensibility for move.
  70486. * The higher the faster.
  70487. */
  70488. touchMoveSensibility: number;
  70489. private _offsetX;
  70490. private _offsetY;
  70491. private _pointerPressed;
  70492. private _pointerInput;
  70493. private _observer;
  70494. private _onLostFocus;
  70495. /**
  70496. * Attach the input controls to a specific dom element to get the input from.
  70497. * @param element Defines the element the controls should be listened from
  70498. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70499. */
  70500. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70501. /**
  70502. * Detach the current controls from the specified dom element.
  70503. * @param element Defines the element to stop listening the inputs from
  70504. */
  70505. detachControl(element: Nullable<HTMLElement>): void;
  70506. /**
  70507. * Update the current camera state depending on the inputs that have been used this frame.
  70508. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70509. */
  70510. checkInputs(): void;
  70511. /**
  70512. * Gets the class name of the current intput.
  70513. * @returns the class name
  70514. */
  70515. getClassName(): string;
  70516. /**
  70517. * Get the friendly name associated with the input class.
  70518. * @returns the input friendly name
  70519. */
  70520. getSimpleName(): string;
  70521. }
  70522. }
  70523. declare module BABYLON {
  70524. /**
  70525. * Default Inputs manager for the FreeCamera.
  70526. * It groups all the default supported inputs for ease of use.
  70527. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70528. */
  70529. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  70530. /**
  70531. * Instantiates a new FreeCameraInputsManager.
  70532. * @param camera Defines the camera the inputs belong to
  70533. */
  70534. constructor(camera: FreeCamera);
  70535. /**
  70536. * Add keyboard input support to the input manager.
  70537. * @returns the current input manager
  70538. */
  70539. addKeyboard(): FreeCameraInputsManager;
  70540. /**
  70541. * Add mouse input support to the input manager.
  70542. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  70543. * @returns the current input manager
  70544. */
  70545. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  70546. /**
  70547. * Add touch input support to the input manager.
  70548. * @returns the current input manager
  70549. */
  70550. addTouch(): FreeCameraInputsManager;
  70551. }
  70552. }
  70553. declare module BABYLON {
  70554. /**
  70555. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  70556. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  70557. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  70558. */
  70559. export class FreeCamera extends TargetCamera {
  70560. /**
  70561. * Define the collision ellipsoid of the camera.
  70562. * This is helpful to simulate a camera body like the player body around the camera
  70563. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  70564. */
  70565. ellipsoid: Vector3;
  70566. /**
  70567. * Define an offset for the position of the ellipsoid around the camera.
  70568. * This can be helpful to determine the center of the body near the gravity center of the body
  70569. * instead of its head.
  70570. */
  70571. ellipsoidOffset: Vector3;
  70572. /**
  70573. * Enable or disable collisions of the camera with the rest of the scene objects.
  70574. */
  70575. checkCollisions: boolean;
  70576. /**
  70577. * Enable or disable gravity on the camera.
  70578. */
  70579. applyGravity: boolean;
  70580. /**
  70581. * Define the input manager associated to the camera.
  70582. */
  70583. inputs: FreeCameraInputsManager;
  70584. /**
  70585. * Gets the input sensibility for a mouse input. (default is 2000.0)
  70586. * Higher values reduce sensitivity.
  70587. */
  70588. /**
  70589. * Sets the input sensibility for a mouse input. (default is 2000.0)
  70590. * Higher values reduce sensitivity.
  70591. */
  70592. angularSensibility: number;
  70593. /**
  70594. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  70595. */
  70596. keysUp: number[];
  70597. /**
  70598. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  70599. */
  70600. keysDown: number[];
  70601. /**
  70602. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  70603. */
  70604. keysLeft: number[];
  70605. /**
  70606. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  70607. */
  70608. keysRight: number[];
  70609. /**
  70610. * Event raised when the camera collide with a mesh in the scene.
  70611. */
  70612. onCollide: (collidedMesh: AbstractMesh) => void;
  70613. private _collider;
  70614. private _needMoveForGravity;
  70615. private _oldPosition;
  70616. private _diffPosition;
  70617. private _newPosition;
  70618. /** @hidden */
  70619. _localDirection: Vector3;
  70620. /** @hidden */
  70621. _transformedDirection: Vector3;
  70622. /**
  70623. * Instantiates a Free Camera.
  70624. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  70625. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  70626. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  70627. * @param name Define the name of the camera in the scene
  70628. * @param position Define the start position of the camera in the scene
  70629. * @param scene Define the scene the camera belongs to
  70630. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  70631. */
  70632. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  70633. /**
  70634. * Attached controls to the current camera.
  70635. * @param element Defines the element the controls should be listened from
  70636. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70637. */
  70638. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70639. /**
  70640. * Detach the current controls from the camera.
  70641. * The camera will stop reacting to inputs.
  70642. * @param element Defines the element to stop listening the inputs from
  70643. */
  70644. detachControl(element: HTMLElement): void;
  70645. private _collisionMask;
  70646. /**
  70647. * Define a collision mask to limit the list of object the camera can collide with
  70648. */
  70649. collisionMask: number;
  70650. /** @hidden */
  70651. _collideWithWorld(displacement: Vector3): void;
  70652. private _onCollisionPositionChange;
  70653. /** @hidden */
  70654. _checkInputs(): void;
  70655. /** @hidden */
  70656. _decideIfNeedsToMove(): boolean;
  70657. /** @hidden */
  70658. _updatePosition(): void;
  70659. /**
  70660. * Destroy the camera and release the current resources hold by it.
  70661. */
  70662. dispose(): void;
  70663. /**
  70664. * Gets the current object class name.
  70665. * @return the class name
  70666. */
  70667. getClassName(): string;
  70668. }
  70669. }
  70670. declare module BABYLON {
  70671. /**
  70672. * Represents a gamepad control stick position
  70673. */
  70674. export class StickValues {
  70675. /**
  70676. * The x component of the control stick
  70677. */
  70678. x: number;
  70679. /**
  70680. * The y component of the control stick
  70681. */
  70682. y: number;
  70683. /**
  70684. * Initializes the gamepad x and y control stick values
  70685. * @param x The x component of the gamepad control stick value
  70686. * @param y The y component of the gamepad control stick value
  70687. */
  70688. constructor(
  70689. /**
  70690. * The x component of the control stick
  70691. */
  70692. x: number,
  70693. /**
  70694. * The y component of the control stick
  70695. */
  70696. y: number);
  70697. }
  70698. /**
  70699. * An interface which manages callbacks for gamepad button changes
  70700. */
  70701. export interface GamepadButtonChanges {
  70702. /**
  70703. * Called when a gamepad has been changed
  70704. */
  70705. changed: boolean;
  70706. /**
  70707. * Called when a gamepad press event has been triggered
  70708. */
  70709. pressChanged: boolean;
  70710. /**
  70711. * Called when a touch event has been triggered
  70712. */
  70713. touchChanged: boolean;
  70714. /**
  70715. * Called when a value has changed
  70716. */
  70717. valueChanged: boolean;
  70718. }
  70719. /**
  70720. * Represents a gamepad
  70721. */
  70722. export class Gamepad {
  70723. /**
  70724. * The id of the gamepad
  70725. */
  70726. id: string;
  70727. /**
  70728. * The index of the gamepad
  70729. */
  70730. index: number;
  70731. /**
  70732. * The browser gamepad
  70733. */
  70734. browserGamepad: any;
  70735. /**
  70736. * Specifies what type of gamepad this represents
  70737. */
  70738. type: number;
  70739. private _leftStick;
  70740. private _rightStick;
  70741. /** @hidden */
  70742. _isConnected: boolean;
  70743. private _leftStickAxisX;
  70744. private _leftStickAxisY;
  70745. private _rightStickAxisX;
  70746. private _rightStickAxisY;
  70747. /**
  70748. * Triggered when the left control stick has been changed
  70749. */
  70750. private _onleftstickchanged;
  70751. /**
  70752. * Triggered when the right control stick has been changed
  70753. */
  70754. private _onrightstickchanged;
  70755. /**
  70756. * Represents a gamepad controller
  70757. */
  70758. static GAMEPAD: number;
  70759. /**
  70760. * Represents a generic controller
  70761. */
  70762. static GENERIC: number;
  70763. /**
  70764. * Represents an XBox controller
  70765. */
  70766. static XBOX: number;
  70767. /**
  70768. * Represents a pose-enabled controller
  70769. */
  70770. static POSE_ENABLED: number;
  70771. /**
  70772. * Specifies whether the left control stick should be Y-inverted
  70773. */
  70774. protected _invertLeftStickY: boolean;
  70775. /**
  70776. * Specifies if the gamepad has been connected
  70777. */
  70778. readonly isConnected: boolean;
  70779. /**
  70780. * Initializes the gamepad
  70781. * @param id The id of the gamepad
  70782. * @param index The index of the gamepad
  70783. * @param browserGamepad The browser gamepad
  70784. * @param leftStickX The x component of the left joystick
  70785. * @param leftStickY The y component of the left joystick
  70786. * @param rightStickX The x component of the right joystick
  70787. * @param rightStickY The y component of the right joystick
  70788. */
  70789. constructor(
  70790. /**
  70791. * The id of the gamepad
  70792. */
  70793. id: string,
  70794. /**
  70795. * The index of the gamepad
  70796. */
  70797. index: number,
  70798. /**
  70799. * The browser gamepad
  70800. */
  70801. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  70802. /**
  70803. * Callback triggered when the left joystick has changed
  70804. * @param callback
  70805. */
  70806. onleftstickchanged(callback: (values: StickValues) => void): void;
  70807. /**
  70808. * Callback triggered when the right joystick has changed
  70809. * @param callback
  70810. */
  70811. onrightstickchanged(callback: (values: StickValues) => void): void;
  70812. /**
  70813. * Gets the left joystick
  70814. */
  70815. /**
  70816. * Sets the left joystick values
  70817. */
  70818. leftStick: StickValues;
  70819. /**
  70820. * Gets the right joystick
  70821. */
  70822. /**
  70823. * Sets the right joystick value
  70824. */
  70825. rightStick: StickValues;
  70826. /**
  70827. * Updates the gamepad joystick positions
  70828. */
  70829. update(): void;
  70830. /**
  70831. * Disposes the gamepad
  70832. */
  70833. dispose(): void;
  70834. }
  70835. /**
  70836. * Represents a generic gamepad
  70837. */
  70838. export class GenericPad extends Gamepad {
  70839. private _buttons;
  70840. private _onbuttondown;
  70841. private _onbuttonup;
  70842. /**
  70843. * Observable triggered when a button has been pressed
  70844. */
  70845. onButtonDownObservable: Observable<number>;
  70846. /**
  70847. * Observable triggered when a button has been released
  70848. */
  70849. onButtonUpObservable: Observable<number>;
  70850. /**
  70851. * Callback triggered when a button has been pressed
  70852. * @param callback Called when a button has been pressed
  70853. */
  70854. onbuttondown(callback: (buttonPressed: number) => void): void;
  70855. /**
  70856. * Callback triggered when a button has been released
  70857. * @param callback Called when a button has been released
  70858. */
  70859. onbuttonup(callback: (buttonReleased: number) => void): void;
  70860. /**
  70861. * Initializes the generic gamepad
  70862. * @param id The id of the generic gamepad
  70863. * @param index The index of the generic gamepad
  70864. * @param browserGamepad The browser gamepad
  70865. */
  70866. constructor(id: string, index: number, browserGamepad: any);
  70867. private _setButtonValue;
  70868. /**
  70869. * Updates the generic gamepad
  70870. */
  70871. update(): void;
  70872. /**
  70873. * Disposes the generic gamepad
  70874. */
  70875. dispose(): void;
  70876. }
  70877. }
  70878. declare module BABYLON {
  70879. /**
  70880. * Defines the types of pose enabled controllers that are supported
  70881. */
  70882. export enum PoseEnabledControllerType {
  70883. /**
  70884. * HTC Vive
  70885. */
  70886. VIVE = 0,
  70887. /**
  70888. * Oculus Rift
  70889. */
  70890. OCULUS = 1,
  70891. /**
  70892. * Windows mixed reality
  70893. */
  70894. WINDOWS = 2,
  70895. /**
  70896. * Samsung gear VR
  70897. */
  70898. GEAR_VR = 3,
  70899. /**
  70900. * Google Daydream
  70901. */
  70902. DAYDREAM = 4,
  70903. /**
  70904. * Generic
  70905. */
  70906. GENERIC = 5
  70907. }
  70908. /**
  70909. * Defines the MutableGamepadButton interface for the state of a gamepad button
  70910. */
  70911. export interface MutableGamepadButton {
  70912. /**
  70913. * Value of the button/trigger
  70914. */
  70915. value: number;
  70916. /**
  70917. * If the button/trigger is currently touched
  70918. */
  70919. touched: boolean;
  70920. /**
  70921. * If the button/trigger is currently pressed
  70922. */
  70923. pressed: boolean;
  70924. }
  70925. /**
  70926. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  70927. * @hidden
  70928. */
  70929. export interface ExtendedGamepadButton extends GamepadButton {
  70930. /**
  70931. * If the button/trigger is currently pressed
  70932. */
  70933. readonly pressed: boolean;
  70934. /**
  70935. * If the button/trigger is currently touched
  70936. */
  70937. readonly touched: boolean;
  70938. /**
  70939. * Value of the button/trigger
  70940. */
  70941. readonly value: number;
  70942. }
  70943. /** @hidden */
  70944. export interface _GamePadFactory {
  70945. /**
  70946. * Returns wether or not the current gamepad can be created for this type of controller.
  70947. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  70948. * @returns true if it can be created, otherwise false
  70949. */
  70950. canCreate(gamepadInfo: any): boolean;
  70951. /**
  70952. * Creates a new instance of the Gamepad.
  70953. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  70954. * @returns the new gamepad instance
  70955. */
  70956. create(gamepadInfo: any): Gamepad;
  70957. }
  70958. /**
  70959. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  70960. */
  70961. export class PoseEnabledControllerHelper {
  70962. /** @hidden */
  70963. static _ControllerFactories: _GamePadFactory[];
  70964. /** @hidden */
  70965. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  70966. /**
  70967. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  70968. * @param vrGamepad the gamepad to initialized
  70969. * @returns a vr controller of the type the gamepad identified as
  70970. */
  70971. static InitiateController(vrGamepad: any): Gamepad;
  70972. }
  70973. /**
  70974. * Defines the PoseEnabledController object that contains state of a vr capable controller
  70975. */
  70976. export class PoseEnabledController extends Gamepad implements PoseControlled {
  70977. private _deviceRoomPosition;
  70978. private _deviceRoomRotationQuaternion;
  70979. /**
  70980. * The device position in babylon space
  70981. */
  70982. devicePosition: Vector3;
  70983. /**
  70984. * The device rotation in babylon space
  70985. */
  70986. deviceRotationQuaternion: Quaternion;
  70987. /**
  70988. * The scale factor of the device in babylon space
  70989. */
  70990. deviceScaleFactor: number;
  70991. /**
  70992. * (Likely devicePosition should be used instead) The device position in its room space
  70993. */
  70994. position: Vector3;
  70995. /**
  70996. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  70997. */
  70998. rotationQuaternion: Quaternion;
  70999. /**
  71000. * The type of controller (Eg. Windows mixed reality)
  71001. */
  71002. controllerType: PoseEnabledControllerType;
  71003. protected _calculatedPosition: Vector3;
  71004. private _calculatedRotation;
  71005. /**
  71006. * The raw pose from the device
  71007. */
  71008. rawPose: DevicePose;
  71009. private _trackPosition;
  71010. private _maxRotationDistFromHeadset;
  71011. private _draggedRoomRotation;
  71012. /**
  71013. * @hidden
  71014. */
  71015. _disableTrackPosition(fixedPosition: Vector3): void;
  71016. /**
  71017. * Internal, the mesh attached to the controller
  71018. * @hidden
  71019. */
  71020. _mesh: Nullable<AbstractMesh>;
  71021. private _poseControlledCamera;
  71022. private _leftHandSystemQuaternion;
  71023. /**
  71024. * Internal, matrix used to convert room space to babylon space
  71025. * @hidden
  71026. */
  71027. _deviceToWorld: Matrix;
  71028. /**
  71029. * Node to be used when casting a ray from the controller
  71030. * @hidden
  71031. */
  71032. _pointingPoseNode: Nullable<TransformNode>;
  71033. /**
  71034. * Name of the child mesh that can be used to cast a ray from the controller
  71035. */
  71036. static readonly POINTING_POSE: string;
  71037. /**
  71038. * Creates a new PoseEnabledController from a gamepad
  71039. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  71040. */
  71041. constructor(browserGamepad: any);
  71042. private _workingMatrix;
  71043. /**
  71044. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  71045. */
  71046. update(): void;
  71047. /**
  71048. * Updates only the pose device and mesh without doing any button event checking
  71049. */
  71050. protected _updatePoseAndMesh(): void;
  71051. /**
  71052. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  71053. * @param poseData raw pose fromthe device
  71054. */
  71055. updateFromDevice(poseData: DevicePose): void;
  71056. /**
  71057. * @hidden
  71058. */
  71059. _meshAttachedObservable: Observable<AbstractMesh>;
  71060. /**
  71061. * Attaches a mesh to the controller
  71062. * @param mesh the mesh to be attached
  71063. */
  71064. attachToMesh(mesh: AbstractMesh): void;
  71065. /**
  71066. * Attaches the controllers mesh to a camera
  71067. * @param camera the camera the mesh should be attached to
  71068. */
  71069. attachToPoseControlledCamera(camera: TargetCamera): void;
  71070. /**
  71071. * Disposes of the controller
  71072. */
  71073. dispose(): void;
  71074. /**
  71075. * The mesh that is attached to the controller
  71076. */
  71077. readonly mesh: Nullable<AbstractMesh>;
  71078. /**
  71079. * Gets the ray of the controller in the direction the controller is pointing
  71080. * @param length the length the resulting ray should be
  71081. * @returns a ray in the direction the controller is pointing
  71082. */
  71083. getForwardRay(length?: number): Ray;
  71084. }
  71085. }
  71086. declare module BABYLON {
  71087. /**
  71088. * Defines the WebVRController object that represents controllers tracked in 3D space
  71089. */
  71090. export abstract class WebVRController extends PoseEnabledController {
  71091. /**
  71092. * Internal, the default controller model for the controller
  71093. */
  71094. protected _defaultModel: AbstractMesh;
  71095. /**
  71096. * Fired when the trigger state has changed
  71097. */
  71098. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  71099. /**
  71100. * Fired when the main button state has changed
  71101. */
  71102. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  71103. /**
  71104. * Fired when the secondary button state has changed
  71105. */
  71106. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  71107. /**
  71108. * Fired when the pad state has changed
  71109. */
  71110. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  71111. /**
  71112. * Fired when controllers stick values have changed
  71113. */
  71114. onPadValuesChangedObservable: Observable<StickValues>;
  71115. /**
  71116. * Array of button availible on the controller
  71117. */
  71118. protected _buttons: Array<MutableGamepadButton>;
  71119. private _onButtonStateChange;
  71120. /**
  71121. * Fired when a controller button's state has changed
  71122. * @param callback the callback containing the button that was modified
  71123. */
  71124. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  71125. /**
  71126. * X and Y axis corrisponding to the controllers joystick
  71127. */
  71128. pad: StickValues;
  71129. /**
  71130. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  71131. */
  71132. hand: string;
  71133. /**
  71134. * The default controller model for the controller
  71135. */
  71136. readonly defaultModel: AbstractMesh;
  71137. /**
  71138. * Creates a new WebVRController from a gamepad
  71139. * @param vrGamepad the gamepad that the WebVRController should be created from
  71140. */
  71141. constructor(vrGamepad: any);
  71142. /**
  71143. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  71144. */
  71145. update(): void;
  71146. /**
  71147. * Function to be called when a button is modified
  71148. */
  71149. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  71150. /**
  71151. * Loads a mesh and attaches it to the controller
  71152. * @param scene the scene the mesh should be added to
  71153. * @param meshLoaded callback for when the mesh has been loaded
  71154. */
  71155. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  71156. private _setButtonValue;
  71157. private _changes;
  71158. private _checkChanges;
  71159. /**
  71160. * Disposes of th webVRCOntroller
  71161. */
  71162. dispose(): void;
  71163. }
  71164. }
  71165. declare module BABYLON {
  71166. /**
  71167. * The HemisphericLight simulates the ambient environment light,
  71168. * so the passed direction is the light reflection direction, not the incoming direction.
  71169. */
  71170. export class HemisphericLight extends Light {
  71171. /**
  71172. * The groundColor is the light in the opposite direction to the one specified during creation.
  71173. * 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.
  71174. */
  71175. groundColor: Color3;
  71176. /**
  71177. * The light reflection direction, not the incoming direction.
  71178. */
  71179. direction: Vector3;
  71180. /**
  71181. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  71182. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  71183. * The HemisphericLight can't cast shadows.
  71184. * Documentation : https://doc.babylonjs.com/babylon101/lights
  71185. * @param name The friendly name of the light
  71186. * @param direction The direction of the light reflection
  71187. * @param scene The scene the light belongs to
  71188. */
  71189. constructor(name: string, direction: Vector3, scene: Scene);
  71190. protected _buildUniformLayout(): void;
  71191. /**
  71192. * Returns the string "HemisphericLight".
  71193. * @return The class name
  71194. */
  71195. getClassName(): string;
  71196. /**
  71197. * Sets the HemisphericLight direction towards the passed target (Vector3).
  71198. * Returns the updated direction.
  71199. * @param target The target the direction should point to
  71200. * @return The computed direction
  71201. */
  71202. setDirectionToTarget(target: Vector3): Vector3;
  71203. /**
  71204. * Returns the shadow generator associated to the light.
  71205. * @returns Always null for hemispheric lights because it does not support shadows.
  71206. */
  71207. getShadowGenerator(): Nullable<IShadowGenerator>;
  71208. /**
  71209. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  71210. * @param effect The effect to update
  71211. * @param lightIndex The index of the light in the effect to update
  71212. * @returns The hemispheric light
  71213. */
  71214. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  71215. /**
  71216. * Computes the world matrix of the node
  71217. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71218. * @param useWasUpdatedFlag defines a reserved property
  71219. * @returns the world matrix
  71220. */
  71221. computeWorldMatrix(): Matrix;
  71222. /**
  71223. * Returns the integer 3.
  71224. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  71225. */
  71226. getTypeID(): number;
  71227. /**
  71228. * Prepares the list of defines specific to the light type.
  71229. * @param defines the list of defines
  71230. * @param lightIndex defines the index of the light for the effect
  71231. */
  71232. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  71233. }
  71234. }
  71235. declare module BABYLON {
  71236. /**
  71237. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  71238. * IMPORTANT!! The data is right-hand data.
  71239. * @export
  71240. * @interface DevicePose
  71241. */
  71242. export interface DevicePose {
  71243. /**
  71244. * The position of the device, values in array are [x,y,z].
  71245. */
  71246. readonly position: Nullable<Float32Array>;
  71247. /**
  71248. * The linearVelocity of the device, values in array are [x,y,z].
  71249. */
  71250. readonly linearVelocity: Nullable<Float32Array>;
  71251. /**
  71252. * The linearAcceleration of the device, values in array are [x,y,z].
  71253. */
  71254. readonly linearAcceleration: Nullable<Float32Array>;
  71255. /**
  71256. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  71257. */
  71258. readonly orientation: Nullable<Float32Array>;
  71259. /**
  71260. * The angularVelocity of the device, values in array are [x,y,z].
  71261. */
  71262. readonly angularVelocity: Nullable<Float32Array>;
  71263. /**
  71264. * The angularAcceleration of the device, values in array are [x,y,z].
  71265. */
  71266. readonly angularAcceleration: Nullable<Float32Array>;
  71267. }
  71268. /**
  71269. * Interface representing a pose controlled object in Babylon.
  71270. * A pose controlled object has both regular pose values as well as pose values
  71271. * from an external device such as a VR head mounted display
  71272. */
  71273. export interface PoseControlled {
  71274. /**
  71275. * The position of the object in babylon space.
  71276. */
  71277. position: Vector3;
  71278. /**
  71279. * The rotation quaternion of the object in babylon space.
  71280. */
  71281. rotationQuaternion: Quaternion;
  71282. /**
  71283. * The position of the device in babylon space.
  71284. */
  71285. devicePosition?: Vector3;
  71286. /**
  71287. * The rotation quaternion of the device in babylon space.
  71288. */
  71289. deviceRotationQuaternion: Quaternion;
  71290. /**
  71291. * The raw pose coming from the device.
  71292. */
  71293. rawPose: Nullable<DevicePose>;
  71294. /**
  71295. * The scale of the device to be used when translating from device space to babylon space.
  71296. */
  71297. deviceScaleFactor: number;
  71298. /**
  71299. * Updates the poseControlled values based on the input device pose.
  71300. * @param poseData the pose data to update the object with
  71301. */
  71302. updateFromDevice(poseData: DevicePose): void;
  71303. }
  71304. /**
  71305. * Set of options to customize the webVRCamera
  71306. */
  71307. export interface WebVROptions {
  71308. /**
  71309. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  71310. */
  71311. trackPosition?: boolean;
  71312. /**
  71313. * Sets the scale of the vrDevice in babylon space. (default: 1)
  71314. */
  71315. positionScale?: number;
  71316. /**
  71317. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  71318. */
  71319. displayName?: string;
  71320. /**
  71321. * Should the native controller meshes be initialized. (default: true)
  71322. */
  71323. controllerMeshes?: boolean;
  71324. /**
  71325. * Creating a default HemiLight only on controllers. (default: true)
  71326. */
  71327. defaultLightingOnControllers?: boolean;
  71328. /**
  71329. * If you don't want to use the default VR button of the helper. (default: false)
  71330. */
  71331. useCustomVRButton?: boolean;
  71332. /**
  71333. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  71334. */
  71335. customVRButton?: HTMLButtonElement;
  71336. /**
  71337. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  71338. */
  71339. rayLength?: number;
  71340. /**
  71341. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  71342. */
  71343. defaultHeight?: number;
  71344. }
  71345. /**
  71346. * This represents a WebVR camera.
  71347. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  71348. * @example http://doc.babylonjs.com/how_to/webvr_camera
  71349. */
  71350. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  71351. private webVROptions;
  71352. /**
  71353. * @hidden
  71354. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  71355. */
  71356. _vrDevice: any;
  71357. /**
  71358. * The rawPose of the vrDevice.
  71359. */
  71360. rawPose: Nullable<DevicePose>;
  71361. private _onVREnabled;
  71362. private _specsVersion;
  71363. private _attached;
  71364. private _frameData;
  71365. protected _descendants: Array<Node>;
  71366. private _deviceRoomPosition;
  71367. /** @hidden */
  71368. _deviceRoomRotationQuaternion: Quaternion;
  71369. private _standingMatrix;
  71370. /**
  71371. * Represents device position in babylon space.
  71372. */
  71373. devicePosition: Vector3;
  71374. /**
  71375. * Represents device rotation in babylon space.
  71376. */
  71377. deviceRotationQuaternion: Quaternion;
  71378. /**
  71379. * The scale of the device to be used when translating from device space to babylon space.
  71380. */
  71381. deviceScaleFactor: number;
  71382. private _deviceToWorld;
  71383. private _worldToDevice;
  71384. /**
  71385. * References to the webVR controllers for the vrDevice.
  71386. */
  71387. controllers: Array<WebVRController>;
  71388. /**
  71389. * Emits an event when a controller is attached.
  71390. */
  71391. onControllersAttachedObservable: Observable<WebVRController[]>;
  71392. /**
  71393. * Emits an event when a controller's mesh has been loaded;
  71394. */
  71395. onControllerMeshLoadedObservable: Observable<WebVRController>;
  71396. /**
  71397. * Emits an event when the HMD's pose has been updated.
  71398. */
  71399. onPoseUpdatedFromDeviceObservable: Observable<any>;
  71400. private _poseSet;
  71401. /**
  71402. * If the rig cameras be used as parent instead of this camera.
  71403. */
  71404. rigParenting: boolean;
  71405. private _lightOnControllers;
  71406. private _defaultHeight?;
  71407. /**
  71408. * Instantiates a WebVRFreeCamera.
  71409. * @param name The name of the WebVRFreeCamera
  71410. * @param position The starting anchor position for the camera
  71411. * @param scene The scene the camera belongs to
  71412. * @param webVROptions a set of customizable options for the webVRCamera
  71413. */
  71414. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  71415. /**
  71416. * Gets the device distance from the ground in meters.
  71417. * @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.
  71418. */
  71419. deviceDistanceToRoomGround(): number;
  71420. /**
  71421. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  71422. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  71423. */
  71424. useStandingMatrix(callback?: (bool: boolean) => void): void;
  71425. /**
  71426. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  71427. * @returns A promise with a boolean set to if the standing matrix is supported.
  71428. */
  71429. useStandingMatrixAsync(): Promise<boolean>;
  71430. /**
  71431. * Disposes the camera
  71432. */
  71433. dispose(): void;
  71434. /**
  71435. * Gets a vrController by name.
  71436. * @param name The name of the controller to retreive
  71437. * @returns the controller matching the name specified or null if not found
  71438. */
  71439. getControllerByName(name: string): Nullable<WebVRController>;
  71440. private _leftController;
  71441. /**
  71442. * The controller corrisponding to the users left hand.
  71443. */
  71444. readonly leftController: Nullable<WebVRController>;
  71445. private _rightController;
  71446. /**
  71447. * The controller corrisponding to the users right hand.
  71448. */
  71449. readonly rightController: Nullable<WebVRController>;
  71450. /**
  71451. * Casts a ray forward from the vrCamera's gaze.
  71452. * @param length Length of the ray (default: 100)
  71453. * @returns the ray corrisponding to the gaze
  71454. */
  71455. getForwardRay(length?: number): Ray;
  71456. /**
  71457. * @hidden
  71458. * Updates the camera based on device's frame data
  71459. */
  71460. _checkInputs(): void;
  71461. /**
  71462. * Updates the poseControlled values based on the input device pose.
  71463. * @param poseData Pose coming from the device
  71464. */
  71465. updateFromDevice(poseData: DevicePose): void;
  71466. private _htmlElementAttached;
  71467. private _detachIfAttached;
  71468. /**
  71469. * WebVR's attach control will start broadcasting frames to the device.
  71470. * Note that in certain browsers (chrome for example) this function must be called
  71471. * within a user-interaction callback. Example:
  71472. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  71473. *
  71474. * @param element html element to attach the vrDevice to
  71475. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  71476. */
  71477. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71478. /**
  71479. * Detaches the camera from the html element and disables VR
  71480. *
  71481. * @param element html element to detach from
  71482. */
  71483. detachControl(element: HTMLElement): void;
  71484. /**
  71485. * @returns the name of this class
  71486. */
  71487. getClassName(): string;
  71488. /**
  71489. * Calls resetPose on the vrDisplay
  71490. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  71491. */
  71492. resetToCurrentRotation(): void;
  71493. /**
  71494. * @hidden
  71495. * Updates the rig cameras (left and right eye)
  71496. */
  71497. _updateRigCameras(): void;
  71498. private _workingVector;
  71499. private _oneVector;
  71500. private _workingMatrix;
  71501. private updateCacheCalled;
  71502. private _correctPositionIfNotTrackPosition;
  71503. /**
  71504. * @hidden
  71505. * Updates the cached values of the camera
  71506. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  71507. */
  71508. _updateCache(ignoreParentClass?: boolean): void;
  71509. /**
  71510. * @hidden
  71511. * Get current device position in babylon world
  71512. */
  71513. _computeDevicePosition(): void;
  71514. /**
  71515. * Updates the current device position and rotation in the babylon world
  71516. */
  71517. update(): void;
  71518. /**
  71519. * @hidden
  71520. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  71521. * @returns an identity matrix
  71522. */
  71523. _getViewMatrix(): Matrix;
  71524. private _tmpMatrix;
  71525. /**
  71526. * This function is called by the two RIG cameras.
  71527. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  71528. * @hidden
  71529. */
  71530. _getWebVRViewMatrix(): Matrix;
  71531. /** @hidden */
  71532. _getWebVRProjectionMatrix(): Matrix;
  71533. private _onGamepadConnectedObserver;
  71534. private _onGamepadDisconnectedObserver;
  71535. private _updateCacheWhenTrackingDisabledObserver;
  71536. /**
  71537. * Initializes the controllers and their meshes
  71538. */
  71539. initControllers(): void;
  71540. }
  71541. }
  71542. declare module BABYLON {
  71543. /**
  71544. * Size options for a post process
  71545. */
  71546. export type PostProcessOptions = {
  71547. width: number;
  71548. height: number;
  71549. };
  71550. /**
  71551. * PostProcess can be used to apply a shader to a texture after it has been rendered
  71552. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71553. */
  71554. export class PostProcess {
  71555. /** Name of the PostProcess. */
  71556. name: string;
  71557. /**
  71558. * Gets or sets the unique id of the post process
  71559. */
  71560. uniqueId: number;
  71561. /**
  71562. * Width of the texture to apply the post process on
  71563. */
  71564. width: number;
  71565. /**
  71566. * Height of the texture to apply the post process on
  71567. */
  71568. height: number;
  71569. /**
  71570. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  71571. * @hidden
  71572. */
  71573. _outputTexture: Nullable<InternalTexture>;
  71574. /**
  71575. * Sampling mode used by the shader
  71576. * See https://doc.babylonjs.com/classes/3.1/texture
  71577. */
  71578. renderTargetSamplingMode: number;
  71579. /**
  71580. * Clear color to use when screen clearing
  71581. */
  71582. clearColor: Color4;
  71583. /**
  71584. * If the buffer needs to be cleared before applying the post process. (default: true)
  71585. * Should be set to false if shader will overwrite all previous pixels.
  71586. */
  71587. autoClear: boolean;
  71588. /**
  71589. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  71590. */
  71591. alphaMode: number;
  71592. /**
  71593. * Sets the setAlphaBlendConstants of the babylon engine
  71594. */
  71595. alphaConstants: Color4;
  71596. /**
  71597. * Animations to be used for the post processing
  71598. */
  71599. animations: Animation[];
  71600. /**
  71601. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  71602. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  71603. */
  71604. enablePixelPerfectMode: boolean;
  71605. /**
  71606. * Force the postprocess to be applied without taking in account viewport
  71607. */
  71608. forceFullscreenViewport: boolean;
  71609. /**
  71610. * List of inspectable custom properties (used by the Inspector)
  71611. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71612. */
  71613. inspectableCustomProperties: IInspectable[];
  71614. /**
  71615. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  71616. *
  71617. * | Value | Type | Description |
  71618. * | ----- | ----------------------------------- | ----------- |
  71619. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  71620. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  71621. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  71622. *
  71623. */
  71624. scaleMode: number;
  71625. /**
  71626. * Force textures to be a power of two (default: false)
  71627. */
  71628. alwaysForcePOT: boolean;
  71629. private _samples;
  71630. /**
  71631. * Number of sample textures (default: 1)
  71632. */
  71633. samples: number;
  71634. /**
  71635. * Modify the scale of the post process to be the same as the viewport (default: false)
  71636. */
  71637. adaptScaleToCurrentViewport: boolean;
  71638. private _camera;
  71639. private _scene;
  71640. private _engine;
  71641. private _options;
  71642. private _reusable;
  71643. private _textureType;
  71644. /**
  71645. * Smart array of input and output textures for the post process.
  71646. * @hidden
  71647. */
  71648. _textures: SmartArray<InternalTexture>;
  71649. /**
  71650. * The index in _textures that corresponds to the output texture.
  71651. * @hidden
  71652. */
  71653. _currentRenderTextureInd: number;
  71654. private _effect;
  71655. private _samplers;
  71656. private _fragmentUrl;
  71657. private _vertexUrl;
  71658. private _parameters;
  71659. private _scaleRatio;
  71660. protected _indexParameters: any;
  71661. private _shareOutputWithPostProcess;
  71662. private _texelSize;
  71663. private _forcedOutputTexture;
  71664. /**
  71665. * Returns the fragment url or shader name used in the post process.
  71666. * @returns the fragment url or name in the shader store.
  71667. */
  71668. getEffectName(): string;
  71669. /**
  71670. * An event triggered when the postprocess is activated.
  71671. */
  71672. onActivateObservable: Observable<Camera>;
  71673. private _onActivateObserver;
  71674. /**
  71675. * A function that is added to the onActivateObservable
  71676. */
  71677. onActivate: Nullable<(camera: Camera) => void>;
  71678. /**
  71679. * An event triggered when the postprocess changes its size.
  71680. */
  71681. onSizeChangedObservable: Observable<PostProcess>;
  71682. private _onSizeChangedObserver;
  71683. /**
  71684. * A function that is added to the onSizeChangedObservable
  71685. */
  71686. onSizeChanged: (postProcess: PostProcess) => void;
  71687. /**
  71688. * An event triggered when the postprocess applies its effect.
  71689. */
  71690. onApplyObservable: Observable<Effect>;
  71691. private _onApplyObserver;
  71692. /**
  71693. * A function that is added to the onApplyObservable
  71694. */
  71695. onApply: (effect: Effect) => void;
  71696. /**
  71697. * An event triggered before rendering the postprocess
  71698. */
  71699. onBeforeRenderObservable: Observable<Effect>;
  71700. private _onBeforeRenderObserver;
  71701. /**
  71702. * A function that is added to the onBeforeRenderObservable
  71703. */
  71704. onBeforeRender: (effect: Effect) => void;
  71705. /**
  71706. * An event triggered after rendering the postprocess
  71707. */
  71708. onAfterRenderObservable: Observable<Effect>;
  71709. private _onAfterRenderObserver;
  71710. /**
  71711. * A function that is added to the onAfterRenderObservable
  71712. */
  71713. onAfterRender: (efect: Effect) => void;
  71714. /**
  71715. * 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
  71716. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  71717. */
  71718. inputTexture: InternalTexture;
  71719. /**
  71720. * Gets the camera which post process is applied to.
  71721. * @returns The camera the post process is applied to.
  71722. */
  71723. getCamera(): Camera;
  71724. /**
  71725. * Gets the texel size of the postprocess.
  71726. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  71727. */
  71728. readonly texelSize: Vector2;
  71729. /**
  71730. * Creates a new instance PostProcess
  71731. * @param name The name of the PostProcess.
  71732. * @param fragmentUrl The url of the fragment shader to be used.
  71733. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  71734. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  71735. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  71736. * @param camera The camera to apply the render pass to.
  71737. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71738. * @param engine The engine which the post process will be applied. (default: current engine)
  71739. * @param reusable If the post process can be reused on the same frame. (default: false)
  71740. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  71741. * @param textureType Type of textures used when performing the post process. (default: 0)
  71742. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  71743. * @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
  71744. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  71745. */
  71746. constructor(
  71747. /** Name of the PostProcess. */
  71748. 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);
  71749. /**
  71750. * Gets a string idenfifying the name of the class
  71751. * @returns "PostProcess" string
  71752. */
  71753. getClassName(): string;
  71754. /**
  71755. * Gets the engine which this post process belongs to.
  71756. * @returns The engine the post process was enabled with.
  71757. */
  71758. getEngine(): Engine;
  71759. /**
  71760. * The effect that is created when initializing the post process.
  71761. * @returns The created effect corrisponding the the postprocess.
  71762. */
  71763. getEffect(): Effect;
  71764. /**
  71765. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  71766. * @param postProcess The post process to share the output with.
  71767. * @returns This post process.
  71768. */
  71769. shareOutputWith(postProcess: PostProcess): PostProcess;
  71770. /**
  71771. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  71772. * This should be called if the post process that shares output with this post process is disabled/disposed.
  71773. */
  71774. useOwnOutput(): void;
  71775. /**
  71776. * Updates the effect with the current post process compile time values and recompiles the shader.
  71777. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  71778. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  71779. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  71780. * @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
  71781. * @param onCompiled Called when the shader has been compiled.
  71782. * @param onError Called if there is an error when compiling a shader.
  71783. */
  71784. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71785. /**
  71786. * The post process is reusable if it can be used multiple times within one frame.
  71787. * @returns If the post process is reusable
  71788. */
  71789. isReusable(): boolean;
  71790. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  71791. markTextureDirty(): void;
  71792. /**
  71793. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  71794. * 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.
  71795. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  71796. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  71797. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  71798. * @returns The target texture that was bound to be written to.
  71799. */
  71800. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  71801. /**
  71802. * If the post process is supported.
  71803. */
  71804. readonly isSupported: boolean;
  71805. /**
  71806. * The aspect ratio of the output texture.
  71807. */
  71808. readonly aspectRatio: number;
  71809. /**
  71810. * Get a value indicating if the post-process is ready to be used
  71811. * @returns true if the post-process is ready (shader is compiled)
  71812. */
  71813. isReady(): boolean;
  71814. /**
  71815. * Binds all textures and uniforms to the shader, this will be run on every pass.
  71816. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  71817. */
  71818. apply(): Nullable<Effect>;
  71819. private _disposeTextures;
  71820. /**
  71821. * Disposes the post process.
  71822. * @param camera The camera to dispose the post process on.
  71823. */
  71824. dispose(camera?: Camera): void;
  71825. }
  71826. }
  71827. declare module BABYLON {
  71828. /**
  71829. * PostProcessManager is used to manage one or more post processes or post process pipelines
  71830. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71831. */
  71832. export class PostProcessManager {
  71833. private _scene;
  71834. private _indexBuffer;
  71835. private _vertexBuffers;
  71836. /**
  71837. * Creates a new instance PostProcess
  71838. * @param scene The scene that the post process is associated with.
  71839. */
  71840. constructor(scene: Scene);
  71841. private _prepareBuffers;
  71842. private _buildIndexBuffer;
  71843. /**
  71844. * Rebuilds the vertex buffers of the manager.
  71845. * @hidden
  71846. */
  71847. _rebuild(): void;
  71848. /**
  71849. * Prepares a frame to be run through a post process.
  71850. * @param sourceTexture The input texture to the post procesess. (default: null)
  71851. * @param postProcesses An array of post processes to be run. (default: null)
  71852. * @returns True if the post processes were able to be run.
  71853. * @hidden
  71854. */
  71855. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  71856. /**
  71857. * Manually render a set of post processes to a texture.
  71858. * @param postProcesses An array of post processes to be run.
  71859. * @param targetTexture The target texture to render to.
  71860. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  71861. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  71862. * @param lodLevel defines which lod of the texture to render to
  71863. */
  71864. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  71865. /**
  71866. * Finalize the result of the output of the postprocesses.
  71867. * @param doNotPresent If true the result will not be displayed to the screen.
  71868. * @param targetTexture The target texture to render to.
  71869. * @param faceIndex The index of the face to bind the target texture to.
  71870. * @param postProcesses The array of post processes to render.
  71871. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  71872. * @hidden
  71873. */
  71874. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  71875. /**
  71876. * Disposes of the post process manager.
  71877. */
  71878. dispose(): void;
  71879. }
  71880. }
  71881. declare module BABYLON {
  71882. interface AbstractScene {
  71883. /**
  71884. * The list of layers (background and foreground) of the scene
  71885. */
  71886. layers: Array<Layer>;
  71887. }
  71888. /**
  71889. * Defines the layer scene component responsible to manage any layers
  71890. * in a given scene.
  71891. */
  71892. export class LayerSceneComponent implements ISceneComponent {
  71893. /**
  71894. * The component name helpfull to identify the component in the list of scene components.
  71895. */
  71896. readonly name: string;
  71897. /**
  71898. * The scene the component belongs to.
  71899. */
  71900. scene: Scene;
  71901. private _engine;
  71902. /**
  71903. * Creates a new instance of the component for the given scene
  71904. * @param scene Defines the scene to register the component in
  71905. */
  71906. constructor(scene: Scene);
  71907. /**
  71908. * Registers the component in a given scene
  71909. */
  71910. register(): void;
  71911. /**
  71912. * Rebuilds the elements related to this component in case of
  71913. * context lost for instance.
  71914. */
  71915. rebuild(): void;
  71916. /**
  71917. * Disposes the component and the associated ressources.
  71918. */
  71919. dispose(): void;
  71920. private _draw;
  71921. private _drawCameraPredicate;
  71922. private _drawCameraBackground;
  71923. private _drawCameraForeground;
  71924. private _drawRenderTargetPredicate;
  71925. private _drawRenderTargetBackground;
  71926. private _drawRenderTargetForeground;
  71927. }
  71928. }
  71929. declare module BABYLON {
  71930. /** @hidden */
  71931. export var layerPixelShader: {
  71932. name: string;
  71933. shader: string;
  71934. };
  71935. }
  71936. declare module BABYLON {
  71937. /** @hidden */
  71938. export var layerVertexShader: {
  71939. name: string;
  71940. shader: string;
  71941. };
  71942. }
  71943. declare module BABYLON {
  71944. /**
  71945. * This represents a full screen 2d layer.
  71946. * This can be useful to display a picture in the background of your scene for instance.
  71947. * @see https://www.babylonjs-playground.com/#08A2BS#1
  71948. */
  71949. export class Layer {
  71950. /**
  71951. * Define the name of the layer.
  71952. */
  71953. name: string;
  71954. /**
  71955. * Define the texture the layer should display.
  71956. */
  71957. texture: Nullable<Texture>;
  71958. /**
  71959. * Is the layer in background or foreground.
  71960. */
  71961. isBackground: boolean;
  71962. /**
  71963. * Define the color of the layer (instead of texture).
  71964. */
  71965. color: Color4;
  71966. /**
  71967. * Define the scale of the layer in order to zoom in out of the texture.
  71968. */
  71969. scale: Vector2;
  71970. /**
  71971. * Define an offset for the layer in order to shift the texture.
  71972. */
  71973. offset: Vector2;
  71974. /**
  71975. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  71976. */
  71977. alphaBlendingMode: number;
  71978. /**
  71979. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  71980. * Alpha test will not mix with the background color in case of transparency.
  71981. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  71982. */
  71983. alphaTest: boolean;
  71984. /**
  71985. * Define a mask to restrict the layer to only some of the scene cameras.
  71986. */
  71987. layerMask: number;
  71988. /**
  71989. * Define the list of render target the layer is visible into.
  71990. */
  71991. renderTargetTextures: RenderTargetTexture[];
  71992. /**
  71993. * Define if the layer is only used in renderTarget or if it also
  71994. * renders in the main frame buffer of the canvas.
  71995. */
  71996. renderOnlyInRenderTargetTextures: boolean;
  71997. private _scene;
  71998. private _vertexBuffers;
  71999. private _indexBuffer;
  72000. private _effect;
  72001. private _alphaTestEffect;
  72002. /**
  72003. * An event triggered when the layer is disposed.
  72004. */
  72005. onDisposeObservable: Observable<Layer>;
  72006. private _onDisposeObserver;
  72007. /**
  72008. * Back compatibility with callback before the onDisposeObservable existed.
  72009. * The set callback will be triggered when the layer has been disposed.
  72010. */
  72011. onDispose: () => void;
  72012. /**
  72013. * An event triggered before rendering the scene
  72014. */
  72015. onBeforeRenderObservable: Observable<Layer>;
  72016. private _onBeforeRenderObserver;
  72017. /**
  72018. * Back compatibility with callback before the onBeforeRenderObservable existed.
  72019. * The set callback will be triggered just before rendering the layer.
  72020. */
  72021. onBeforeRender: () => void;
  72022. /**
  72023. * An event triggered after rendering the scene
  72024. */
  72025. onAfterRenderObservable: Observable<Layer>;
  72026. private _onAfterRenderObserver;
  72027. /**
  72028. * Back compatibility with callback before the onAfterRenderObservable existed.
  72029. * The set callback will be triggered just after rendering the layer.
  72030. */
  72031. onAfterRender: () => void;
  72032. /**
  72033. * Instantiates a new layer.
  72034. * This represents a full screen 2d layer.
  72035. * This can be useful to display a picture in the background of your scene for instance.
  72036. * @see https://www.babylonjs-playground.com/#08A2BS#1
  72037. * @param name Define the name of the layer in the scene
  72038. * @param imgUrl Define the url of the texture to display in the layer
  72039. * @param scene Define the scene the layer belongs to
  72040. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  72041. * @param color Defines a color for the layer
  72042. */
  72043. constructor(
  72044. /**
  72045. * Define the name of the layer.
  72046. */
  72047. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  72048. private _createIndexBuffer;
  72049. /** @hidden */
  72050. _rebuild(): void;
  72051. /**
  72052. * Renders the layer in the scene.
  72053. */
  72054. render(): void;
  72055. /**
  72056. * Disposes and releases the associated ressources.
  72057. */
  72058. dispose(): void;
  72059. }
  72060. }
  72061. declare module BABYLON {
  72062. interface AbstractScene {
  72063. /**
  72064. * The list of procedural textures added to the scene
  72065. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  72066. */
  72067. proceduralTextures: Array<ProceduralTexture>;
  72068. }
  72069. /**
  72070. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  72071. * in a given scene.
  72072. */
  72073. export class ProceduralTextureSceneComponent implements ISceneComponent {
  72074. /**
  72075. * The component name helpfull to identify the component in the list of scene components.
  72076. */
  72077. readonly name: string;
  72078. /**
  72079. * The scene the component belongs to.
  72080. */
  72081. scene: Scene;
  72082. /**
  72083. * Creates a new instance of the component for the given scene
  72084. * @param scene Defines the scene to register the component in
  72085. */
  72086. constructor(scene: Scene);
  72087. /**
  72088. * Registers the component in a given scene
  72089. */
  72090. register(): void;
  72091. /**
  72092. * Rebuilds the elements related to this component in case of
  72093. * context lost for instance.
  72094. */
  72095. rebuild(): void;
  72096. /**
  72097. * Disposes the component and the associated ressources.
  72098. */
  72099. dispose(): void;
  72100. private _beforeClear;
  72101. }
  72102. }
  72103. declare module BABYLON {
  72104. /** @hidden */
  72105. export var proceduralVertexShader: {
  72106. name: string;
  72107. shader: string;
  72108. };
  72109. }
  72110. declare module BABYLON {
  72111. /**
  72112. * 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.
  72113. * This is the base class of any Procedural texture and contains most of the shareable code.
  72114. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  72115. */
  72116. export class ProceduralTexture extends Texture {
  72117. isCube: boolean;
  72118. /**
  72119. * Define if the texture is enabled or not (disabled texture will not render)
  72120. */
  72121. isEnabled: boolean;
  72122. /**
  72123. * Define if the texture must be cleared before rendering (default is true)
  72124. */
  72125. autoClear: boolean;
  72126. /**
  72127. * Callback called when the texture is generated
  72128. */
  72129. onGenerated: () => void;
  72130. /**
  72131. * Event raised when the texture is generated
  72132. */
  72133. onGeneratedObservable: Observable<ProceduralTexture>;
  72134. /** @hidden */
  72135. _generateMipMaps: boolean;
  72136. /** @hidden **/
  72137. _effect: Effect;
  72138. /** @hidden */
  72139. _textures: {
  72140. [key: string]: Texture;
  72141. };
  72142. private _size;
  72143. private _currentRefreshId;
  72144. private _refreshRate;
  72145. private _vertexBuffers;
  72146. private _indexBuffer;
  72147. private _uniforms;
  72148. private _samplers;
  72149. private _fragment;
  72150. private _floats;
  72151. private _ints;
  72152. private _floatsArrays;
  72153. private _colors3;
  72154. private _colors4;
  72155. private _vectors2;
  72156. private _vectors3;
  72157. private _matrices;
  72158. private _fallbackTexture;
  72159. private _fallbackTextureUsed;
  72160. private _engine;
  72161. private _cachedDefines;
  72162. private _contentUpdateId;
  72163. private _contentData;
  72164. /**
  72165. * Instantiates a new procedural texture.
  72166. * 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.
  72167. * This is the base class of any Procedural texture and contains most of the shareable code.
  72168. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  72169. * @param name Define the name of the texture
  72170. * @param size Define the size of the texture to create
  72171. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  72172. * @param scene Define the scene the texture belongs to
  72173. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  72174. * @param generateMipMaps Define if the texture should creates mip maps or not
  72175. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  72176. */
  72177. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  72178. /**
  72179. * The effect that is created when initializing the post process.
  72180. * @returns The created effect corrisponding the the postprocess.
  72181. */
  72182. getEffect(): Effect;
  72183. /**
  72184. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  72185. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  72186. */
  72187. getContent(): Nullable<ArrayBufferView>;
  72188. private _createIndexBuffer;
  72189. /** @hidden */
  72190. _rebuild(): void;
  72191. /**
  72192. * Resets the texture in order to recreate its associated resources.
  72193. * This can be called in case of context loss
  72194. */
  72195. reset(): void;
  72196. protected _getDefines(): string;
  72197. /**
  72198. * Is the texture ready to be used ? (rendered at least once)
  72199. * @returns true if ready, otherwise, false.
  72200. */
  72201. isReady(): boolean;
  72202. /**
  72203. * Resets the refresh counter of the texture and start bak from scratch.
  72204. * Could be useful to regenerate the texture if it is setup to render only once.
  72205. */
  72206. resetRefreshCounter(): void;
  72207. /**
  72208. * Set the fragment shader to use in order to render the texture.
  72209. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  72210. */
  72211. setFragment(fragment: any): void;
  72212. /**
  72213. * Define the refresh rate of the texture or the rendering frequency.
  72214. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  72215. */
  72216. refreshRate: number;
  72217. /** @hidden */
  72218. _shouldRender(): boolean;
  72219. /**
  72220. * Get the size the texture is rendering at.
  72221. * @returns the size (texture is always squared)
  72222. */
  72223. getRenderSize(): number;
  72224. /**
  72225. * Resize the texture to new value.
  72226. * @param size Define the new size the texture should have
  72227. * @param generateMipMaps Define whether the new texture should create mip maps
  72228. */
  72229. resize(size: number, generateMipMaps: boolean): void;
  72230. private _checkUniform;
  72231. /**
  72232. * Set a texture in the shader program used to render.
  72233. * @param name Define the name of the uniform samplers as defined in the shader
  72234. * @param texture Define the texture to bind to this sampler
  72235. * @return the texture itself allowing "fluent" like uniform updates
  72236. */
  72237. setTexture(name: string, texture: Texture): ProceduralTexture;
  72238. /**
  72239. * Set a float in the shader.
  72240. * @param name Define the name of the uniform as defined in the shader
  72241. * @param value Define the value to give to the uniform
  72242. * @return the texture itself allowing "fluent" like uniform updates
  72243. */
  72244. setFloat(name: string, value: number): ProceduralTexture;
  72245. /**
  72246. * Set a int in the shader.
  72247. * @param name Define the name of the uniform as defined in the shader
  72248. * @param value Define the value to give to the uniform
  72249. * @return the texture itself allowing "fluent" like uniform updates
  72250. */
  72251. setInt(name: string, value: number): ProceduralTexture;
  72252. /**
  72253. * Set an array of floats in the shader.
  72254. * @param name Define the name of the uniform as defined in the shader
  72255. * @param value Define the value to give to the uniform
  72256. * @return the texture itself allowing "fluent" like uniform updates
  72257. */
  72258. setFloats(name: string, value: number[]): ProceduralTexture;
  72259. /**
  72260. * Set a vec3 in the shader from a Color3.
  72261. * @param name Define the name of the uniform as defined in the shader
  72262. * @param value Define the value to give to the uniform
  72263. * @return the texture itself allowing "fluent" like uniform updates
  72264. */
  72265. setColor3(name: string, value: Color3): ProceduralTexture;
  72266. /**
  72267. * Set a vec4 in the shader from a Color4.
  72268. * @param name Define the name of the uniform as defined in the shader
  72269. * @param value Define the value to give to the uniform
  72270. * @return the texture itself allowing "fluent" like uniform updates
  72271. */
  72272. setColor4(name: string, value: Color4): ProceduralTexture;
  72273. /**
  72274. * Set a vec2 in the shader from a Vector2.
  72275. * @param name Define the name of the uniform as defined in the shader
  72276. * @param value Define the value to give to the uniform
  72277. * @return the texture itself allowing "fluent" like uniform updates
  72278. */
  72279. setVector2(name: string, value: Vector2): ProceduralTexture;
  72280. /**
  72281. * Set a vec3 in the shader from a Vector3.
  72282. * @param name Define the name of the uniform as defined in the shader
  72283. * @param value Define the value to give to the uniform
  72284. * @return the texture itself allowing "fluent" like uniform updates
  72285. */
  72286. setVector3(name: string, value: Vector3): ProceduralTexture;
  72287. /**
  72288. * Set a mat4 in the shader from a MAtrix.
  72289. * @param name Define the name of the uniform as defined in the shader
  72290. * @param value Define the value to give to the uniform
  72291. * @return the texture itself allowing "fluent" like uniform updates
  72292. */
  72293. setMatrix(name: string, value: Matrix): ProceduralTexture;
  72294. /**
  72295. * Render the texture to its associated render target.
  72296. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  72297. */
  72298. render(useCameraPostProcess?: boolean): void;
  72299. /**
  72300. * Clone the texture.
  72301. * @returns the cloned texture
  72302. */
  72303. clone(): ProceduralTexture;
  72304. /**
  72305. * Dispose the texture and release its asoociated resources.
  72306. */
  72307. dispose(): void;
  72308. }
  72309. }
  72310. declare module BABYLON {
  72311. /**
  72312. * This represents the base class for particle system in Babylon.
  72313. * 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.
  72314. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  72315. * @example https://doc.babylonjs.com/babylon101/particles
  72316. */
  72317. export class BaseParticleSystem {
  72318. /**
  72319. * Source color is added to the destination color without alpha affecting the result
  72320. */
  72321. static BLENDMODE_ONEONE: number;
  72322. /**
  72323. * Blend current color and particle color using particle’s alpha
  72324. */
  72325. static BLENDMODE_STANDARD: number;
  72326. /**
  72327. * Add current color and particle color multiplied by particle’s alpha
  72328. */
  72329. static BLENDMODE_ADD: number;
  72330. /**
  72331. * Multiply current color with particle color
  72332. */
  72333. static BLENDMODE_MULTIPLY: number;
  72334. /**
  72335. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  72336. */
  72337. static BLENDMODE_MULTIPLYADD: number;
  72338. /**
  72339. * List of animations used by the particle system.
  72340. */
  72341. animations: Animation[];
  72342. /**
  72343. * The id of the Particle system.
  72344. */
  72345. id: string;
  72346. /**
  72347. * The friendly name of the Particle system.
  72348. */
  72349. name: string;
  72350. /**
  72351. * The rendering group used by the Particle system to chose when to render.
  72352. */
  72353. renderingGroupId: number;
  72354. /**
  72355. * The emitter represents the Mesh or position we are attaching the particle system to.
  72356. */
  72357. emitter: Nullable<AbstractMesh | Vector3>;
  72358. /**
  72359. * The maximum number of particles to emit per frame
  72360. */
  72361. emitRate: number;
  72362. /**
  72363. * If you want to launch only a few particles at once, that can be done, as well.
  72364. */
  72365. manualEmitCount: number;
  72366. /**
  72367. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  72368. */
  72369. updateSpeed: number;
  72370. /**
  72371. * The amount of time the particle system is running (depends of the overall update speed).
  72372. */
  72373. targetStopDuration: number;
  72374. /**
  72375. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  72376. */
  72377. disposeOnStop: boolean;
  72378. /**
  72379. * Minimum power of emitting particles.
  72380. */
  72381. minEmitPower: number;
  72382. /**
  72383. * Maximum power of emitting particles.
  72384. */
  72385. maxEmitPower: number;
  72386. /**
  72387. * Minimum life time of emitting particles.
  72388. */
  72389. minLifeTime: number;
  72390. /**
  72391. * Maximum life time of emitting particles.
  72392. */
  72393. maxLifeTime: number;
  72394. /**
  72395. * Minimum Size of emitting particles.
  72396. */
  72397. minSize: number;
  72398. /**
  72399. * Maximum Size of emitting particles.
  72400. */
  72401. maxSize: number;
  72402. /**
  72403. * Minimum scale of emitting particles on X axis.
  72404. */
  72405. minScaleX: number;
  72406. /**
  72407. * Maximum scale of emitting particles on X axis.
  72408. */
  72409. maxScaleX: number;
  72410. /**
  72411. * Minimum scale of emitting particles on Y axis.
  72412. */
  72413. minScaleY: number;
  72414. /**
  72415. * Maximum scale of emitting particles on Y axis.
  72416. */
  72417. maxScaleY: number;
  72418. /**
  72419. * Gets or sets the minimal initial rotation in radians.
  72420. */
  72421. minInitialRotation: number;
  72422. /**
  72423. * Gets or sets the maximal initial rotation in radians.
  72424. */
  72425. maxInitialRotation: number;
  72426. /**
  72427. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  72428. */
  72429. minAngularSpeed: number;
  72430. /**
  72431. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  72432. */
  72433. maxAngularSpeed: number;
  72434. /**
  72435. * The texture used to render each particle. (this can be a spritesheet)
  72436. */
  72437. particleTexture: Nullable<Texture>;
  72438. /**
  72439. * The layer mask we are rendering the particles through.
  72440. */
  72441. layerMask: number;
  72442. /**
  72443. * This can help using your own shader to render the particle system.
  72444. * The according effect will be created
  72445. */
  72446. customShader: any;
  72447. /**
  72448. * By default particle system starts as soon as they are created. This prevents the
  72449. * automatic start to happen and let you decide when to start emitting particles.
  72450. */
  72451. preventAutoStart: boolean;
  72452. private _noiseTexture;
  72453. /**
  72454. * Gets or sets a texture used to add random noise to particle positions
  72455. */
  72456. noiseTexture: Nullable<ProceduralTexture>;
  72457. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  72458. noiseStrength: Vector3;
  72459. /**
  72460. * Callback triggered when the particle animation is ending.
  72461. */
  72462. onAnimationEnd: Nullable<() => void>;
  72463. /**
  72464. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  72465. */
  72466. blendMode: number;
  72467. /**
  72468. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  72469. * to override the particles.
  72470. */
  72471. forceDepthWrite: boolean;
  72472. /** 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 */
  72473. preWarmCycles: number;
  72474. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  72475. preWarmStepOffset: number;
  72476. /**
  72477. * 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)
  72478. */
  72479. spriteCellChangeSpeed: number;
  72480. /**
  72481. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  72482. */
  72483. startSpriteCellID: number;
  72484. /**
  72485. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  72486. */
  72487. endSpriteCellID: number;
  72488. /**
  72489. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  72490. */
  72491. spriteCellWidth: number;
  72492. /**
  72493. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  72494. */
  72495. spriteCellHeight: number;
  72496. /**
  72497. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  72498. */
  72499. spriteRandomStartCell: boolean;
  72500. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  72501. translationPivot: Vector2;
  72502. /** @hidden */
  72503. protected _isAnimationSheetEnabled: boolean;
  72504. /**
  72505. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  72506. */
  72507. beginAnimationOnStart: boolean;
  72508. /**
  72509. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  72510. */
  72511. beginAnimationFrom: number;
  72512. /**
  72513. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  72514. */
  72515. beginAnimationTo: number;
  72516. /**
  72517. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  72518. */
  72519. beginAnimationLoop: boolean;
  72520. /**
  72521. * Gets or sets a world offset applied to all particles
  72522. */
  72523. worldOffset: Vector3;
  72524. /**
  72525. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  72526. */
  72527. isAnimationSheetEnabled: boolean;
  72528. /**
  72529. * Get hosting scene
  72530. * @returns the scene
  72531. */
  72532. getScene(): Scene;
  72533. /**
  72534. * You can use gravity if you want to give an orientation to your particles.
  72535. */
  72536. gravity: Vector3;
  72537. protected _colorGradients: Nullable<Array<ColorGradient>>;
  72538. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  72539. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  72540. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  72541. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  72542. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  72543. protected _dragGradients: Nullable<Array<FactorGradient>>;
  72544. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  72545. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  72546. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  72547. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  72548. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  72549. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  72550. /**
  72551. * Defines the delay in milliseconds before starting the system (0 by default)
  72552. */
  72553. startDelay: number;
  72554. /**
  72555. * Gets the current list of drag gradients.
  72556. * You must use addDragGradient and removeDragGradient to udpate this list
  72557. * @returns the list of drag gradients
  72558. */
  72559. getDragGradients(): Nullable<Array<FactorGradient>>;
  72560. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  72561. limitVelocityDamping: number;
  72562. /**
  72563. * Gets the current list of limit velocity gradients.
  72564. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  72565. * @returns the list of limit velocity gradients
  72566. */
  72567. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  72568. /**
  72569. * Gets the current list of color gradients.
  72570. * You must use addColorGradient and removeColorGradient to udpate this list
  72571. * @returns the list of color gradients
  72572. */
  72573. getColorGradients(): Nullable<Array<ColorGradient>>;
  72574. /**
  72575. * Gets the current list of size gradients.
  72576. * You must use addSizeGradient and removeSizeGradient to udpate this list
  72577. * @returns the list of size gradients
  72578. */
  72579. getSizeGradients(): Nullable<Array<FactorGradient>>;
  72580. /**
  72581. * Gets the current list of color remap gradients.
  72582. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  72583. * @returns the list of color remap gradients
  72584. */
  72585. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  72586. /**
  72587. * Gets the current list of alpha remap gradients.
  72588. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  72589. * @returns the list of alpha remap gradients
  72590. */
  72591. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  72592. /**
  72593. * Gets the current list of life time gradients.
  72594. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  72595. * @returns the list of life time gradients
  72596. */
  72597. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  72598. /**
  72599. * Gets the current list of angular speed gradients.
  72600. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  72601. * @returns the list of angular speed gradients
  72602. */
  72603. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  72604. /**
  72605. * Gets the current list of velocity gradients.
  72606. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  72607. * @returns the list of velocity gradients
  72608. */
  72609. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  72610. /**
  72611. * Gets the current list of start size gradients.
  72612. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  72613. * @returns the list of start size gradients
  72614. */
  72615. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  72616. /**
  72617. * Gets the current list of emit rate gradients.
  72618. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  72619. * @returns the list of emit rate gradients
  72620. */
  72621. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  72622. /**
  72623. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72624. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72625. */
  72626. direction1: Vector3;
  72627. /**
  72628. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  72629. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72630. */
  72631. direction2: Vector3;
  72632. /**
  72633. * 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.
  72634. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72635. */
  72636. minEmitBox: Vector3;
  72637. /**
  72638. * 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.
  72639. * This only works when particleEmitterTyps is a BoxParticleEmitter
  72640. */
  72641. maxEmitBox: Vector3;
  72642. /**
  72643. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  72644. */
  72645. color1: Color4;
  72646. /**
  72647. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  72648. */
  72649. color2: Color4;
  72650. /**
  72651. * Color the particle will have at the end of its lifetime
  72652. */
  72653. colorDead: Color4;
  72654. /**
  72655. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  72656. */
  72657. textureMask: Color4;
  72658. /**
  72659. * The particle emitter type defines the emitter used by the particle system.
  72660. * It can be for example box, sphere, or cone...
  72661. */
  72662. particleEmitterType: IParticleEmitterType;
  72663. /** @hidden */
  72664. _isSubEmitter: boolean;
  72665. /**
  72666. * Gets or sets the billboard mode to use when isBillboardBased = true.
  72667. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  72668. */
  72669. billboardMode: number;
  72670. protected _isBillboardBased: boolean;
  72671. /**
  72672. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  72673. */
  72674. isBillboardBased: boolean;
  72675. /**
  72676. * The scene the particle system belongs to.
  72677. */
  72678. protected _scene: Scene;
  72679. /**
  72680. * Local cache of defines for image processing.
  72681. */
  72682. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  72683. /**
  72684. * Default configuration related to image processing available in the standard Material.
  72685. */
  72686. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  72687. /**
  72688. * Gets the image processing configuration used either in this material.
  72689. */
  72690. /**
  72691. * Sets the Default image processing configuration used either in the this material.
  72692. *
  72693. * If sets to null, the scene one is in use.
  72694. */
  72695. imageProcessingConfiguration: ImageProcessingConfiguration;
  72696. /**
  72697. * Attaches a new image processing configuration to the Standard Material.
  72698. * @param configuration
  72699. */
  72700. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  72701. /** @hidden */
  72702. protected _reset(): void;
  72703. /** @hidden */
  72704. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  72705. /**
  72706. * Instantiates a particle system.
  72707. * 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.
  72708. * @param name The name of the particle system
  72709. */
  72710. constructor(name: string);
  72711. /**
  72712. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  72713. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72714. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72715. * @returns the emitter
  72716. */
  72717. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  72718. /**
  72719. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  72720. * @param radius The radius of the hemisphere to emit from
  72721. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72722. * @returns the emitter
  72723. */
  72724. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  72725. /**
  72726. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  72727. * @param radius The radius of the sphere to emit from
  72728. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  72729. * @returns the emitter
  72730. */
  72731. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  72732. /**
  72733. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  72734. * @param radius The radius of the sphere to emit from
  72735. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  72736. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  72737. * @returns the emitter
  72738. */
  72739. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  72740. /**
  72741. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  72742. * @param radius The radius of the emission cylinder
  72743. * @param height The height of the emission cylinder
  72744. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  72745. * @param directionRandomizer How much to randomize the particle direction [0-1]
  72746. * @returns the emitter
  72747. */
  72748. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  72749. /**
  72750. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  72751. * @param radius The radius of the cylinder to emit from
  72752. * @param height The height of the emission cylinder
  72753. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  72754. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  72755. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  72756. * @returns the emitter
  72757. */
  72758. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  72759. /**
  72760. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  72761. * @param radius The radius of the cone to emit from
  72762. * @param angle The base angle of the cone
  72763. * @returns the emitter
  72764. */
  72765. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  72766. /**
  72767. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  72768. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  72769. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  72770. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  72771. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  72772. * @returns the emitter
  72773. */
  72774. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  72775. }
  72776. }
  72777. declare module BABYLON {
  72778. /**
  72779. * Type of sub emitter
  72780. */
  72781. export enum SubEmitterType {
  72782. /**
  72783. * Attached to the particle over it's lifetime
  72784. */
  72785. ATTACHED = 0,
  72786. /**
  72787. * Created when the particle dies
  72788. */
  72789. END = 1
  72790. }
  72791. /**
  72792. * Sub emitter class used to emit particles from an existing particle
  72793. */
  72794. export class SubEmitter {
  72795. /**
  72796. * the particle system to be used by the sub emitter
  72797. */
  72798. particleSystem: ParticleSystem;
  72799. /**
  72800. * Type of the submitter (Default: END)
  72801. */
  72802. type: SubEmitterType;
  72803. /**
  72804. * 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)
  72805. * Note: This only is supported when using an emitter of type Mesh
  72806. */
  72807. inheritDirection: boolean;
  72808. /**
  72809. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  72810. */
  72811. inheritedVelocityAmount: number;
  72812. /**
  72813. * Creates a sub emitter
  72814. * @param particleSystem the particle system to be used by the sub emitter
  72815. */
  72816. constructor(
  72817. /**
  72818. * the particle system to be used by the sub emitter
  72819. */
  72820. particleSystem: ParticleSystem);
  72821. /**
  72822. * Clones the sub emitter
  72823. * @returns the cloned sub emitter
  72824. */
  72825. clone(): SubEmitter;
  72826. /**
  72827. * Serialize current object to a JSON object
  72828. * @returns the serialized object
  72829. */
  72830. serialize(): any;
  72831. /** @hidden */
  72832. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  72833. /**
  72834. * Creates a new SubEmitter from a serialized JSON version
  72835. * @param serializationObject defines the JSON object to read from
  72836. * @param scene defines the hosting scene
  72837. * @param rootUrl defines the rootUrl for data loading
  72838. * @returns a new SubEmitter
  72839. */
  72840. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  72841. /** Release associated resources */
  72842. dispose(): void;
  72843. }
  72844. }
  72845. declare module BABYLON {
  72846. /** @hidden */
  72847. export var clipPlaneFragmentDeclaration: {
  72848. name: string;
  72849. shader: string;
  72850. };
  72851. }
  72852. declare module BABYLON {
  72853. /** @hidden */
  72854. export var imageProcessingDeclaration: {
  72855. name: string;
  72856. shader: string;
  72857. };
  72858. }
  72859. declare module BABYLON {
  72860. /** @hidden */
  72861. export var imageProcessingFunctions: {
  72862. name: string;
  72863. shader: string;
  72864. };
  72865. }
  72866. declare module BABYLON {
  72867. /** @hidden */
  72868. export var clipPlaneFragment: {
  72869. name: string;
  72870. shader: string;
  72871. };
  72872. }
  72873. declare module BABYLON {
  72874. /** @hidden */
  72875. export var particlesPixelShader: {
  72876. name: string;
  72877. shader: string;
  72878. };
  72879. }
  72880. declare module BABYLON {
  72881. /** @hidden */
  72882. export var clipPlaneVertexDeclaration: {
  72883. name: string;
  72884. shader: string;
  72885. };
  72886. }
  72887. declare module BABYLON {
  72888. /** @hidden */
  72889. export var clipPlaneVertex: {
  72890. name: string;
  72891. shader: string;
  72892. };
  72893. }
  72894. declare module BABYLON {
  72895. /** @hidden */
  72896. export var particlesVertexShader: {
  72897. name: string;
  72898. shader: string;
  72899. };
  72900. }
  72901. declare module BABYLON {
  72902. /**
  72903. * This represents a particle system in Babylon.
  72904. * 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.
  72905. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  72906. * @example https://doc.babylonjs.com/babylon101/particles
  72907. */
  72908. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  72909. /**
  72910. * Billboard mode will only apply to Y axis
  72911. */
  72912. static readonly BILLBOARDMODE_Y: number;
  72913. /**
  72914. * Billboard mode will apply to all axes
  72915. */
  72916. static readonly BILLBOARDMODE_ALL: number;
  72917. /**
  72918. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  72919. */
  72920. static readonly BILLBOARDMODE_STRETCHED: number;
  72921. /**
  72922. * This function can be defined to provide custom update for active particles.
  72923. * This function will be called instead of regular update (age, position, color, etc.).
  72924. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  72925. */
  72926. updateFunction: (particles: Particle[]) => void;
  72927. private _emitterWorldMatrix;
  72928. /**
  72929. * This function can be defined to specify initial direction for every new particle.
  72930. * It by default use the emitterType defined function
  72931. */
  72932. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  72933. /**
  72934. * This function can be defined to specify initial position for every new particle.
  72935. * It by default use the emitterType defined function
  72936. */
  72937. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  72938. /**
  72939. * @hidden
  72940. */
  72941. _inheritedVelocityOffset: Vector3;
  72942. /**
  72943. * An event triggered when the system is disposed
  72944. */
  72945. onDisposeObservable: Observable<ParticleSystem>;
  72946. private _onDisposeObserver;
  72947. /**
  72948. * Sets a callback that will be triggered when the system is disposed
  72949. */
  72950. onDispose: () => void;
  72951. private _particles;
  72952. private _epsilon;
  72953. private _capacity;
  72954. private _stockParticles;
  72955. private _newPartsExcess;
  72956. private _vertexData;
  72957. private _vertexBuffer;
  72958. private _vertexBuffers;
  72959. private _spriteBuffer;
  72960. private _indexBuffer;
  72961. private _effect;
  72962. private _customEffect;
  72963. private _cachedDefines;
  72964. private _scaledColorStep;
  72965. private _colorDiff;
  72966. private _scaledDirection;
  72967. private _scaledGravity;
  72968. private _currentRenderId;
  72969. private _alive;
  72970. private _useInstancing;
  72971. private _started;
  72972. private _stopped;
  72973. private _actualFrame;
  72974. private _scaledUpdateSpeed;
  72975. private _vertexBufferSize;
  72976. /** @hidden */
  72977. _currentEmitRateGradient: Nullable<FactorGradient>;
  72978. /** @hidden */
  72979. _currentEmitRate1: number;
  72980. /** @hidden */
  72981. _currentEmitRate2: number;
  72982. /** @hidden */
  72983. _currentStartSizeGradient: Nullable<FactorGradient>;
  72984. /** @hidden */
  72985. _currentStartSize1: number;
  72986. /** @hidden */
  72987. _currentStartSize2: number;
  72988. private readonly _rawTextureWidth;
  72989. private _rampGradientsTexture;
  72990. private _useRampGradients;
  72991. /** Gets or sets a boolean indicating that ramp gradients must be used
  72992. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72993. */
  72994. useRampGradients: boolean;
  72995. /**
  72996. * 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.
  72997. * 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: [])
  72998. */
  72999. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  73000. private _subEmitters;
  73001. /**
  73002. * @hidden
  73003. * If the particle systems emitter should be disposed when the particle system is disposed
  73004. */
  73005. _disposeEmitterOnDispose: boolean;
  73006. /**
  73007. * The current active Sub-systems, this property is used by the root particle system only.
  73008. */
  73009. activeSubSystems: Array<ParticleSystem>;
  73010. private _rootParticleSystem;
  73011. /**
  73012. * Gets the current list of active particles
  73013. */
  73014. readonly particles: Particle[];
  73015. /**
  73016. * Returns the string "ParticleSystem"
  73017. * @returns a string containing the class name
  73018. */
  73019. getClassName(): string;
  73020. /**
  73021. * Instantiates a particle system.
  73022. * 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.
  73023. * @param name The name of the particle system
  73024. * @param capacity The max number of particles alive at the same time
  73025. * @param scene The scene the particle system belongs to
  73026. * @param customEffect a custom effect used to change the way particles are rendered by default
  73027. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  73028. * @param epsilon Offset used to render the particles
  73029. */
  73030. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  73031. private _addFactorGradient;
  73032. private _removeFactorGradient;
  73033. /**
  73034. * Adds a new life time gradient
  73035. * @param gradient defines the gradient to use (between 0 and 1)
  73036. * @param factor defines the life time factor to affect to the specified gradient
  73037. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73038. * @returns the current particle system
  73039. */
  73040. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73041. /**
  73042. * Remove a specific life time gradient
  73043. * @param gradient defines the gradient to remove
  73044. * @returns the current particle system
  73045. */
  73046. removeLifeTimeGradient(gradient: number): IParticleSystem;
  73047. /**
  73048. * Adds a new size gradient
  73049. * @param gradient defines the gradient to use (between 0 and 1)
  73050. * @param factor defines the size factor to affect to the specified gradient
  73051. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73052. * @returns the current particle system
  73053. */
  73054. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73055. /**
  73056. * Remove a specific size gradient
  73057. * @param gradient defines the gradient to remove
  73058. * @returns the current particle system
  73059. */
  73060. removeSizeGradient(gradient: number): IParticleSystem;
  73061. /**
  73062. * Adds a new color remap gradient
  73063. * @param gradient defines the gradient to use (between 0 and 1)
  73064. * @param min defines the color remap minimal range
  73065. * @param max defines the color remap maximal range
  73066. * @returns the current particle system
  73067. */
  73068. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73069. /**
  73070. * Remove a specific color remap gradient
  73071. * @param gradient defines the gradient to remove
  73072. * @returns the current particle system
  73073. */
  73074. removeColorRemapGradient(gradient: number): IParticleSystem;
  73075. /**
  73076. * Adds a new alpha remap gradient
  73077. * @param gradient defines the gradient to use (between 0 and 1)
  73078. * @param min defines the alpha remap minimal range
  73079. * @param max defines the alpha remap maximal range
  73080. * @returns the current particle system
  73081. */
  73082. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  73083. /**
  73084. * Remove a specific alpha remap gradient
  73085. * @param gradient defines the gradient to remove
  73086. * @returns the current particle system
  73087. */
  73088. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  73089. /**
  73090. * Adds a new angular speed gradient
  73091. * @param gradient defines the gradient to use (between 0 and 1)
  73092. * @param factor defines the angular speed to affect to the specified gradient
  73093. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73094. * @returns the current particle system
  73095. */
  73096. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73097. /**
  73098. * Remove a specific angular speed gradient
  73099. * @param gradient defines the gradient to remove
  73100. * @returns the current particle system
  73101. */
  73102. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  73103. /**
  73104. * Adds a new velocity gradient
  73105. * @param gradient defines the gradient to use (between 0 and 1)
  73106. * @param factor defines the velocity to affect to the specified gradient
  73107. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73108. * @returns the current particle system
  73109. */
  73110. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73111. /**
  73112. * Remove a specific velocity gradient
  73113. * @param gradient defines the gradient to remove
  73114. * @returns the current particle system
  73115. */
  73116. removeVelocityGradient(gradient: number): IParticleSystem;
  73117. /**
  73118. * Adds a new limit velocity gradient
  73119. * @param gradient defines the gradient to use (between 0 and 1)
  73120. * @param factor defines the limit velocity value to affect to the specified gradient
  73121. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73122. * @returns the current particle system
  73123. */
  73124. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73125. /**
  73126. * Remove a specific limit velocity gradient
  73127. * @param gradient defines the gradient to remove
  73128. * @returns the current particle system
  73129. */
  73130. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  73131. /**
  73132. * Adds a new drag gradient
  73133. * @param gradient defines the gradient to use (between 0 and 1)
  73134. * @param factor defines the drag value to affect to the specified gradient
  73135. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73136. * @returns the current particle system
  73137. */
  73138. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73139. /**
  73140. * Remove a specific drag gradient
  73141. * @param gradient defines the gradient to remove
  73142. * @returns the current particle system
  73143. */
  73144. removeDragGradient(gradient: number): IParticleSystem;
  73145. /**
  73146. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  73147. * @param gradient defines the gradient to use (between 0 and 1)
  73148. * @param factor defines the emit rate value to affect to the specified gradient
  73149. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73150. * @returns the current particle system
  73151. */
  73152. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73153. /**
  73154. * Remove a specific emit rate gradient
  73155. * @param gradient defines the gradient to remove
  73156. * @returns the current particle system
  73157. */
  73158. removeEmitRateGradient(gradient: number): IParticleSystem;
  73159. /**
  73160. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  73161. * @param gradient defines the gradient to use (between 0 and 1)
  73162. * @param factor defines the start size value to affect to the specified gradient
  73163. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  73164. * @returns the current particle system
  73165. */
  73166. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  73167. /**
  73168. * Remove a specific start size gradient
  73169. * @param gradient defines the gradient to remove
  73170. * @returns the current particle system
  73171. */
  73172. removeStartSizeGradient(gradient: number): IParticleSystem;
  73173. private _createRampGradientTexture;
  73174. /**
  73175. * Gets the current list of ramp gradients.
  73176. * You must use addRampGradient and removeRampGradient to udpate this list
  73177. * @returns the list of ramp gradients
  73178. */
  73179. getRampGradients(): Nullable<Array<Color3Gradient>>;
  73180. /**
  73181. * Adds a new ramp gradient used to remap particle colors
  73182. * @param gradient defines the gradient to use (between 0 and 1)
  73183. * @param color defines the color to affect to the specified gradient
  73184. * @returns the current particle system
  73185. */
  73186. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  73187. /**
  73188. * Remove a specific ramp gradient
  73189. * @param gradient defines the gradient to remove
  73190. * @returns the current particle system
  73191. */
  73192. removeRampGradient(gradient: number): ParticleSystem;
  73193. /**
  73194. * Adds a new color gradient
  73195. * @param gradient defines the gradient to use (between 0 and 1)
  73196. * @param color1 defines the color to affect to the specified gradient
  73197. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  73198. * @returns this particle system
  73199. */
  73200. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  73201. /**
  73202. * Remove a specific color gradient
  73203. * @param gradient defines the gradient to remove
  73204. * @returns this particle system
  73205. */
  73206. removeColorGradient(gradient: number): IParticleSystem;
  73207. private _fetchR;
  73208. protected _reset(): void;
  73209. private _resetEffect;
  73210. private _createVertexBuffers;
  73211. private _createIndexBuffer;
  73212. /**
  73213. * Gets the maximum number of particles active at the same time.
  73214. * @returns The max number of active particles.
  73215. */
  73216. getCapacity(): number;
  73217. /**
  73218. * Gets whether there are still active particles in the system.
  73219. * @returns True if it is alive, otherwise false.
  73220. */
  73221. isAlive(): boolean;
  73222. /**
  73223. * Gets if the system has been started. (Note: this will still be true after stop is called)
  73224. * @returns True if it has been started, otherwise false.
  73225. */
  73226. isStarted(): boolean;
  73227. private _prepareSubEmitterInternalArray;
  73228. /**
  73229. * Starts the particle system and begins to emit
  73230. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  73231. */
  73232. start(delay?: number): void;
  73233. /**
  73234. * Stops the particle system.
  73235. * @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.
  73236. */
  73237. stop(stopSubEmitters?: boolean): void;
  73238. /**
  73239. * Remove all active particles
  73240. */
  73241. reset(): void;
  73242. /**
  73243. * @hidden (for internal use only)
  73244. */
  73245. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  73246. /**
  73247. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  73248. * Its lifetime will start back at 0.
  73249. */
  73250. recycleParticle: (particle: Particle) => void;
  73251. private _stopSubEmitters;
  73252. private _createParticle;
  73253. private _removeFromRoot;
  73254. private _emitFromParticle;
  73255. private _update;
  73256. /** @hidden */
  73257. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  73258. /** @hidden */
  73259. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  73260. /** @hidden */
  73261. private _getEffect;
  73262. /**
  73263. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  73264. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  73265. */
  73266. animate(preWarmOnly?: boolean): void;
  73267. private _appendParticleVertices;
  73268. /**
  73269. * Rebuilds the particle system.
  73270. */
  73271. rebuild(): void;
  73272. /**
  73273. * Is this system ready to be used/rendered
  73274. * @return true if the system is ready
  73275. */
  73276. isReady(): boolean;
  73277. private _render;
  73278. /**
  73279. * Renders the particle system in its current state.
  73280. * @returns the current number of particles
  73281. */
  73282. render(): number;
  73283. /**
  73284. * Disposes the particle system and free the associated resources
  73285. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  73286. */
  73287. dispose(disposeTexture?: boolean): void;
  73288. /**
  73289. * Clones the particle system.
  73290. * @param name The name of the cloned object
  73291. * @param newEmitter The new emitter to use
  73292. * @returns the cloned particle system
  73293. */
  73294. clone(name: string, newEmitter: any): ParticleSystem;
  73295. /**
  73296. * Serializes the particle system to a JSON object.
  73297. * @returns the JSON object
  73298. */
  73299. serialize(): any;
  73300. /** @hidden */
  73301. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  73302. /** @hidden */
  73303. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  73304. /**
  73305. * Parses a JSON object to create a particle system.
  73306. * @param parsedParticleSystem The JSON object to parse
  73307. * @param scene The scene to create the particle system in
  73308. * @param rootUrl The root url to use to load external dependencies like texture
  73309. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  73310. * @returns the Parsed particle system
  73311. */
  73312. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  73313. }
  73314. }
  73315. declare module BABYLON {
  73316. /**
  73317. * A particle represents one of the element emitted by a particle system.
  73318. * This is mainly define by its coordinates, direction, velocity and age.
  73319. */
  73320. export class Particle {
  73321. /**
  73322. * The particle system the particle belongs to.
  73323. */
  73324. particleSystem: ParticleSystem;
  73325. private static _Count;
  73326. /**
  73327. * Unique ID of the particle
  73328. */
  73329. id: number;
  73330. /**
  73331. * The world position of the particle in the scene.
  73332. */
  73333. position: Vector3;
  73334. /**
  73335. * The world direction of the particle in the scene.
  73336. */
  73337. direction: Vector3;
  73338. /**
  73339. * The color of the particle.
  73340. */
  73341. color: Color4;
  73342. /**
  73343. * The color change of the particle per step.
  73344. */
  73345. colorStep: Color4;
  73346. /**
  73347. * Defines how long will the life of the particle be.
  73348. */
  73349. lifeTime: number;
  73350. /**
  73351. * The current age of the particle.
  73352. */
  73353. age: number;
  73354. /**
  73355. * The current size of the particle.
  73356. */
  73357. size: number;
  73358. /**
  73359. * The current scale of the particle.
  73360. */
  73361. scale: Vector2;
  73362. /**
  73363. * The current angle of the particle.
  73364. */
  73365. angle: number;
  73366. /**
  73367. * Defines how fast is the angle changing.
  73368. */
  73369. angularSpeed: number;
  73370. /**
  73371. * Defines the cell index used by the particle to be rendered from a sprite.
  73372. */
  73373. cellIndex: number;
  73374. /**
  73375. * The information required to support color remapping
  73376. */
  73377. remapData: Vector4;
  73378. /** @hidden */
  73379. _randomCellOffset?: number;
  73380. /** @hidden */
  73381. _initialDirection: Nullable<Vector3>;
  73382. /** @hidden */
  73383. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  73384. /** @hidden */
  73385. _initialStartSpriteCellID: number;
  73386. /** @hidden */
  73387. _initialEndSpriteCellID: number;
  73388. /** @hidden */
  73389. _currentColorGradient: Nullable<ColorGradient>;
  73390. /** @hidden */
  73391. _currentColor1: Color4;
  73392. /** @hidden */
  73393. _currentColor2: Color4;
  73394. /** @hidden */
  73395. _currentSizeGradient: Nullable<FactorGradient>;
  73396. /** @hidden */
  73397. _currentSize1: number;
  73398. /** @hidden */
  73399. _currentSize2: number;
  73400. /** @hidden */
  73401. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  73402. /** @hidden */
  73403. _currentAngularSpeed1: number;
  73404. /** @hidden */
  73405. _currentAngularSpeed2: number;
  73406. /** @hidden */
  73407. _currentVelocityGradient: Nullable<FactorGradient>;
  73408. /** @hidden */
  73409. _currentVelocity1: number;
  73410. /** @hidden */
  73411. _currentVelocity2: number;
  73412. /** @hidden */
  73413. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  73414. /** @hidden */
  73415. _currentLimitVelocity1: number;
  73416. /** @hidden */
  73417. _currentLimitVelocity2: number;
  73418. /** @hidden */
  73419. _currentDragGradient: Nullable<FactorGradient>;
  73420. /** @hidden */
  73421. _currentDrag1: number;
  73422. /** @hidden */
  73423. _currentDrag2: number;
  73424. /** @hidden */
  73425. _randomNoiseCoordinates1: Vector3;
  73426. /** @hidden */
  73427. _randomNoiseCoordinates2: Vector3;
  73428. /**
  73429. * Creates a new instance Particle
  73430. * @param particleSystem the particle system the particle belongs to
  73431. */
  73432. constructor(
  73433. /**
  73434. * The particle system the particle belongs to.
  73435. */
  73436. particleSystem: ParticleSystem);
  73437. private updateCellInfoFromSystem;
  73438. /**
  73439. * Defines how the sprite cell index is updated for the particle
  73440. */
  73441. updateCellIndex(): void;
  73442. /** @hidden */
  73443. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  73444. /** @hidden */
  73445. _inheritParticleInfoToSubEmitters(): void;
  73446. /** @hidden */
  73447. _reset(): void;
  73448. /**
  73449. * Copy the properties of particle to another one.
  73450. * @param other the particle to copy the information to.
  73451. */
  73452. copyTo(other: Particle): void;
  73453. }
  73454. }
  73455. declare module BABYLON {
  73456. /**
  73457. * Particle emitter represents a volume emitting particles.
  73458. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  73459. */
  73460. export interface IParticleEmitterType {
  73461. /**
  73462. * Called by the particle System when the direction is computed for the created particle.
  73463. * @param worldMatrix is the world matrix of the particle system
  73464. * @param directionToUpdate is the direction vector to update with the result
  73465. * @param particle is the particle we are computed the direction for
  73466. */
  73467. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73468. /**
  73469. * Called by the particle System when the position is computed for the created particle.
  73470. * @param worldMatrix is the world matrix of the particle system
  73471. * @param positionToUpdate is the position vector to update with the result
  73472. * @param particle is the particle we are computed the position for
  73473. */
  73474. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73475. /**
  73476. * Clones the current emitter and returns a copy of it
  73477. * @returns the new emitter
  73478. */
  73479. clone(): IParticleEmitterType;
  73480. /**
  73481. * Called by the GPUParticleSystem to setup the update shader
  73482. * @param effect defines the update shader
  73483. */
  73484. applyToShader(effect: Effect): void;
  73485. /**
  73486. * Returns a string to use to update the GPU particles update shader
  73487. * @returns the effect defines string
  73488. */
  73489. getEffectDefines(): string;
  73490. /**
  73491. * Returns a string representing the class name
  73492. * @returns a string containing the class name
  73493. */
  73494. getClassName(): string;
  73495. /**
  73496. * Serializes the particle system to a JSON object.
  73497. * @returns the JSON object
  73498. */
  73499. serialize(): any;
  73500. /**
  73501. * Parse properties from a JSON object
  73502. * @param serializationObject defines the JSON object
  73503. */
  73504. parse(serializationObject: any): void;
  73505. }
  73506. }
  73507. declare module BABYLON {
  73508. /**
  73509. * Particle emitter emitting particles from the inside of a box.
  73510. * It emits the particles randomly between 2 given directions.
  73511. */
  73512. export class BoxParticleEmitter implements IParticleEmitterType {
  73513. /**
  73514. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73515. */
  73516. direction1: Vector3;
  73517. /**
  73518. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73519. */
  73520. direction2: Vector3;
  73521. /**
  73522. * 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.
  73523. */
  73524. minEmitBox: Vector3;
  73525. /**
  73526. * 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.
  73527. */
  73528. maxEmitBox: Vector3;
  73529. /**
  73530. * Creates a new instance BoxParticleEmitter
  73531. */
  73532. constructor();
  73533. /**
  73534. * Called by the particle System when the direction is computed for the created particle.
  73535. * @param worldMatrix is the world matrix of the particle system
  73536. * @param directionToUpdate is the direction vector to update with the result
  73537. * @param particle is the particle we are computed the direction for
  73538. */
  73539. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73540. /**
  73541. * Called by the particle System when the position is computed for the created particle.
  73542. * @param worldMatrix is the world matrix of the particle system
  73543. * @param positionToUpdate is the position vector to update with the result
  73544. * @param particle is the particle we are computed the position for
  73545. */
  73546. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73547. /**
  73548. * Clones the current emitter and returns a copy of it
  73549. * @returns the new emitter
  73550. */
  73551. clone(): BoxParticleEmitter;
  73552. /**
  73553. * Called by the GPUParticleSystem to setup the update shader
  73554. * @param effect defines the update shader
  73555. */
  73556. applyToShader(effect: Effect): void;
  73557. /**
  73558. * Returns a string to use to update the GPU particles update shader
  73559. * @returns a string containng the defines string
  73560. */
  73561. getEffectDefines(): string;
  73562. /**
  73563. * Returns the string "BoxParticleEmitter"
  73564. * @returns a string containing the class name
  73565. */
  73566. getClassName(): string;
  73567. /**
  73568. * Serializes the particle system to a JSON object.
  73569. * @returns the JSON object
  73570. */
  73571. serialize(): any;
  73572. /**
  73573. * Parse properties from a JSON object
  73574. * @param serializationObject defines the JSON object
  73575. */
  73576. parse(serializationObject: any): void;
  73577. }
  73578. }
  73579. declare module BABYLON {
  73580. /**
  73581. * Particle emitter emitting particles from the inside of a cone.
  73582. * It emits the particles alongside the cone volume from the base to the particle.
  73583. * The emission direction might be randomized.
  73584. */
  73585. export class ConeParticleEmitter implements IParticleEmitterType {
  73586. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  73587. directionRandomizer: number;
  73588. private _radius;
  73589. private _angle;
  73590. private _height;
  73591. /**
  73592. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  73593. */
  73594. radiusRange: number;
  73595. /**
  73596. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  73597. */
  73598. heightRange: number;
  73599. /**
  73600. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  73601. */
  73602. emitFromSpawnPointOnly: boolean;
  73603. /**
  73604. * Gets or sets the radius of the emission cone
  73605. */
  73606. radius: number;
  73607. /**
  73608. * Gets or sets the angle of the emission cone
  73609. */
  73610. angle: number;
  73611. private _buildHeight;
  73612. /**
  73613. * Creates a new instance ConeParticleEmitter
  73614. * @param radius the radius of the emission cone (1 by default)
  73615. * @param angle the cone base angle (PI by default)
  73616. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  73617. */
  73618. constructor(radius?: number, angle?: number,
  73619. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  73620. directionRandomizer?: number);
  73621. /**
  73622. * Called by the particle System when the direction is computed for the created particle.
  73623. * @param worldMatrix is the world matrix of the particle system
  73624. * @param directionToUpdate is the direction vector to update with the result
  73625. * @param particle is the particle we are computed the direction for
  73626. */
  73627. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73628. /**
  73629. * Called by the particle System when the position is computed for the created particle.
  73630. * @param worldMatrix is the world matrix of the particle system
  73631. * @param positionToUpdate is the position vector to update with the result
  73632. * @param particle is the particle we are computed the position for
  73633. */
  73634. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73635. /**
  73636. * Clones the current emitter and returns a copy of it
  73637. * @returns the new emitter
  73638. */
  73639. clone(): ConeParticleEmitter;
  73640. /**
  73641. * Called by the GPUParticleSystem to setup the update shader
  73642. * @param effect defines the update shader
  73643. */
  73644. applyToShader(effect: Effect): void;
  73645. /**
  73646. * Returns a string to use to update the GPU particles update shader
  73647. * @returns a string containng the defines string
  73648. */
  73649. getEffectDefines(): string;
  73650. /**
  73651. * Returns the string "ConeParticleEmitter"
  73652. * @returns a string containing the class name
  73653. */
  73654. getClassName(): string;
  73655. /**
  73656. * Serializes the particle system to a JSON object.
  73657. * @returns the JSON object
  73658. */
  73659. serialize(): any;
  73660. /**
  73661. * Parse properties from a JSON object
  73662. * @param serializationObject defines the JSON object
  73663. */
  73664. parse(serializationObject: any): void;
  73665. }
  73666. }
  73667. declare module BABYLON {
  73668. /**
  73669. * Particle emitter emitting particles from the inside of a cylinder.
  73670. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  73671. */
  73672. export class CylinderParticleEmitter implements IParticleEmitterType {
  73673. /**
  73674. * The radius of the emission cylinder.
  73675. */
  73676. radius: number;
  73677. /**
  73678. * The height of the emission cylinder.
  73679. */
  73680. height: number;
  73681. /**
  73682. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73683. */
  73684. radiusRange: number;
  73685. /**
  73686. * How much to randomize the particle direction [0-1].
  73687. */
  73688. directionRandomizer: number;
  73689. /**
  73690. * Creates a new instance CylinderParticleEmitter
  73691. * @param radius the radius of the emission cylinder (1 by default)
  73692. * @param height the height of the emission cylinder (1 by default)
  73693. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73694. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73695. */
  73696. constructor(
  73697. /**
  73698. * The radius of the emission cylinder.
  73699. */
  73700. radius?: number,
  73701. /**
  73702. * The height of the emission cylinder.
  73703. */
  73704. height?: number,
  73705. /**
  73706. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73707. */
  73708. radiusRange?: number,
  73709. /**
  73710. * How much to randomize the particle direction [0-1].
  73711. */
  73712. directionRandomizer?: number);
  73713. /**
  73714. * Called by the particle System when the direction is computed for the created particle.
  73715. * @param worldMatrix is the world matrix of the particle system
  73716. * @param directionToUpdate is the direction vector to update with the result
  73717. * @param particle is the particle we are computed the direction for
  73718. */
  73719. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73720. /**
  73721. * Called by the particle System when the position is computed for the created particle.
  73722. * @param worldMatrix is the world matrix of the particle system
  73723. * @param positionToUpdate is the position vector to update with the result
  73724. * @param particle is the particle we are computed the position for
  73725. */
  73726. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73727. /**
  73728. * Clones the current emitter and returns a copy of it
  73729. * @returns the new emitter
  73730. */
  73731. clone(): CylinderParticleEmitter;
  73732. /**
  73733. * Called by the GPUParticleSystem to setup the update shader
  73734. * @param effect defines the update shader
  73735. */
  73736. applyToShader(effect: Effect): void;
  73737. /**
  73738. * Returns a string to use to update the GPU particles update shader
  73739. * @returns a string containng the defines string
  73740. */
  73741. getEffectDefines(): string;
  73742. /**
  73743. * Returns the string "CylinderParticleEmitter"
  73744. * @returns a string containing the class name
  73745. */
  73746. getClassName(): string;
  73747. /**
  73748. * Serializes the particle system to a JSON object.
  73749. * @returns the JSON object
  73750. */
  73751. serialize(): any;
  73752. /**
  73753. * Parse properties from a JSON object
  73754. * @param serializationObject defines the JSON object
  73755. */
  73756. parse(serializationObject: any): void;
  73757. }
  73758. /**
  73759. * Particle emitter emitting particles from the inside of a cylinder.
  73760. * It emits the particles randomly between two vectors.
  73761. */
  73762. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  73763. /**
  73764. * The min limit of the emission direction.
  73765. */
  73766. direction1: Vector3;
  73767. /**
  73768. * The max limit of the emission direction.
  73769. */
  73770. direction2: Vector3;
  73771. /**
  73772. * Creates a new instance CylinderDirectedParticleEmitter
  73773. * @param radius the radius of the emission cylinder (1 by default)
  73774. * @param height the height of the emission cylinder (1 by default)
  73775. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73776. * @param direction1 the min limit of the emission direction (up vector by default)
  73777. * @param direction2 the max limit of the emission direction (up vector by default)
  73778. */
  73779. constructor(radius?: number, height?: number, radiusRange?: number,
  73780. /**
  73781. * The min limit of the emission direction.
  73782. */
  73783. direction1?: Vector3,
  73784. /**
  73785. * The max limit of the emission direction.
  73786. */
  73787. direction2?: Vector3);
  73788. /**
  73789. * Called by the particle System when the direction is computed for the created particle.
  73790. * @param worldMatrix is the world matrix of the particle system
  73791. * @param directionToUpdate is the direction vector to update with the result
  73792. * @param particle is the particle we are computed the direction for
  73793. */
  73794. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73795. /**
  73796. * Clones the current emitter and returns a copy of it
  73797. * @returns the new emitter
  73798. */
  73799. clone(): CylinderDirectedParticleEmitter;
  73800. /**
  73801. * Called by the GPUParticleSystem to setup the update shader
  73802. * @param effect defines the update shader
  73803. */
  73804. applyToShader(effect: Effect): void;
  73805. /**
  73806. * Returns a string to use to update the GPU particles update shader
  73807. * @returns a string containng the defines string
  73808. */
  73809. getEffectDefines(): string;
  73810. /**
  73811. * Returns the string "CylinderDirectedParticleEmitter"
  73812. * @returns a string containing the class name
  73813. */
  73814. getClassName(): string;
  73815. /**
  73816. * Serializes the particle system to a JSON object.
  73817. * @returns the JSON object
  73818. */
  73819. serialize(): any;
  73820. /**
  73821. * Parse properties from a JSON object
  73822. * @param serializationObject defines the JSON object
  73823. */
  73824. parse(serializationObject: any): void;
  73825. }
  73826. }
  73827. declare module BABYLON {
  73828. /**
  73829. * Particle emitter emitting particles from the inside of a hemisphere.
  73830. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  73831. */
  73832. export class HemisphericParticleEmitter implements IParticleEmitterType {
  73833. /**
  73834. * The radius of the emission hemisphere.
  73835. */
  73836. radius: number;
  73837. /**
  73838. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73839. */
  73840. radiusRange: number;
  73841. /**
  73842. * How much to randomize the particle direction [0-1].
  73843. */
  73844. directionRandomizer: number;
  73845. /**
  73846. * Creates a new instance HemisphericParticleEmitter
  73847. * @param radius the radius of the emission hemisphere (1 by default)
  73848. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73849. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73850. */
  73851. constructor(
  73852. /**
  73853. * The radius of the emission hemisphere.
  73854. */
  73855. radius?: number,
  73856. /**
  73857. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73858. */
  73859. radiusRange?: number,
  73860. /**
  73861. * How much to randomize the particle direction [0-1].
  73862. */
  73863. directionRandomizer?: number);
  73864. /**
  73865. * Called by the particle System when the direction is computed for the created particle.
  73866. * @param worldMatrix is the world matrix of the particle system
  73867. * @param directionToUpdate is the direction vector to update with the result
  73868. * @param particle is the particle we are computed the direction for
  73869. */
  73870. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73871. /**
  73872. * Called by the particle System when the position is computed for the created particle.
  73873. * @param worldMatrix is the world matrix of the particle system
  73874. * @param positionToUpdate is the position vector to update with the result
  73875. * @param particle is the particle we are computed the position for
  73876. */
  73877. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73878. /**
  73879. * Clones the current emitter and returns a copy of it
  73880. * @returns the new emitter
  73881. */
  73882. clone(): HemisphericParticleEmitter;
  73883. /**
  73884. * Called by the GPUParticleSystem to setup the update shader
  73885. * @param effect defines the update shader
  73886. */
  73887. applyToShader(effect: Effect): void;
  73888. /**
  73889. * Returns a string to use to update the GPU particles update shader
  73890. * @returns a string containng the defines string
  73891. */
  73892. getEffectDefines(): string;
  73893. /**
  73894. * Returns the string "HemisphericParticleEmitter"
  73895. * @returns a string containing the class name
  73896. */
  73897. getClassName(): string;
  73898. /**
  73899. * Serializes the particle system to a JSON object.
  73900. * @returns the JSON object
  73901. */
  73902. serialize(): any;
  73903. /**
  73904. * Parse properties from a JSON object
  73905. * @param serializationObject defines the JSON object
  73906. */
  73907. parse(serializationObject: any): void;
  73908. }
  73909. }
  73910. declare module BABYLON {
  73911. /**
  73912. * Particle emitter emitting particles from a point.
  73913. * It emits the particles randomly between 2 given directions.
  73914. */
  73915. export class PointParticleEmitter implements IParticleEmitterType {
  73916. /**
  73917. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73918. */
  73919. direction1: Vector3;
  73920. /**
  73921. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73922. */
  73923. direction2: Vector3;
  73924. /**
  73925. * Creates a new instance PointParticleEmitter
  73926. */
  73927. constructor();
  73928. /**
  73929. * Called by the particle System when the direction is computed for the created particle.
  73930. * @param worldMatrix is the world matrix of the particle system
  73931. * @param directionToUpdate is the direction vector to update with the result
  73932. * @param particle is the particle we are computed the direction for
  73933. */
  73934. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  73935. /**
  73936. * Called by the particle System when the position is computed for the created particle.
  73937. * @param worldMatrix is the world matrix of the particle system
  73938. * @param positionToUpdate is the position vector to update with the result
  73939. * @param particle is the particle we are computed the position for
  73940. */
  73941. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  73942. /**
  73943. * Clones the current emitter and returns a copy of it
  73944. * @returns the new emitter
  73945. */
  73946. clone(): PointParticleEmitter;
  73947. /**
  73948. * Called by the GPUParticleSystem to setup the update shader
  73949. * @param effect defines the update shader
  73950. */
  73951. applyToShader(effect: Effect): void;
  73952. /**
  73953. * Returns a string to use to update the GPU particles update shader
  73954. * @returns a string containng the defines string
  73955. */
  73956. getEffectDefines(): string;
  73957. /**
  73958. * Returns the string "PointParticleEmitter"
  73959. * @returns a string containing the class name
  73960. */
  73961. getClassName(): string;
  73962. /**
  73963. * Serializes the particle system to a JSON object.
  73964. * @returns the JSON object
  73965. */
  73966. serialize(): any;
  73967. /**
  73968. * Parse properties from a JSON object
  73969. * @param serializationObject defines the JSON object
  73970. */
  73971. parse(serializationObject: any): void;
  73972. }
  73973. }
  73974. declare module BABYLON {
  73975. /**
  73976. * Particle emitter emitting particles from the inside of a sphere.
  73977. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  73978. */
  73979. export class SphereParticleEmitter implements IParticleEmitterType {
  73980. /**
  73981. * The radius of the emission sphere.
  73982. */
  73983. radius: number;
  73984. /**
  73985. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  73986. */
  73987. radiusRange: number;
  73988. /**
  73989. * How much to randomize the particle direction [0-1].
  73990. */
  73991. directionRandomizer: number;
  73992. /**
  73993. * Creates a new instance SphereParticleEmitter
  73994. * @param radius the radius of the emission sphere (1 by default)
  73995. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73996. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  73997. */
  73998. constructor(
  73999. /**
  74000. * The radius of the emission sphere.
  74001. */
  74002. radius?: number,
  74003. /**
  74004. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74005. */
  74006. radiusRange?: number,
  74007. /**
  74008. * How much to randomize the particle direction [0-1].
  74009. */
  74010. directionRandomizer?: number);
  74011. /**
  74012. * Called by the particle System when the direction is computed for the created particle.
  74013. * @param worldMatrix is the world matrix of the particle system
  74014. * @param directionToUpdate is the direction vector to update with the result
  74015. * @param particle is the particle we are computed the direction for
  74016. */
  74017. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74018. /**
  74019. * Called by the particle System when the position is computed for the created particle.
  74020. * @param worldMatrix is the world matrix of the particle system
  74021. * @param positionToUpdate is the position vector to update with the result
  74022. * @param particle is the particle we are computed the position for
  74023. */
  74024. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74025. /**
  74026. * Clones the current emitter and returns a copy of it
  74027. * @returns the new emitter
  74028. */
  74029. clone(): SphereParticleEmitter;
  74030. /**
  74031. * Called by the GPUParticleSystem to setup the update shader
  74032. * @param effect defines the update shader
  74033. */
  74034. applyToShader(effect: Effect): void;
  74035. /**
  74036. * Returns a string to use to update the GPU particles update shader
  74037. * @returns a string containng the defines string
  74038. */
  74039. getEffectDefines(): string;
  74040. /**
  74041. * Returns the string "SphereParticleEmitter"
  74042. * @returns a string containing the class name
  74043. */
  74044. getClassName(): string;
  74045. /**
  74046. * Serializes the particle system to a JSON object.
  74047. * @returns the JSON object
  74048. */
  74049. serialize(): any;
  74050. /**
  74051. * Parse properties from a JSON object
  74052. * @param serializationObject defines the JSON object
  74053. */
  74054. parse(serializationObject: any): void;
  74055. }
  74056. /**
  74057. * Particle emitter emitting particles from the inside of a sphere.
  74058. * It emits the particles randomly between two vectors.
  74059. */
  74060. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  74061. /**
  74062. * The min limit of the emission direction.
  74063. */
  74064. direction1: Vector3;
  74065. /**
  74066. * The max limit of the emission direction.
  74067. */
  74068. direction2: Vector3;
  74069. /**
  74070. * Creates a new instance SphereDirectedParticleEmitter
  74071. * @param radius the radius of the emission sphere (1 by default)
  74072. * @param direction1 the min limit of the emission direction (up vector by default)
  74073. * @param direction2 the max limit of the emission direction (up vector by default)
  74074. */
  74075. constructor(radius?: number,
  74076. /**
  74077. * The min limit of the emission direction.
  74078. */
  74079. direction1?: Vector3,
  74080. /**
  74081. * The max limit of the emission direction.
  74082. */
  74083. direction2?: Vector3);
  74084. /**
  74085. * Called by the particle System when the direction is computed for the created particle.
  74086. * @param worldMatrix is the world matrix of the particle system
  74087. * @param directionToUpdate is the direction vector to update with the result
  74088. * @param particle is the particle we are computed the direction for
  74089. */
  74090. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74091. /**
  74092. * Clones the current emitter and returns a copy of it
  74093. * @returns the new emitter
  74094. */
  74095. clone(): SphereDirectedParticleEmitter;
  74096. /**
  74097. * Called by the GPUParticleSystem to setup the update shader
  74098. * @param effect defines the update shader
  74099. */
  74100. applyToShader(effect: Effect): void;
  74101. /**
  74102. * Returns a string to use to update the GPU particles update shader
  74103. * @returns a string containng the defines string
  74104. */
  74105. getEffectDefines(): string;
  74106. /**
  74107. * Returns the string "SphereDirectedParticleEmitter"
  74108. * @returns a string containing the class name
  74109. */
  74110. getClassName(): string;
  74111. /**
  74112. * Serializes the particle system to a JSON object.
  74113. * @returns the JSON object
  74114. */
  74115. serialize(): any;
  74116. /**
  74117. * Parse properties from a JSON object
  74118. * @param serializationObject defines the JSON object
  74119. */
  74120. parse(serializationObject: any): void;
  74121. }
  74122. }
  74123. declare module BABYLON {
  74124. /**
  74125. * Interface representing a particle system in Babylon.js.
  74126. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  74127. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  74128. */
  74129. export interface IParticleSystem {
  74130. /**
  74131. * List of animations used by the particle system.
  74132. */
  74133. animations: Animation[];
  74134. /**
  74135. * The id of the Particle system.
  74136. */
  74137. id: string;
  74138. /**
  74139. * The name of the Particle system.
  74140. */
  74141. name: string;
  74142. /**
  74143. * The emitter represents the Mesh or position we are attaching the particle system to.
  74144. */
  74145. emitter: Nullable<AbstractMesh | Vector3>;
  74146. /**
  74147. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  74148. */
  74149. isBillboardBased: boolean;
  74150. /**
  74151. * The rendering group used by the Particle system to chose when to render.
  74152. */
  74153. renderingGroupId: number;
  74154. /**
  74155. * The layer mask we are rendering the particles through.
  74156. */
  74157. layerMask: number;
  74158. /**
  74159. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  74160. */
  74161. updateSpeed: number;
  74162. /**
  74163. * The amount of time the particle system is running (depends of the overall update speed).
  74164. */
  74165. targetStopDuration: number;
  74166. /**
  74167. * The texture used to render each particle. (this can be a spritesheet)
  74168. */
  74169. particleTexture: Nullable<Texture>;
  74170. /**
  74171. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  74172. */
  74173. blendMode: number;
  74174. /**
  74175. * Minimum life time of emitting particles.
  74176. */
  74177. minLifeTime: number;
  74178. /**
  74179. * Maximum life time of emitting particles.
  74180. */
  74181. maxLifeTime: number;
  74182. /**
  74183. * Minimum Size of emitting particles.
  74184. */
  74185. minSize: number;
  74186. /**
  74187. * Maximum Size of emitting particles.
  74188. */
  74189. maxSize: number;
  74190. /**
  74191. * Minimum scale of emitting particles on X axis.
  74192. */
  74193. minScaleX: number;
  74194. /**
  74195. * Maximum scale of emitting particles on X axis.
  74196. */
  74197. maxScaleX: number;
  74198. /**
  74199. * Minimum scale of emitting particles on Y axis.
  74200. */
  74201. minScaleY: number;
  74202. /**
  74203. * Maximum scale of emitting particles on Y axis.
  74204. */
  74205. maxScaleY: number;
  74206. /**
  74207. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  74208. */
  74209. color1: Color4;
  74210. /**
  74211. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  74212. */
  74213. color2: Color4;
  74214. /**
  74215. * Color the particle will have at the end of its lifetime.
  74216. */
  74217. colorDead: Color4;
  74218. /**
  74219. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  74220. */
  74221. emitRate: number;
  74222. /**
  74223. * You can use gravity if you want to give an orientation to your particles.
  74224. */
  74225. gravity: Vector3;
  74226. /**
  74227. * Minimum power of emitting particles.
  74228. */
  74229. minEmitPower: number;
  74230. /**
  74231. * Maximum power of emitting particles.
  74232. */
  74233. maxEmitPower: number;
  74234. /**
  74235. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  74236. */
  74237. minAngularSpeed: number;
  74238. /**
  74239. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  74240. */
  74241. maxAngularSpeed: number;
  74242. /**
  74243. * Gets or sets the minimal initial rotation in radians.
  74244. */
  74245. minInitialRotation: number;
  74246. /**
  74247. * Gets or sets the maximal initial rotation in radians.
  74248. */
  74249. maxInitialRotation: number;
  74250. /**
  74251. * The particle emitter type defines the emitter used by the particle system.
  74252. * It can be for example box, sphere, or cone...
  74253. */
  74254. particleEmitterType: Nullable<IParticleEmitterType>;
  74255. /**
  74256. * Defines the delay in milliseconds before starting the system (0 by default)
  74257. */
  74258. startDelay: number;
  74259. /**
  74260. * 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
  74261. */
  74262. preWarmCycles: number;
  74263. /**
  74264. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  74265. */
  74266. preWarmStepOffset: number;
  74267. /**
  74268. * 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)
  74269. */
  74270. spriteCellChangeSpeed: number;
  74271. /**
  74272. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  74273. */
  74274. startSpriteCellID: number;
  74275. /**
  74276. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  74277. */
  74278. endSpriteCellID: number;
  74279. /**
  74280. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  74281. */
  74282. spriteCellWidth: number;
  74283. /**
  74284. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  74285. */
  74286. spriteCellHeight: number;
  74287. /**
  74288. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  74289. */
  74290. spriteRandomStartCell: boolean;
  74291. /**
  74292. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  74293. */
  74294. isAnimationSheetEnabled: boolean;
  74295. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  74296. translationPivot: Vector2;
  74297. /**
  74298. * Gets or sets a texture used to add random noise to particle positions
  74299. */
  74300. noiseTexture: Nullable<BaseTexture>;
  74301. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  74302. noiseStrength: Vector3;
  74303. /**
  74304. * Gets or sets the billboard mode to use when isBillboardBased = true.
  74305. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  74306. */
  74307. billboardMode: number;
  74308. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  74309. limitVelocityDamping: number;
  74310. /**
  74311. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  74312. */
  74313. beginAnimationOnStart: boolean;
  74314. /**
  74315. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  74316. */
  74317. beginAnimationFrom: number;
  74318. /**
  74319. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  74320. */
  74321. beginAnimationTo: number;
  74322. /**
  74323. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  74324. */
  74325. beginAnimationLoop: boolean;
  74326. /**
  74327. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  74328. */
  74329. disposeOnStop: boolean;
  74330. /**
  74331. * Gets the maximum number of particles active at the same time.
  74332. * @returns The max number of active particles.
  74333. */
  74334. getCapacity(): number;
  74335. /**
  74336. * Gets if the system has been started. (Note: this will still be true after stop is called)
  74337. * @returns True if it has been started, otherwise false.
  74338. */
  74339. isStarted(): boolean;
  74340. /**
  74341. * Animates the particle system for this frame.
  74342. */
  74343. animate(): void;
  74344. /**
  74345. * Renders the particle system in its current state.
  74346. * @returns the current number of particles
  74347. */
  74348. render(): number;
  74349. /**
  74350. * Dispose the particle system and frees its associated resources.
  74351. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  74352. */
  74353. dispose(disposeTexture?: boolean): void;
  74354. /**
  74355. * Clones the particle system.
  74356. * @param name The name of the cloned object
  74357. * @param newEmitter The new emitter to use
  74358. * @returns the cloned particle system
  74359. */
  74360. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  74361. /**
  74362. * Serializes the particle system to a JSON object.
  74363. * @returns the JSON object
  74364. */
  74365. serialize(): any;
  74366. /**
  74367. * Rebuild the particle system
  74368. */
  74369. rebuild(): void;
  74370. /**
  74371. * Starts the particle system and begins to emit
  74372. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  74373. */
  74374. start(delay?: number): void;
  74375. /**
  74376. * Stops the particle system.
  74377. */
  74378. stop(): void;
  74379. /**
  74380. * Remove all active particles
  74381. */
  74382. reset(): void;
  74383. /**
  74384. * Is this system ready to be used/rendered
  74385. * @return true if the system is ready
  74386. */
  74387. isReady(): boolean;
  74388. /**
  74389. * Adds a new color gradient
  74390. * @param gradient defines the gradient to use (between 0 and 1)
  74391. * @param color1 defines the color to affect to the specified gradient
  74392. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  74393. * @returns the current particle system
  74394. */
  74395. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  74396. /**
  74397. * Remove a specific color gradient
  74398. * @param gradient defines the gradient to remove
  74399. * @returns the current particle system
  74400. */
  74401. removeColorGradient(gradient: number): IParticleSystem;
  74402. /**
  74403. * Adds a new size gradient
  74404. * @param gradient defines the gradient to use (between 0 and 1)
  74405. * @param factor defines the size factor to affect to the specified gradient
  74406. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74407. * @returns the current particle system
  74408. */
  74409. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74410. /**
  74411. * Remove a specific size gradient
  74412. * @param gradient defines the gradient to remove
  74413. * @returns the current particle system
  74414. */
  74415. removeSizeGradient(gradient: number): IParticleSystem;
  74416. /**
  74417. * Gets the current list of color gradients.
  74418. * You must use addColorGradient and removeColorGradient to udpate this list
  74419. * @returns the list of color gradients
  74420. */
  74421. getColorGradients(): Nullable<Array<ColorGradient>>;
  74422. /**
  74423. * Gets the current list of size gradients.
  74424. * You must use addSizeGradient and removeSizeGradient to udpate this list
  74425. * @returns the list of size gradients
  74426. */
  74427. getSizeGradients(): Nullable<Array<FactorGradient>>;
  74428. /**
  74429. * Gets the current list of angular speed gradients.
  74430. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  74431. * @returns the list of angular speed gradients
  74432. */
  74433. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  74434. /**
  74435. * Adds a new angular speed gradient
  74436. * @param gradient defines the gradient to use (between 0 and 1)
  74437. * @param factor defines the angular speed to affect to the specified gradient
  74438. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74439. * @returns the current particle system
  74440. */
  74441. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74442. /**
  74443. * Remove a specific angular speed gradient
  74444. * @param gradient defines the gradient to remove
  74445. * @returns the current particle system
  74446. */
  74447. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  74448. /**
  74449. * Gets the current list of velocity gradients.
  74450. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  74451. * @returns the list of velocity gradients
  74452. */
  74453. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  74454. /**
  74455. * Adds a new velocity gradient
  74456. * @param gradient defines the gradient to use (between 0 and 1)
  74457. * @param factor defines the velocity to affect to the specified gradient
  74458. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74459. * @returns the current particle system
  74460. */
  74461. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74462. /**
  74463. * Remove a specific velocity gradient
  74464. * @param gradient defines the gradient to remove
  74465. * @returns the current particle system
  74466. */
  74467. removeVelocityGradient(gradient: number): IParticleSystem;
  74468. /**
  74469. * Gets the current list of limit velocity gradients.
  74470. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  74471. * @returns the list of limit velocity gradients
  74472. */
  74473. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  74474. /**
  74475. * Adds a new limit velocity gradient
  74476. * @param gradient defines the gradient to use (between 0 and 1)
  74477. * @param factor defines the limit velocity to affect to the specified gradient
  74478. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74479. * @returns the current particle system
  74480. */
  74481. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74482. /**
  74483. * Remove a specific limit velocity gradient
  74484. * @param gradient defines the gradient to remove
  74485. * @returns the current particle system
  74486. */
  74487. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  74488. /**
  74489. * Adds a new drag gradient
  74490. * @param gradient defines the gradient to use (between 0 and 1)
  74491. * @param factor defines the drag to affect to the specified gradient
  74492. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74493. * @returns the current particle system
  74494. */
  74495. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74496. /**
  74497. * Remove a specific drag gradient
  74498. * @param gradient defines the gradient to remove
  74499. * @returns the current particle system
  74500. */
  74501. removeDragGradient(gradient: number): IParticleSystem;
  74502. /**
  74503. * Gets the current list of drag gradients.
  74504. * You must use addDragGradient and removeDragGradient to udpate this list
  74505. * @returns the list of drag gradients
  74506. */
  74507. getDragGradients(): Nullable<Array<FactorGradient>>;
  74508. /**
  74509. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  74510. * @param gradient defines the gradient to use (between 0 and 1)
  74511. * @param factor defines the emit rate to affect to the specified gradient
  74512. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74513. * @returns the current particle system
  74514. */
  74515. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74516. /**
  74517. * Remove a specific emit rate gradient
  74518. * @param gradient defines the gradient to remove
  74519. * @returns the current particle system
  74520. */
  74521. removeEmitRateGradient(gradient: number): IParticleSystem;
  74522. /**
  74523. * Gets the current list of emit rate gradients.
  74524. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  74525. * @returns the list of emit rate gradients
  74526. */
  74527. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  74528. /**
  74529. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  74530. * @param gradient defines the gradient to use (between 0 and 1)
  74531. * @param factor defines the start size to affect to the specified gradient
  74532. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74533. * @returns the current particle system
  74534. */
  74535. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74536. /**
  74537. * Remove a specific start size gradient
  74538. * @param gradient defines the gradient to remove
  74539. * @returns the current particle system
  74540. */
  74541. removeStartSizeGradient(gradient: number): IParticleSystem;
  74542. /**
  74543. * Gets the current list of start size gradients.
  74544. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  74545. * @returns the list of start size gradients
  74546. */
  74547. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  74548. /**
  74549. * Adds a new life time gradient
  74550. * @param gradient defines the gradient to use (between 0 and 1)
  74551. * @param factor defines the life time factor to affect to the specified gradient
  74552. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74553. * @returns the current particle system
  74554. */
  74555. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74556. /**
  74557. * Remove a specific life time gradient
  74558. * @param gradient defines the gradient to remove
  74559. * @returns the current particle system
  74560. */
  74561. removeLifeTimeGradient(gradient: number): IParticleSystem;
  74562. /**
  74563. * Gets the current list of life time gradients.
  74564. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  74565. * @returns the list of life time gradients
  74566. */
  74567. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  74568. /**
  74569. * Gets the current list of color gradients.
  74570. * You must use addColorGradient and removeColorGradient to udpate this list
  74571. * @returns the list of color gradients
  74572. */
  74573. getColorGradients(): Nullable<Array<ColorGradient>>;
  74574. /**
  74575. * Adds a new ramp gradient used to remap particle colors
  74576. * @param gradient defines the gradient to use (between 0 and 1)
  74577. * @param color defines the color to affect to the specified gradient
  74578. * @returns the current particle system
  74579. */
  74580. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  74581. /**
  74582. * Gets the current list of ramp gradients.
  74583. * You must use addRampGradient and removeRampGradient to udpate this list
  74584. * @returns the list of ramp gradients
  74585. */
  74586. getRampGradients(): Nullable<Array<Color3Gradient>>;
  74587. /** Gets or sets a boolean indicating that ramp gradients must be used
  74588. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  74589. */
  74590. useRampGradients: boolean;
  74591. /**
  74592. * Adds a new color remap gradient
  74593. * @param gradient defines the gradient to use (between 0 and 1)
  74594. * @param min defines the color remap minimal range
  74595. * @param max defines the color remap maximal range
  74596. * @returns the current particle system
  74597. */
  74598. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74599. /**
  74600. * Gets the current list of color remap gradients.
  74601. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  74602. * @returns the list of color remap gradients
  74603. */
  74604. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  74605. /**
  74606. * Adds a new alpha remap gradient
  74607. * @param gradient defines the gradient to use (between 0 and 1)
  74608. * @param min defines the alpha remap minimal range
  74609. * @param max defines the alpha remap maximal range
  74610. * @returns the current particle system
  74611. */
  74612. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74613. /**
  74614. * Gets the current list of alpha remap gradients.
  74615. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  74616. * @returns the list of alpha remap gradients
  74617. */
  74618. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  74619. /**
  74620. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  74621. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74622. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74623. * @returns the emitter
  74624. */
  74625. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  74626. /**
  74627. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  74628. * @param radius The radius of the hemisphere to emit from
  74629. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74630. * @returns the emitter
  74631. */
  74632. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  74633. /**
  74634. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  74635. * @param radius The radius of the sphere to emit from
  74636. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74637. * @returns the emitter
  74638. */
  74639. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  74640. /**
  74641. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  74642. * @param radius The radius of the sphere to emit from
  74643. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  74644. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  74645. * @returns the emitter
  74646. */
  74647. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  74648. /**
  74649. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  74650. * @param radius The radius of the emission cylinder
  74651. * @param height The height of the emission cylinder
  74652. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  74653. * @param directionRandomizer How much to randomize the particle direction [0-1]
  74654. * @returns the emitter
  74655. */
  74656. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  74657. /**
  74658. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  74659. * @param radius The radius of the cylinder to emit from
  74660. * @param height The height of the emission cylinder
  74661. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74662. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  74663. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  74664. * @returns the emitter
  74665. */
  74666. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  74667. /**
  74668. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  74669. * @param radius The radius of the cone to emit from
  74670. * @param angle The base angle of the cone
  74671. * @returns the emitter
  74672. */
  74673. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  74674. /**
  74675. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  74676. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74677. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74678. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74679. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74680. * @returns the emitter
  74681. */
  74682. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  74683. /**
  74684. * Get hosting scene
  74685. * @returns the scene
  74686. */
  74687. getScene(): Scene;
  74688. }
  74689. }
  74690. declare module BABYLON {
  74691. /**
  74692. * Creates an instance based on a source mesh.
  74693. */
  74694. export class InstancedMesh extends AbstractMesh {
  74695. private _sourceMesh;
  74696. private _currentLOD;
  74697. /** @hidden */
  74698. _indexInSourceMeshInstanceArray: number;
  74699. constructor(name: string, source: Mesh);
  74700. /**
  74701. * Returns the string "InstancedMesh".
  74702. */
  74703. getClassName(): string;
  74704. /**
  74705. * If the source mesh receives shadows
  74706. */
  74707. readonly receiveShadows: boolean;
  74708. /**
  74709. * The material of the source mesh
  74710. */
  74711. readonly material: Nullable<Material>;
  74712. /**
  74713. * Visibility of the source mesh
  74714. */
  74715. readonly visibility: number;
  74716. /**
  74717. * Skeleton of the source mesh
  74718. */
  74719. readonly skeleton: Nullable<Skeleton>;
  74720. /**
  74721. * Rendering ground id of the source mesh
  74722. */
  74723. renderingGroupId: number;
  74724. /**
  74725. * Returns the total number of vertices (integer).
  74726. */
  74727. getTotalVertices(): number;
  74728. /**
  74729. * Returns a positive integer : the total number of indices in this mesh geometry.
  74730. * @returns the numner of indices or zero if the mesh has no geometry.
  74731. */
  74732. getTotalIndices(): number;
  74733. /**
  74734. * The source mesh of the instance
  74735. */
  74736. readonly sourceMesh: Mesh;
  74737. /**
  74738. * Is this node ready to be used/rendered
  74739. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  74740. * @return {boolean} is it ready
  74741. */
  74742. isReady(completeCheck?: boolean): boolean;
  74743. /**
  74744. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  74745. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  74746. * @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.
  74747. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  74748. */
  74749. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  74750. /**
  74751. * Sets the vertex data of the mesh geometry for the requested `kind`.
  74752. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  74753. * The `data` are either a numeric array either a Float32Array.
  74754. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  74755. * 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).
  74756. * Note that a new underlying VertexBuffer object is created each call.
  74757. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  74758. *
  74759. * Possible `kind` values :
  74760. * - VertexBuffer.PositionKind
  74761. * - VertexBuffer.UVKind
  74762. * - VertexBuffer.UV2Kind
  74763. * - VertexBuffer.UV3Kind
  74764. * - VertexBuffer.UV4Kind
  74765. * - VertexBuffer.UV5Kind
  74766. * - VertexBuffer.UV6Kind
  74767. * - VertexBuffer.ColorKind
  74768. * - VertexBuffer.MatricesIndicesKind
  74769. * - VertexBuffer.MatricesIndicesExtraKind
  74770. * - VertexBuffer.MatricesWeightsKind
  74771. * - VertexBuffer.MatricesWeightsExtraKind
  74772. *
  74773. * Returns the Mesh.
  74774. */
  74775. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  74776. /**
  74777. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  74778. * If the mesh has no geometry, it is simply returned as it is.
  74779. * The `data` are either a numeric array either a Float32Array.
  74780. * No new underlying VertexBuffer object is created.
  74781. * 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.
  74782. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  74783. *
  74784. * Possible `kind` values :
  74785. * - VertexBuffer.PositionKind
  74786. * - VertexBuffer.UVKind
  74787. * - VertexBuffer.UV2Kind
  74788. * - VertexBuffer.UV3Kind
  74789. * - VertexBuffer.UV4Kind
  74790. * - VertexBuffer.UV5Kind
  74791. * - VertexBuffer.UV6Kind
  74792. * - VertexBuffer.ColorKind
  74793. * - VertexBuffer.MatricesIndicesKind
  74794. * - VertexBuffer.MatricesIndicesExtraKind
  74795. * - VertexBuffer.MatricesWeightsKind
  74796. * - VertexBuffer.MatricesWeightsExtraKind
  74797. *
  74798. * Returns the Mesh.
  74799. */
  74800. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  74801. /**
  74802. * Sets the mesh indices.
  74803. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  74804. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  74805. * This method creates a new index buffer each call.
  74806. * Returns the Mesh.
  74807. */
  74808. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  74809. /**
  74810. * Boolean : True if the mesh owns the requested kind of data.
  74811. */
  74812. isVerticesDataPresent(kind: string): boolean;
  74813. /**
  74814. * Returns an array of indices (IndicesArray).
  74815. */
  74816. getIndices(): Nullable<IndicesArray>;
  74817. readonly _positions: Nullable<Vector3[]>;
  74818. /**
  74819. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  74820. * This means the mesh underlying bounding box and sphere are recomputed.
  74821. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  74822. * @returns the current mesh
  74823. */
  74824. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  74825. /** @hidden */
  74826. _preActivate(): InstancedMesh;
  74827. /** @hidden */
  74828. _activate(renderId: number): InstancedMesh;
  74829. /**
  74830. * Returns the current associated LOD AbstractMesh.
  74831. */
  74832. getLOD(camera: Camera): AbstractMesh;
  74833. /** @hidden */
  74834. _syncSubMeshes(): InstancedMesh;
  74835. /** @hidden */
  74836. _generatePointsArray(): boolean;
  74837. /**
  74838. * Creates a new InstancedMesh from the current mesh.
  74839. * - name (string) : the cloned mesh name
  74840. * - newParent (optional Node) : the optional Node to parent the clone to.
  74841. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  74842. *
  74843. * Returns the clone.
  74844. */
  74845. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  74846. /**
  74847. * Disposes the InstancedMesh.
  74848. * Returns nothing.
  74849. */
  74850. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74851. }
  74852. }
  74853. declare module BABYLON {
  74854. /**
  74855. * Defines the options associated with the creation of a shader material.
  74856. */
  74857. export interface IShaderMaterialOptions {
  74858. /**
  74859. * Does the material work in alpha blend mode
  74860. */
  74861. needAlphaBlending: boolean;
  74862. /**
  74863. * Does the material work in alpha test mode
  74864. */
  74865. needAlphaTesting: boolean;
  74866. /**
  74867. * The list of attribute names used in the shader
  74868. */
  74869. attributes: string[];
  74870. /**
  74871. * The list of unifrom names used in the shader
  74872. */
  74873. uniforms: string[];
  74874. /**
  74875. * The list of UBO names used in the shader
  74876. */
  74877. uniformBuffers: string[];
  74878. /**
  74879. * The list of sampler names used in the shader
  74880. */
  74881. samplers: string[];
  74882. /**
  74883. * The list of defines used in the shader
  74884. */
  74885. defines: string[];
  74886. }
  74887. /**
  74888. * 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.
  74889. *
  74890. * This returned material effects how the mesh will look based on the code in the shaders.
  74891. *
  74892. * @see http://doc.babylonjs.com/how_to/shader_material
  74893. */
  74894. export class ShaderMaterial extends Material {
  74895. private _shaderPath;
  74896. private _options;
  74897. private _textures;
  74898. private _textureArrays;
  74899. private _floats;
  74900. private _ints;
  74901. private _floatsArrays;
  74902. private _colors3;
  74903. private _colors3Arrays;
  74904. private _colors4;
  74905. private _vectors2;
  74906. private _vectors3;
  74907. private _vectors4;
  74908. private _matrices;
  74909. private _matrices3x3;
  74910. private _matrices2x2;
  74911. private _vectors2Arrays;
  74912. private _vectors3Arrays;
  74913. private _cachedWorldViewMatrix;
  74914. private _renderId;
  74915. /**
  74916. * Instantiate a new shader material.
  74917. * 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.
  74918. * This returned material effects how the mesh will look based on the code in the shaders.
  74919. * @see http://doc.babylonjs.com/how_to/shader_material
  74920. * @param name Define the name of the material in the scene
  74921. * @param scene Define the scene the material belongs to
  74922. * @param shaderPath Defines the route to the shader code in one of three ways:
  74923. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  74924. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  74925. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  74926. * @param options Define the options used to create the shader
  74927. */
  74928. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  74929. /**
  74930. * Gets the options used to compile the shader.
  74931. * They can be modified to trigger a new compilation
  74932. */
  74933. readonly options: IShaderMaterialOptions;
  74934. /**
  74935. * Gets the current class name of the material e.g. "ShaderMaterial"
  74936. * Mainly use in serialization.
  74937. * @returns the class name
  74938. */
  74939. getClassName(): string;
  74940. /**
  74941. * Specifies if the material will require alpha blending
  74942. * @returns a boolean specifying if alpha blending is needed
  74943. */
  74944. needAlphaBlending(): boolean;
  74945. /**
  74946. * Specifies if this material should be rendered in alpha test mode
  74947. * @returns a boolean specifying if an alpha test is needed.
  74948. */
  74949. needAlphaTesting(): boolean;
  74950. private _checkUniform;
  74951. /**
  74952. * Set a texture in the shader.
  74953. * @param name Define the name of the uniform samplers as defined in the shader
  74954. * @param texture Define the texture to bind to this sampler
  74955. * @return the material itself allowing "fluent" like uniform updates
  74956. */
  74957. setTexture(name: string, texture: Texture): ShaderMaterial;
  74958. /**
  74959. * Set a texture array in the shader.
  74960. * @param name Define the name of the uniform sampler array as defined in the shader
  74961. * @param textures Define the list of textures to bind to this sampler
  74962. * @return the material itself allowing "fluent" like uniform updates
  74963. */
  74964. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  74965. /**
  74966. * Set a float in the shader.
  74967. * @param name Define the name of the uniform as defined in the shader
  74968. * @param value Define the value to give to the uniform
  74969. * @return the material itself allowing "fluent" like uniform updates
  74970. */
  74971. setFloat(name: string, value: number): ShaderMaterial;
  74972. /**
  74973. * Set a int in the shader.
  74974. * @param name Define the name of the uniform as defined in the shader
  74975. * @param value Define the value to give to the uniform
  74976. * @return the material itself allowing "fluent" like uniform updates
  74977. */
  74978. setInt(name: string, value: number): ShaderMaterial;
  74979. /**
  74980. * Set an array of floats in the shader.
  74981. * @param name Define the name of the uniform as defined in the shader
  74982. * @param value Define the value to give to the uniform
  74983. * @return the material itself allowing "fluent" like uniform updates
  74984. */
  74985. setFloats(name: string, value: number[]): ShaderMaterial;
  74986. /**
  74987. * Set a vec3 in the shader from a Color3.
  74988. * @param name Define the name of the uniform as defined in the shader
  74989. * @param value Define the value to give to the uniform
  74990. * @return the material itself allowing "fluent" like uniform updates
  74991. */
  74992. setColor3(name: string, value: Color3): ShaderMaterial;
  74993. /**
  74994. * Set a vec3 array in the shader from a Color3 array.
  74995. * @param name Define the name of the uniform as defined in the shader
  74996. * @param value Define the value to give to the uniform
  74997. * @return the material itself allowing "fluent" like uniform updates
  74998. */
  74999. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  75000. /**
  75001. * Set a vec4 in the shader from a Color4.
  75002. * @param name Define the name of the uniform as defined in the shader
  75003. * @param value Define the value to give to the uniform
  75004. * @return the material itself allowing "fluent" like uniform updates
  75005. */
  75006. setColor4(name: string, value: Color4): ShaderMaterial;
  75007. /**
  75008. * Set a vec2 in the shader from a Vector2.
  75009. * @param name Define the name of the uniform as defined in the shader
  75010. * @param value Define the value to give to the uniform
  75011. * @return the material itself allowing "fluent" like uniform updates
  75012. */
  75013. setVector2(name: string, value: Vector2): ShaderMaterial;
  75014. /**
  75015. * Set a vec3 in the shader from a Vector3.
  75016. * @param name Define the name of the uniform as defined in the shader
  75017. * @param value Define the value to give to the uniform
  75018. * @return the material itself allowing "fluent" like uniform updates
  75019. */
  75020. setVector3(name: string, value: Vector3): ShaderMaterial;
  75021. /**
  75022. * Set a vec4 in the shader from a Vector4.
  75023. * @param name Define the name of the uniform as defined in the shader
  75024. * @param value Define the value to give to the uniform
  75025. * @return the material itself allowing "fluent" like uniform updates
  75026. */
  75027. setVector4(name: string, value: Vector4): ShaderMaterial;
  75028. /**
  75029. * Set a mat4 in the shader from a Matrix.
  75030. * @param name Define the name of the uniform as defined in the shader
  75031. * @param value Define the value to give to the uniform
  75032. * @return the material itself allowing "fluent" like uniform updates
  75033. */
  75034. setMatrix(name: string, value: Matrix): ShaderMaterial;
  75035. /**
  75036. * Set a mat3 in the shader from a Float32Array.
  75037. * @param name Define the name of the uniform as defined in the shader
  75038. * @param value Define the value to give to the uniform
  75039. * @return the material itself allowing "fluent" like uniform updates
  75040. */
  75041. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  75042. /**
  75043. * Set a mat2 in the shader from a Float32Array.
  75044. * @param name Define the name of the uniform as defined in the shader
  75045. * @param value Define the value to give to the uniform
  75046. * @return the material itself allowing "fluent" like uniform updates
  75047. */
  75048. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  75049. /**
  75050. * Set a vec2 array in the shader from a number array.
  75051. * @param name Define the name of the uniform as defined in the shader
  75052. * @param value Define the value to give to the uniform
  75053. * @return the material itself allowing "fluent" like uniform updates
  75054. */
  75055. setArray2(name: string, value: number[]): ShaderMaterial;
  75056. /**
  75057. * Set a vec3 array in the shader from a number array.
  75058. * @param name Define the name of the uniform as defined in the shader
  75059. * @param value Define the value to give to the uniform
  75060. * @return the material itself allowing "fluent" like uniform updates
  75061. */
  75062. setArray3(name: string, value: number[]): ShaderMaterial;
  75063. private _checkCache;
  75064. /**
  75065. * Checks if the material is ready to render the requested mesh
  75066. * @param mesh Define the mesh to render
  75067. * @param useInstances Define whether or not the material is used with instances
  75068. * @returns true if ready, otherwise false
  75069. */
  75070. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  75071. /**
  75072. * Binds the world matrix to the material
  75073. * @param world defines the world transformation matrix
  75074. */
  75075. bindOnlyWorldMatrix(world: Matrix): void;
  75076. /**
  75077. * Binds the material to the mesh
  75078. * @param world defines the world transformation matrix
  75079. * @param mesh defines the mesh to bind the material to
  75080. */
  75081. bind(world: Matrix, mesh?: Mesh): void;
  75082. /**
  75083. * Gets the active textures from the material
  75084. * @returns an array of textures
  75085. */
  75086. getActiveTextures(): BaseTexture[];
  75087. /**
  75088. * Specifies if the material uses a texture
  75089. * @param texture defines the texture to check against the material
  75090. * @returns a boolean specifying if the material uses the texture
  75091. */
  75092. hasTexture(texture: BaseTexture): boolean;
  75093. /**
  75094. * Makes a duplicate of the material, and gives it a new name
  75095. * @param name defines the new name for the duplicated material
  75096. * @returns the cloned material
  75097. */
  75098. clone(name: string): ShaderMaterial;
  75099. /**
  75100. * Disposes the material
  75101. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75102. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  75103. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  75104. */
  75105. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  75106. /**
  75107. * Serializes this material in a JSON representation
  75108. * @returns the serialized material object
  75109. */
  75110. serialize(): any;
  75111. /**
  75112. * Creates a shader material from parsed shader material data
  75113. * @param source defines the JSON represnetation of the material
  75114. * @param scene defines the hosting scene
  75115. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75116. * @returns a new material
  75117. */
  75118. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  75119. }
  75120. }
  75121. declare module BABYLON {
  75122. /** @hidden */
  75123. export var colorPixelShader: {
  75124. name: string;
  75125. shader: string;
  75126. };
  75127. }
  75128. declare module BABYLON {
  75129. /** @hidden */
  75130. export var colorVertexShader: {
  75131. name: string;
  75132. shader: string;
  75133. };
  75134. }
  75135. declare module BABYLON {
  75136. /**
  75137. * Line mesh
  75138. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  75139. */
  75140. export class LinesMesh extends Mesh {
  75141. /**
  75142. * If vertex color should be applied to the mesh
  75143. */
  75144. useVertexColor?: boolean | undefined;
  75145. /**
  75146. * If vertex alpha should be applied to the mesh
  75147. */
  75148. useVertexAlpha?: boolean | undefined;
  75149. /**
  75150. * Color of the line (Default: White)
  75151. */
  75152. color: Color3;
  75153. /**
  75154. * Alpha of the line (Default: 1)
  75155. */
  75156. alpha: number;
  75157. /**
  75158. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75159. * This margin is expressed in world space coordinates, so its value may vary.
  75160. * Default value is 0.1
  75161. */
  75162. intersectionThreshold: number;
  75163. private _colorShader;
  75164. /**
  75165. * Creates a new LinesMesh
  75166. * @param name defines the name
  75167. * @param scene defines the hosting scene
  75168. * @param parent defines the parent mesh if any
  75169. * @param source defines the optional source LinesMesh used to clone data from
  75170. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  75171. * When false, achieved by calling a clone(), also passing False.
  75172. * This will make creation of children, recursive.
  75173. * @param useVertexColor defines if this LinesMesh supports vertex color
  75174. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  75175. */
  75176. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  75177. /**
  75178. * If vertex color should be applied to the mesh
  75179. */
  75180. useVertexColor?: boolean | undefined,
  75181. /**
  75182. * If vertex alpha should be applied to the mesh
  75183. */
  75184. useVertexAlpha?: boolean | undefined);
  75185. private _addClipPlaneDefine;
  75186. private _removeClipPlaneDefine;
  75187. isReady(): boolean;
  75188. /**
  75189. * Returns the string "LineMesh"
  75190. */
  75191. getClassName(): string;
  75192. /**
  75193. * @hidden
  75194. */
  75195. /**
  75196. * @hidden
  75197. */
  75198. material: Material;
  75199. /**
  75200. * @hidden
  75201. */
  75202. readonly checkCollisions: boolean;
  75203. /** @hidden */
  75204. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  75205. /** @hidden */
  75206. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  75207. /**
  75208. * Disposes of the line mesh
  75209. * @param doNotRecurse If children should be disposed
  75210. */
  75211. dispose(doNotRecurse?: boolean): void;
  75212. /**
  75213. * Returns a new LineMesh object cloned from the current one.
  75214. */
  75215. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  75216. /**
  75217. * Creates a new InstancedLinesMesh object from the mesh model.
  75218. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75219. * @param name defines the name of the new instance
  75220. * @returns a new InstancedLinesMesh
  75221. */
  75222. createInstance(name: string): InstancedLinesMesh;
  75223. }
  75224. /**
  75225. * Creates an instance based on a source LinesMesh
  75226. */
  75227. export class InstancedLinesMesh extends InstancedMesh {
  75228. /**
  75229. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75230. * This margin is expressed in world space coordinates, so its value may vary.
  75231. * Initilized with the intersectionThreshold value of the source LinesMesh
  75232. */
  75233. intersectionThreshold: number;
  75234. constructor(name: string, source: LinesMesh);
  75235. /**
  75236. * Returns the string "InstancedLinesMesh".
  75237. */
  75238. getClassName(): string;
  75239. }
  75240. }
  75241. declare module BABYLON {
  75242. /** @hidden */
  75243. export var linePixelShader: {
  75244. name: string;
  75245. shader: string;
  75246. };
  75247. }
  75248. declare module BABYLON {
  75249. /** @hidden */
  75250. export var lineVertexShader: {
  75251. name: string;
  75252. shader: string;
  75253. };
  75254. }
  75255. declare module BABYLON {
  75256. interface AbstractMesh {
  75257. /**
  75258. * Disables the mesh edge rendering mode
  75259. * @returns the currentAbstractMesh
  75260. */
  75261. disableEdgesRendering(): AbstractMesh;
  75262. /**
  75263. * Enables the edge rendering mode on the mesh.
  75264. * This mode makes the mesh edges visible
  75265. * @param epsilon defines the maximal distance between two angles to detect a face
  75266. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  75267. * @returns the currentAbstractMesh
  75268. * @see https://www.babylonjs-playground.com/#19O9TU#0
  75269. */
  75270. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  75271. /**
  75272. * Gets the edgesRenderer associated with the mesh
  75273. */
  75274. edgesRenderer: Nullable<EdgesRenderer>;
  75275. }
  75276. interface LinesMesh {
  75277. /**
  75278. * Enables the edge rendering mode on the mesh.
  75279. * This mode makes the mesh edges visible
  75280. * @param epsilon defines the maximal distance between two angles to detect a face
  75281. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  75282. * @returns the currentAbstractMesh
  75283. * @see https://www.babylonjs-playground.com/#19O9TU#0
  75284. */
  75285. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  75286. }
  75287. interface InstancedLinesMesh {
  75288. /**
  75289. * Enables the edge rendering mode on the mesh.
  75290. * This mode makes the mesh edges visible
  75291. * @param epsilon defines the maximal distance between two angles to detect a face
  75292. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  75293. * @returns the current InstancedLinesMesh
  75294. * @see https://www.babylonjs-playground.com/#19O9TU#0
  75295. */
  75296. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  75297. }
  75298. /**
  75299. * Defines the minimum contract an Edges renderer should follow.
  75300. */
  75301. export interface IEdgesRenderer extends IDisposable {
  75302. /**
  75303. * Gets or sets a boolean indicating if the edgesRenderer is active
  75304. */
  75305. isEnabled: boolean;
  75306. /**
  75307. * Renders the edges of the attached mesh,
  75308. */
  75309. render(): void;
  75310. /**
  75311. * Checks wether or not the edges renderer is ready to render.
  75312. * @return true if ready, otherwise false.
  75313. */
  75314. isReady(): boolean;
  75315. }
  75316. /**
  75317. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  75318. */
  75319. export class EdgesRenderer implements IEdgesRenderer {
  75320. /**
  75321. * Define the size of the edges with an orthographic camera
  75322. */
  75323. edgesWidthScalerForOrthographic: number;
  75324. /**
  75325. * Define the size of the edges with a perspective camera
  75326. */
  75327. edgesWidthScalerForPerspective: number;
  75328. protected _source: AbstractMesh;
  75329. protected _linesPositions: number[];
  75330. protected _linesNormals: number[];
  75331. protected _linesIndices: number[];
  75332. protected _epsilon: number;
  75333. protected _indicesCount: number;
  75334. protected _lineShader: ShaderMaterial;
  75335. protected _ib: WebGLBuffer;
  75336. protected _buffers: {
  75337. [key: string]: Nullable<VertexBuffer>;
  75338. };
  75339. protected _checkVerticesInsteadOfIndices: boolean;
  75340. private _meshRebuildObserver;
  75341. private _meshDisposeObserver;
  75342. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  75343. isEnabled: boolean;
  75344. /**
  75345. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  75346. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  75347. * @param source Mesh used to create edges
  75348. * @param epsilon sum of angles in adjacency to check for edge
  75349. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  75350. * @param generateEdgesLines - should generate Lines or only prepare resources.
  75351. */
  75352. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  75353. protected _prepareRessources(): void;
  75354. /** @hidden */
  75355. _rebuild(): void;
  75356. /**
  75357. * Releases the required resources for the edges renderer
  75358. */
  75359. dispose(): void;
  75360. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  75361. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  75362. /**
  75363. * Checks if the pair of p0 and p1 is en edge
  75364. * @param faceIndex
  75365. * @param edge
  75366. * @param faceNormals
  75367. * @param p0
  75368. * @param p1
  75369. * @private
  75370. */
  75371. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  75372. /**
  75373. * push line into the position, normal and index buffer
  75374. * @protected
  75375. */
  75376. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  75377. /**
  75378. * Generates lines edges from adjacencjes
  75379. * @private
  75380. */
  75381. _generateEdgesLines(): void;
  75382. /**
  75383. * Checks wether or not the edges renderer is ready to render.
  75384. * @return true if ready, otherwise false.
  75385. */
  75386. isReady(): boolean;
  75387. /**
  75388. * Renders the edges of the attached mesh,
  75389. */
  75390. render(): void;
  75391. }
  75392. /**
  75393. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  75394. */
  75395. export class LineEdgesRenderer extends EdgesRenderer {
  75396. /**
  75397. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  75398. * @param source LineMesh used to generate edges
  75399. * @param epsilon not important (specified angle for edge detection)
  75400. * @param checkVerticesInsteadOfIndices not important for LineMesh
  75401. */
  75402. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  75403. /**
  75404. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  75405. */
  75406. _generateEdgesLines(): void;
  75407. }
  75408. }
  75409. declare module BABYLON {
  75410. /**
  75411. * This represents the object necessary to create a rendering group.
  75412. * This is exclusively used and created by the rendering manager.
  75413. * To modify the behavior, you use the available helpers in your scene or meshes.
  75414. * @hidden
  75415. */
  75416. export class RenderingGroup {
  75417. index: number;
  75418. private _scene;
  75419. private _opaqueSubMeshes;
  75420. private _transparentSubMeshes;
  75421. private _alphaTestSubMeshes;
  75422. private _depthOnlySubMeshes;
  75423. private _particleSystems;
  75424. private _spriteManagers;
  75425. private _opaqueSortCompareFn;
  75426. private _alphaTestSortCompareFn;
  75427. private _transparentSortCompareFn;
  75428. private _renderOpaque;
  75429. private _renderAlphaTest;
  75430. private _renderTransparent;
  75431. private _edgesRenderers;
  75432. onBeforeTransparentRendering: () => void;
  75433. /**
  75434. * Set the opaque sort comparison function.
  75435. * If null the sub meshes will be render in the order they were created
  75436. */
  75437. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  75438. /**
  75439. * Set the alpha test sort comparison function.
  75440. * If null the sub meshes will be render in the order they were created
  75441. */
  75442. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  75443. /**
  75444. * Set the transparent sort comparison function.
  75445. * If null the sub meshes will be render in the order they were created
  75446. */
  75447. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  75448. /**
  75449. * Creates a new rendering group.
  75450. * @param index The rendering group index
  75451. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  75452. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  75453. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  75454. */
  75455. 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>);
  75456. /**
  75457. * Render all the sub meshes contained in the group.
  75458. * @param customRenderFunction Used to override the default render behaviour of the group.
  75459. * @returns true if rendered some submeshes.
  75460. */
  75461. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  75462. /**
  75463. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  75464. * @param subMeshes The submeshes to render
  75465. */
  75466. private renderOpaqueSorted;
  75467. /**
  75468. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  75469. * @param subMeshes The submeshes to render
  75470. */
  75471. private renderAlphaTestSorted;
  75472. /**
  75473. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  75474. * @param subMeshes The submeshes to render
  75475. */
  75476. private renderTransparentSorted;
  75477. /**
  75478. * Renders the submeshes in a specified order.
  75479. * @param subMeshes The submeshes to sort before render
  75480. * @param sortCompareFn The comparison function use to sort
  75481. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  75482. * @param transparent Specifies to activate blending if true
  75483. */
  75484. private static renderSorted;
  75485. /**
  75486. * Renders the submeshes in the order they were dispatched (no sort applied).
  75487. * @param subMeshes The submeshes to render
  75488. */
  75489. private static renderUnsorted;
  75490. /**
  75491. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  75492. * are rendered back to front if in the same alpha index.
  75493. *
  75494. * @param a The first submesh
  75495. * @param b The second submesh
  75496. * @returns The result of the comparison
  75497. */
  75498. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  75499. /**
  75500. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  75501. * are rendered back to front.
  75502. *
  75503. * @param a The first submesh
  75504. * @param b The second submesh
  75505. * @returns The result of the comparison
  75506. */
  75507. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  75508. /**
  75509. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  75510. * are rendered front to back (prevent overdraw).
  75511. *
  75512. * @param a The first submesh
  75513. * @param b The second submesh
  75514. * @returns The result of the comparison
  75515. */
  75516. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  75517. /**
  75518. * Resets the different lists of submeshes to prepare a new frame.
  75519. */
  75520. prepare(): void;
  75521. dispose(): void;
  75522. /**
  75523. * Inserts the submesh in its correct queue depending on its material.
  75524. * @param subMesh The submesh to dispatch
  75525. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  75526. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  75527. */
  75528. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  75529. dispatchSprites(spriteManager: ISpriteManager): void;
  75530. dispatchParticles(particleSystem: IParticleSystem): void;
  75531. private _renderParticles;
  75532. private _renderSprites;
  75533. }
  75534. }
  75535. declare module BABYLON {
  75536. /**
  75537. * Interface describing the different options available in the rendering manager
  75538. * regarding Auto Clear between groups.
  75539. */
  75540. export interface IRenderingManagerAutoClearSetup {
  75541. /**
  75542. * Defines whether or not autoclear is enable.
  75543. */
  75544. autoClear: boolean;
  75545. /**
  75546. * Defines whether or not to autoclear the depth buffer.
  75547. */
  75548. depth: boolean;
  75549. /**
  75550. * Defines whether or not to autoclear the stencil buffer.
  75551. */
  75552. stencil: boolean;
  75553. }
  75554. /**
  75555. * This class is used by the onRenderingGroupObservable
  75556. */
  75557. export class RenderingGroupInfo {
  75558. /**
  75559. * The Scene that being rendered
  75560. */
  75561. scene: Scene;
  75562. /**
  75563. * The camera currently used for the rendering pass
  75564. */
  75565. camera: Nullable<Camera>;
  75566. /**
  75567. * The ID of the renderingGroup being processed
  75568. */
  75569. renderingGroupId: number;
  75570. }
  75571. /**
  75572. * This is the manager responsible of all the rendering for meshes sprites and particles.
  75573. * It is enable to manage the different groups as well as the different necessary sort functions.
  75574. * This should not be used directly aside of the few static configurations
  75575. */
  75576. export class RenderingManager {
  75577. /**
  75578. * The max id used for rendering groups (not included)
  75579. */
  75580. static MAX_RENDERINGGROUPS: number;
  75581. /**
  75582. * The min id used for rendering groups (included)
  75583. */
  75584. static MIN_RENDERINGGROUPS: number;
  75585. /**
  75586. * Used to globally prevent autoclearing scenes.
  75587. */
  75588. static AUTOCLEAR: boolean;
  75589. /**
  75590. * @hidden
  75591. */
  75592. _useSceneAutoClearSetup: boolean;
  75593. private _scene;
  75594. private _renderingGroups;
  75595. private _depthStencilBufferAlreadyCleaned;
  75596. private _autoClearDepthStencil;
  75597. private _customOpaqueSortCompareFn;
  75598. private _customAlphaTestSortCompareFn;
  75599. private _customTransparentSortCompareFn;
  75600. private _renderingGroupInfo;
  75601. /**
  75602. * Instantiates a new rendering group for a particular scene
  75603. * @param scene Defines the scene the groups belongs to
  75604. */
  75605. constructor(scene: Scene);
  75606. private _clearDepthStencilBuffer;
  75607. /**
  75608. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  75609. * @hidden
  75610. */
  75611. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  75612. /**
  75613. * Resets the different information of the group to prepare a new frame
  75614. * @hidden
  75615. */
  75616. reset(): void;
  75617. /**
  75618. * Dispose and release the group and its associated resources.
  75619. * @hidden
  75620. */
  75621. dispose(): void;
  75622. /**
  75623. * Clear the info related to rendering groups preventing retention points during dispose.
  75624. */
  75625. freeRenderingGroups(): void;
  75626. private _prepareRenderingGroup;
  75627. /**
  75628. * Add a sprite manager to the rendering manager in order to render it this frame.
  75629. * @param spriteManager Define the sprite manager to render
  75630. */
  75631. dispatchSprites(spriteManager: ISpriteManager): void;
  75632. /**
  75633. * Add a particle system to the rendering manager in order to render it this frame.
  75634. * @param particleSystem Define the particle system to render
  75635. */
  75636. dispatchParticles(particleSystem: IParticleSystem): void;
  75637. /**
  75638. * Add a submesh to the manager in order to render it this frame
  75639. * @param subMesh The submesh to dispatch
  75640. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  75641. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  75642. */
  75643. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  75644. /**
  75645. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  75646. * This allowed control for front to back rendering or reversly depending of the special needs.
  75647. *
  75648. * @param renderingGroupId The rendering group id corresponding to its index
  75649. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  75650. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  75651. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  75652. */
  75653. 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;
  75654. /**
  75655. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  75656. *
  75657. * @param renderingGroupId The rendering group id corresponding to its index
  75658. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  75659. * @param depth Automatically clears depth between groups if true and autoClear is true.
  75660. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  75661. */
  75662. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  75663. /**
  75664. * Gets the current auto clear configuration for one rendering group of the rendering
  75665. * manager.
  75666. * @param index the rendering group index to get the information for
  75667. * @returns The auto clear setup for the requested rendering group
  75668. */
  75669. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  75670. }
  75671. }
  75672. declare module BABYLON {
  75673. /**
  75674. * This Helps creating a texture that will be created from a camera in your scene.
  75675. * It is basically a dynamic texture that could be used to create special effects for instance.
  75676. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  75677. */
  75678. export class RenderTargetTexture extends Texture {
  75679. isCube: boolean;
  75680. /**
  75681. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  75682. */
  75683. static readonly REFRESHRATE_RENDER_ONCE: number;
  75684. /**
  75685. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  75686. */
  75687. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  75688. /**
  75689. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  75690. * the central point of your effect and can save a lot of performances.
  75691. */
  75692. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  75693. /**
  75694. * Use this predicate to dynamically define the list of mesh you want to render.
  75695. * If set, the renderList property will be overwritten.
  75696. */
  75697. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  75698. private _renderList;
  75699. /**
  75700. * Use this list to define the list of mesh you want to render.
  75701. */
  75702. renderList: Nullable<Array<AbstractMesh>>;
  75703. private _hookArray;
  75704. /**
  75705. * Define if particles should be rendered in your texture.
  75706. */
  75707. renderParticles: boolean;
  75708. /**
  75709. * Define if sprites should be rendered in your texture.
  75710. */
  75711. renderSprites: boolean;
  75712. /**
  75713. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  75714. */
  75715. coordinatesMode: number;
  75716. /**
  75717. * Define the camera used to render the texture.
  75718. */
  75719. activeCamera: Nullable<Camera>;
  75720. /**
  75721. * Override the render function of the texture with your own one.
  75722. */
  75723. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  75724. /**
  75725. * Define if camera post processes should be use while rendering the texture.
  75726. */
  75727. useCameraPostProcesses: boolean;
  75728. /**
  75729. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  75730. */
  75731. ignoreCameraViewport: boolean;
  75732. private _postProcessManager;
  75733. private _postProcesses;
  75734. private _resizeObserver;
  75735. /**
  75736. * An event triggered when the texture is unbind.
  75737. */
  75738. onBeforeBindObservable: Observable<RenderTargetTexture>;
  75739. /**
  75740. * An event triggered when the texture is unbind.
  75741. */
  75742. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  75743. private _onAfterUnbindObserver;
  75744. /**
  75745. * Set a after unbind callback in the texture.
  75746. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  75747. */
  75748. onAfterUnbind: () => void;
  75749. /**
  75750. * An event triggered before rendering the texture
  75751. */
  75752. onBeforeRenderObservable: Observable<number>;
  75753. private _onBeforeRenderObserver;
  75754. /**
  75755. * Set a before render callback in the texture.
  75756. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  75757. */
  75758. onBeforeRender: (faceIndex: number) => void;
  75759. /**
  75760. * An event triggered after rendering the texture
  75761. */
  75762. onAfterRenderObservable: Observable<number>;
  75763. private _onAfterRenderObserver;
  75764. /**
  75765. * Set a after render callback in the texture.
  75766. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  75767. */
  75768. onAfterRender: (faceIndex: number) => void;
  75769. /**
  75770. * An event triggered after the texture clear
  75771. */
  75772. onClearObservable: Observable<Engine>;
  75773. private _onClearObserver;
  75774. /**
  75775. * Set a clear callback in the texture.
  75776. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  75777. */
  75778. onClear: (Engine: Engine) => void;
  75779. /**
  75780. * Define the clear color of the Render Target if it should be different from the scene.
  75781. */
  75782. clearColor: Color4;
  75783. protected _size: number | {
  75784. width: number;
  75785. height: number;
  75786. };
  75787. protected _initialSizeParameter: number | {
  75788. width: number;
  75789. height: number;
  75790. } | {
  75791. ratio: number;
  75792. };
  75793. protected _sizeRatio: Nullable<number>;
  75794. /** @hidden */
  75795. _generateMipMaps: boolean;
  75796. protected _renderingManager: RenderingManager;
  75797. /** @hidden */
  75798. _waitingRenderList: string[];
  75799. protected _doNotChangeAspectRatio: boolean;
  75800. protected _currentRefreshId: number;
  75801. protected _refreshRate: number;
  75802. protected _textureMatrix: Matrix;
  75803. protected _samples: number;
  75804. protected _renderTargetOptions: RenderTargetCreationOptions;
  75805. /**
  75806. * Gets render target creation options that were used.
  75807. */
  75808. readonly renderTargetOptions: RenderTargetCreationOptions;
  75809. protected _engine: Engine;
  75810. protected _onRatioRescale(): void;
  75811. /**
  75812. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  75813. * It must define where the camera used to render the texture is set
  75814. */
  75815. boundingBoxPosition: Vector3;
  75816. private _boundingBoxSize;
  75817. /**
  75818. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  75819. * When defined, the cubemap will switch to local mode
  75820. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  75821. * @example https://www.babylonjs-playground.com/#RNASML
  75822. */
  75823. boundingBoxSize: Vector3;
  75824. /**
  75825. * In case the RTT has been created with a depth texture, get the associated
  75826. * depth texture.
  75827. * Otherwise, return null.
  75828. */
  75829. depthStencilTexture: Nullable<InternalTexture>;
  75830. /**
  75831. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  75832. * or used a shadow, depth texture...
  75833. * @param name The friendly name of the texture
  75834. * @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)
  75835. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  75836. * @param generateMipMaps True if mip maps need to be generated after render.
  75837. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  75838. * @param type The type of the buffer in the RTT (int, half float, float...)
  75839. * @param isCube True if a cube texture needs to be created
  75840. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  75841. * @param generateDepthBuffer True to generate a depth buffer
  75842. * @param generateStencilBuffer True to generate a stencil buffer
  75843. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  75844. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  75845. * @param delayAllocation if the texture allocation should be delayed (default: false)
  75846. */
  75847. constructor(name: string, size: number | {
  75848. width: number;
  75849. height: number;
  75850. } | {
  75851. ratio: number;
  75852. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  75853. /**
  75854. * Creates a depth stencil texture.
  75855. * This is only available in WebGL 2 or with the depth texture extension available.
  75856. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  75857. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  75858. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  75859. */
  75860. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  75861. private _processSizeParameter;
  75862. /**
  75863. * Define the number of samples to use in case of MSAA.
  75864. * It defaults to one meaning no MSAA has been enabled.
  75865. */
  75866. samples: number;
  75867. /**
  75868. * Resets the refresh counter of the texture and start bak from scratch.
  75869. * Could be useful to regenerate the texture if it is setup to render only once.
  75870. */
  75871. resetRefreshCounter(): void;
  75872. /**
  75873. * Define the refresh rate of the texture or the rendering frequency.
  75874. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  75875. */
  75876. refreshRate: number;
  75877. /**
  75878. * Adds a post process to the render target rendering passes.
  75879. * @param postProcess define the post process to add
  75880. */
  75881. addPostProcess(postProcess: PostProcess): void;
  75882. /**
  75883. * Clear all the post processes attached to the render target
  75884. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  75885. */
  75886. clearPostProcesses(dispose?: boolean): void;
  75887. /**
  75888. * Remove one of the post process from the list of attached post processes to the texture
  75889. * @param postProcess define the post process to remove from the list
  75890. */
  75891. removePostProcess(postProcess: PostProcess): void;
  75892. /** @hidden */
  75893. _shouldRender(): boolean;
  75894. /**
  75895. * Gets the actual render size of the texture.
  75896. * @returns the width of the render size
  75897. */
  75898. getRenderSize(): number;
  75899. /**
  75900. * Gets the actual render width of the texture.
  75901. * @returns the width of the render size
  75902. */
  75903. getRenderWidth(): number;
  75904. /**
  75905. * Gets the actual render height of the texture.
  75906. * @returns the height of the render size
  75907. */
  75908. getRenderHeight(): number;
  75909. /**
  75910. * Get if the texture can be rescaled or not.
  75911. */
  75912. readonly canRescale: boolean;
  75913. /**
  75914. * Resize the texture using a ratio.
  75915. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  75916. */
  75917. scale(ratio: number): void;
  75918. /**
  75919. * Get the texture reflection matrix used to rotate/transform the reflection.
  75920. * @returns the reflection matrix
  75921. */
  75922. getReflectionTextureMatrix(): Matrix;
  75923. /**
  75924. * Resize the texture to a new desired size.
  75925. * Be carrefull as it will recreate all the data in the new texture.
  75926. * @param size Define the new size. It can be:
  75927. * - a number for squared texture,
  75928. * - an object containing { width: number, height: number }
  75929. * - or an object containing a ratio { ratio: number }
  75930. */
  75931. resize(size: number | {
  75932. width: number;
  75933. height: number;
  75934. } | {
  75935. ratio: number;
  75936. }): void;
  75937. /**
  75938. * Renders all the objects from the render list into the texture.
  75939. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  75940. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  75941. */
  75942. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  75943. private _bestReflectionRenderTargetDimension;
  75944. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  75945. private renderToTarget;
  75946. /**
  75947. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  75948. * This allowed control for front to back rendering or reversly depending of the special needs.
  75949. *
  75950. * @param renderingGroupId The rendering group id corresponding to its index
  75951. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  75952. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  75953. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  75954. */
  75955. 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;
  75956. /**
  75957. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  75958. *
  75959. * @param renderingGroupId The rendering group id corresponding to its index
  75960. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  75961. */
  75962. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  75963. /**
  75964. * Clones the texture.
  75965. * @returns the cloned texture
  75966. */
  75967. clone(): RenderTargetTexture;
  75968. /**
  75969. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  75970. * @returns The JSON representation of the texture
  75971. */
  75972. serialize(): any;
  75973. /**
  75974. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  75975. */
  75976. disposeFramebufferObjects(): void;
  75977. /**
  75978. * Dispose the texture and release its associated resources.
  75979. */
  75980. dispose(): void;
  75981. /** @hidden */
  75982. _rebuild(): void;
  75983. /**
  75984. * Clear the info related to rendering groups preventing retention point in material dispose.
  75985. */
  75986. freeRenderingGroups(): void;
  75987. }
  75988. }
  75989. declare module BABYLON {
  75990. /**
  75991. * Mirror texture can be used to simulate the view from a mirror in a scene.
  75992. * It will dynamically be rendered every frame to adapt to the camera point of view.
  75993. * You can then easily use it as a reflectionTexture on a flat surface.
  75994. * In case the surface is not a plane, please consider relying on reflection probes.
  75995. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  75996. */
  75997. export class MirrorTexture extends RenderTargetTexture {
  75998. private scene;
  75999. /**
  76000. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  76001. * 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.
  76002. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76003. */
  76004. mirrorPlane: Plane;
  76005. /**
  76006. * Define the blur ratio used to blur the reflection if needed.
  76007. */
  76008. blurRatio: number;
  76009. /**
  76010. * Define the adaptive blur kernel used to blur the reflection if needed.
  76011. * This will autocompute the closest best match for the `blurKernel`
  76012. */
  76013. adaptiveBlurKernel: number;
  76014. /**
  76015. * Define the blur kernel used to blur the reflection if needed.
  76016. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76017. */
  76018. blurKernel: number;
  76019. /**
  76020. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  76021. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76022. */
  76023. blurKernelX: number;
  76024. /**
  76025. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  76026. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  76027. */
  76028. blurKernelY: number;
  76029. private _autoComputeBlurKernel;
  76030. protected _onRatioRescale(): void;
  76031. private _updateGammaSpace;
  76032. private _imageProcessingConfigChangeObserver;
  76033. private _transformMatrix;
  76034. private _mirrorMatrix;
  76035. private _savedViewMatrix;
  76036. private _blurX;
  76037. private _blurY;
  76038. private _adaptiveBlurKernel;
  76039. private _blurKernelX;
  76040. private _blurKernelY;
  76041. private _blurRatio;
  76042. /**
  76043. * Instantiates a Mirror Texture.
  76044. * Mirror texture can be used to simulate the view from a mirror in a scene.
  76045. * It will dynamically be rendered every frame to adapt to the camera point of view.
  76046. * You can then easily use it as a reflectionTexture on a flat surface.
  76047. * In case the surface is not a plane, please consider relying on reflection probes.
  76048. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  76049. * @param name
  76050. * @param size
  76051. * @param scene
  76052. * @param generateMipMaps
  76053. * @param type
  76054. * @param samplingMode
  76055. * @param generateDepthBuffer
  76056. */
  76057. constructor(name: string, size: number | {
  76058. width: number;
  76059. height: number;
  76060. } | {
  76061. ratio: number;
  76062. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  76063. private _preparePostProcesses;
  76064. /**
  76065. * Clone the mirror texture.
  76066. * @returns the cloned texture
  76067. */
  76068. clone(): MirrorTexture;
  76069. /**
  76070. * Serialize the texture to a JSON representation you could use in Parse later on
  76071. * @returns the serialized JSON representation
  76072. */
  76073. serialize(): any;
  76074. /**
  76075. * Dispose the texture and release its associated resources.
  76076. */
  76077. dispose(): void;
  76078. }
  76079. }
  76080. declare module BABYLON {
  76081. /**
  76082. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  76083. * @see http://doc.babylonjs.com/babylon101/materials#texture
  76084. */
  76085. export class Texture extends BaseTexture {
  76086. /** @hidden */
  76087. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  76088. /** @hidden */
  76089. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  76090. /** @hidden */
  76091. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  76092. /** nearest is mag = nearest and min = nearest and mip = linear */
  76093. static readonly NEAREST_SAMPLINGMODE: number;
  76094. /** nearest is mag = nearest and min = nearest and mip = linear */
  76095. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  76096. /** Bilinear is mag = linear and min = linear and mip = nearest */
  76097. static readonly BILINEAR_SAMPLINGMODE: number;
  76098. /** Bilinear is mag = linear and min = linear and mip = nearest */
  76099. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  76100. /** Trilinear is mag = linear and min = linear and mip = linear */
  76101. static readonly TRILINEAR_SAMPLINGMODE: number;
  76102. /** Trilinear is mag = linear and min = linear and mip = linear */
  76103. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  76104. /** mag = nearest and min = nearest and mip = nearest */
  76105. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  76106. /** mag = nearest and min = linear and mip = nearest */
  76107. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  76108. /** mag = nearest and min = linear and mip = linear */
  76109. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  76110. /** mag = nearest and min = linear and mip = none */
  76111. static readonly NEAREST_LINEAR: number;
  76112. /** mag = nearest and min = nearest and mip = none */
  76113. static readonly NEAREST_NEAREST: number;
  76114. /** mag = linear and min = nearest and mip = nearest */
  76115. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  76116. /** mag = linear and min = nearest and mip = linear */
  76117. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  76118. /** mag = linear and min = linear and mip = none */
  76119. static readonly LINEAR_LINEAR: number;
  76120. /** mag = linear and min = nearest and mip = none */
  76121. static readonly LINEAR_NEAREST: number;
  76122. /** Explicit coordinates mode */
  76123. static readonly EXPLICIT_MODE: number;
  76124. /** Spherical coordinates mode */
  76125. static readonly SPHERICAL_MODE: number;
  76126. /** Planar coordinates mode */
  76127. static readonly PLANAR_MODE: number;
  76128. /** Cubic coordinates mode */
  76129. static readonly CUBIC_MODE: number;
  76130. /** Projection coordinates mode */
  76131. static readonly PROJECTION_MODE: number;
  76132. /** Inverse Cubic coordinates mode */
  76133. static readonly SKYBOX_MODE: number;
  76134. /** Inverse Cubic coordinates mode */
  76135. static readonly INVCUBIC_MODE: number;
  76136. /** Equirectangular coordinates mode */
  76137. static readonly EQUIRECTANGULAR_MODE: number;
  76138. /** Equirectangular Fixed coordinates mode */
  76139. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  76140. /** Equirectangular Fixed Mirrored coordinates mode */
  76141. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  76142. /** Texture is not repeating outside of 0..1 UVs */
  76143. static readonly CLAMP_ADDRESSMODE: number;
  76144. /** Texture is repeating outside of 0..1 UVs */
  76145. static readonly WRAP_ADDRESSMODE: number;
  76146. /** Texture is repeating and mirrored */
  76147. static readonly MIRROR_ADDRESSMODE: number;
  76148. /**
  76149. * 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
  76150. */
  76151. static UseSerializedUrlIfAny: boolean;
  76152. /**
  76153. * Define the url of the texture.
  76154. */
  76155. url: Nullable<string>;
  76156. /**
  76157. * Define an offset on the texture to offset the u coordinates of the UVs
  76158. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  76159. */
  76160. uOffset: number;
  76161. /**
  76162. * Define an offset on the texture to offset the v coordinates of the UVs
  76163. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  76164. */
  76165. vOffset: number;
  76166. /**
  76167. * Define an offset on the texture to scale the u coordinates of the UVs
  76168. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  76169. */
  76170. uScale: number;
  76171. /**
  76172. * Define an offset on the texture to scale the v coordinates of the UVs
  76173. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  76174. */
  76175. vScale: number;
  76176. /**
  76177. * Define an offset on the texture to rotate around the u coordinates of the UVs
  76178. * @see http://doc.babylonjs.com/how_to/more_materials
  76179. */
  76180. uAng: number;
  76181. /**
  76182. * Define an offset on the texture to rotate around the v coordinates of the UVs
  76183. * @see http://doc.babylonjs.com/how_to/more_materials
  76184. */
  76185. vAng: number;
  76186. /**
  76187. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  76188. * @see http://doc.babylonjs.com/how_to/more_materials
  76189. */
  76190. wAng: number;
  76191. /**
  76192. * Defines the center of rotation (U)
  76193. */
  76194. uRotationCenter: number;
  76195. /**
  76196. * Defines the center of rotation (V)
  76197. */
  76198. vRotationCenter: number;
  76199. /**
  76200. * Defines the center of rotation (W)
  76201. */
  76202. wRotationCenter: number;
  76203. /**
  76204. * Are mip maps generated for this texture or not.
  76205. */
  76206. readonly noMipmap: boolean;
  76207. /**
  76208. * List of inspectable custom properties (used by the Inspector)
  76209. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  76210. */
  76211. inspectableCustomProperties: IInspectable[];
  76212. private _noMipmap;
  76213. /** @hidden */
  76214. _invertY: boolean;
  76215. private _rowGenerationMatrix;
  76216. private _cachedTextureMatrix;
  76217. private _projectionModeMatrix;
  76218. private _t0;
  76219. private _t1;
  76220. private _t2;
  76221. private _cachedUOffset;
  76222. private _cachedVOffset;
  76223. private _cachedUScale;
  76224. private _cachedVScale;
  76225. private _cachedUAng;
  76226. private _cachedVAng;
  76227. private _cachedWAng;
  76228. private _cachedProjectionMatrixId;
  76229. private _cachedCoordinatesMode;
  76230. /** @hidden */
  76231. protected _initialSamplingMode: number;
  76232. /** @hidden */
  76233. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  76234. private _deleteBuffer;
  76235. protected _format: Nullable<number>;
  76236. private _delayedOnLoad;
  76237. private _delayedOnError;
  76238. /**
  76239. * Observable triggered once the texture has been loaded.
  76240. */
  76241. onLoadObservable: Observable<Texture>;
  76242. protected _isBlocking: boolean;
  76243. /**
  76244. * Is the texture preventing material to render while loading.
  76245. * If false, a default texture will be used instead of the loading one during the preparation step.
  76246. */
  76247. isBlocking: boolean;
  76248. /**
  76249. * Get the current sampling mode associated with the texture.
  76250. */
  76251. readonly samplingMode: number;
  76252. /**
  76253. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  76254. */
  76255. readonly invertY: boolean;
  76256. /**
  76257. * Instantiates a new texture.
  76258. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  76259. * @see http://doc.babylonjs.com/babylon101/materials#texture
  76260. * @param url define the url of the picture to load as a texture
  76261. * @param scene define the scene the texture will belong to
  76262. * @param noMipmap define if the texture will require mip maps or not
  76263. * @param invertY define if the texture needs to be inverted on the y axis during loading
  76264. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  76265. * @param onLoad define a callback triggered when the texture has been loaded
  76266. * @param onError define a callback triggered when an error occurred during the loading session
  76267. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  76268. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  76269. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  76270. */
  76271. 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);
  76272. /**
  76273. * Update the url (and optional buffer) of this texture if url was null during construction.
  76274. * @param url the url of the texture
  76275. * @param buffer the buffer of the texture (defaults to null)
  76276. * @param onLoad callback called when the texture is loaded (defaults to null)
  76277. */
  76278. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  76279. /**
  76280. * Finish the loading sequence of a texture flagged as delayed load.
  76281. * @hidden
  76282. */
  76283. delayLoad(): void;
  76284. private _prepareRowForTextureGeneration;
  76285. /**
  76286. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  76287. * @returns the transform matrix of the texture.
  76288. */
  76289. getTextureMatrix(): Matrix;
  76290. /**
  76291. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  76292. * @returns The reflection texture transform
  76293. */
  76294. getReflectionTextureMatrix(): Matrix;
  76295. /**
  76296. * Clones the texture.
  76297. * @returns the cloned texture
  76298. */
  76299. clone(): Texture;
  76300. /**
  76301. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  76302. * @returns The JSON representation of the texture
  76303. */
  76304. serialize(): any;
  76305. /**
  76306. * Get the current class name of the texture useful for serialization or dynamic coding.
  76307. * @returns "Texture"
  76308. */
  76309. getClassName(): string;
  76310. /**
  76311. * Dispose the texture and release its associated resources.
  76312. */
  76313. dispose(): void;
  76314. /**
  76315. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  76316. * @param parsedTexture Define the JSON representation of the texture
  76317. * @param scene Define the scene the parsed texture should be instantiated in
  76318. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  76319. * @returns The parsed texture if successful
  76320. */
  76321. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  76322. /**
  76323. * Creates a texture from its base 64 representation.
  76324. * @param data Define the base64 payload without the data: prefix
  76325. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  76326. * @param scene Define the scene the texture should belong to
  76327. * @param noMipmap Forces the texture to not create mip map information if true
  76328. * @param invertY define if the texture needs to be inverted on the y axis during loading
  76329. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  76330. * @param onLoad define a callback triggered when the texture has been loaded
  76331. * @param onError define a callback triggered when an error occurred during the loading session
  76332. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  76333. * @returns the created texture
  76334. */
  76335. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  76336. /**
  76337. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  76338. * @param data Define the base64 payload without the data: prefix
  76339. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  76340. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  76341. * @param scene Define the scene the texture should belong to
  76342. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  76343. * @param noMipmap Forces the texture to not create mip map information if true
  76344. * @param invertY define if the texture needs to be inverted on the y axis during loading
  76345. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  76346. * @param onLoad define a callback triggered when the texture has been loaded
  76347. * @param onError define a callback triggered when an error occurred during the loading session
  76348. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  76349. * @returns the created texture
  76350. */
  76351. 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;
  76352. }
  76353. }
  76354. declare module BABYLON {
  76355. /**
  76356. * Raw texture can help creating a texture directly from an array of data.
  76357. * This can be super useful if you either get the data from an uncompressed source or
  76358. * if you wish to create your texture pixel by pixel.
  76359. */
  76360. export class RawTexture extends Texture {
  76361. /**
  76362. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76363. */
  76364. format: number;
  76365. private _engine;
  76366. /**
  76367. * Instantiates a new RawTexture.
  76368. * Raw texture can help creating a texture directly from an array of data.
  76369. * This can be super useful if you either get the data from an uncompressed source or
  76370. * if you wish to create your texture pixel by pixel.
  76371. * @param data define the array of data to use to create the texture
  76372. * @param width define the width of the texture
  76373. * @param height define the height of the texture
  76374. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76375. * @param scene define the scene the texture belongs to
  76376. * @param generateMipMaps define whether mip maps should be generated or not
  76377. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76378. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76379. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76380. */
  76381. constructor(data: ArrayBufferView, width: number, height: number,
  76382. /**
  76383. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76384. */
  76385. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  76386. /**
  76387. * Updates the texture underlying data.
  76388. * @param data Define the new data of the texture
  76389. */
  76390. update(data: ArrayBufferView): void;
  76391. /**
  76392. * Creates a luminance texture from some data.
  76393. * @param data Define the texture data
  76394. * @param width Define the width of the texture
  76395. * @param height Define the height of the texture
  76396. * @param scene Define the scene the texture belongs to
  76397. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76398. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76399. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76400. * @returns the luminance texture
  76401. */
  76402. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76403. /**
  76404. * Creates a luminance alpha texture from some data.
  76405. * @param data Define the texture data
  76406. * @param width Define the width of the texture
  76407. * @param height Define the height of the texture
  76408. * @param scene Define the scene the texture belongs to
  76409. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76410. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76411. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76412. * @returns the luminance alpha texture
  76413. */
  76414. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76415. /**
  76416. * Creates an alpha texture from some data.
  76417. * @param data Define the texture data
  76418. * @param width Define the width of the texture
  76419. * @param height Define the height of the texture
  76420. * @param scene Define the scene the texture belongs to
  76421. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76422. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76423. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76424. * @returns the alpha texture
  76425. */
  76426. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76427. /**
  76428. * Creates a RGB texture from some data.
  76429. * @param data Define the texture data
  76430. * @param width Define the width of the texture
  76431. * @param height Define the height of the texture
  76432. * @param scene Define the scene the texture belongs to
  76433. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76434. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76435. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76436. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76437. * @returns the RGB alpha texture
  76438. */
  76439. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76440. /**
  76441. * Creates a RGBA texture from some data.
  76442. * @param data Define the texture data
  76443. * @param width Define the width of the texture
  76444. * @param height Define the height of the texture
  76445. * @param scene Define the scene the texture belongs to
  76446. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76447. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76448. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76449. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76450. * @returns the RGBA texture
  76451. */
  76452. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76453. /**
  76454. * Creates a R texture from some data.
  76455. * @param data Define the texture data
  76456. * @param width Define the width of the texture
  76457. * @param height Define the height of the texture
  76458. * @param scene Define the scene the texture belongs to
  76459. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76460. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76461. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76462. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76463. * @returns the R texture
  76464. */
  76465. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76466. }
  76467. }
  76468. declare module BABYLON {
  76469. /**
  76470. * Defines a runtime animation
  76471. */
  76472. export class RuntimeAnimation {
  76473. private _events;
  76474. /**
  76475. * The current frame of the runtime animation
  76476. */
  76477. private _currentFrame;
  76478. /**
  76479. * The animation used by the runtime animation
  76480. */
  76481. private _animation;
  76482. /**
  76483. * The target of the runtime animation
  76484. */
  76485. private _target;
  76486. /**
  76487. * The initiating animatable
  76488. */
  76489. private _host;
  76490. /**
  76491. * The original value of the runtime animation
  76492. */
  76493. private _originalValue;
  76494. /**
  76495. * The original blend value of the runtime animation
  76496. */
  76497. private _originalBlendValue;
  76498. /**
  76499. * The offsets cache of the runtime animation
  76500. */
  76501. private _offsetsCache;
  76502. /**
  76503. * The high limits cache of the runtime animation
  76504. */
  76505. private _highLimitsCache;
  76506. /**
  76507. * Specifies if the runtime animation has been stopped
  76508. */
  76509. private _stopped;
  76510. /**
  76511. * The blending factor of the runtime animation
  76512. */
  76513. private _blendingFactor;
  76514. /**
  76515. * The BabylonJS scene
  76516. */
  76517. private _scene;
  76518. /**
  76519. * The current value of the runtime animation
  76520. */
  76521. private _currentValue;
  76522. /** @hidden */
  76523. _workValue: any;
  76524. /**
  76525. * The active target of the runtime animation
  76526. */
  76527. private _activeTarget;
  76528. /**
  76529. * The target path of the runtime animation
  76530. */
  76531. private _targetPath;
  76532. /**
  76533. * The weight of the runtime animation
  76534. */
  76535. private _weight;
  76536. /**
  76537. * The ratio offset of the runtime animation
  76538. */
  76539. private _ratioOffset;
  76540. /**
  76541. * The previous delay of the runtime animation
  76542. */
  76543. private _previousDelay;
  76544. /**
  76545. * The previous ratio of the runtime animation
  76546. */
  76547. private _previousRatio;
  76548. /**
  76549. * Gets the current frame of the runtime animation
  76550. */
  76551. readonly currentFrame: number;
  76552. /**
  76553. * Gets the weight of the runtime animation
  76554. */
  76555. readonly weight: number;
  76556. /**
  76557. * Gets the current value of the runtime animation
  76558. */
  76559. readonly currentValue: any;
  76560. /**
  76561. * Gets the target path of the runtime animation
  76562. */
  76563. readonly targetPath: string;
  76564. /**
  76565. * Gets the actual target of the runtime animation
  76566. */
  76567. readonly target: any;
  76568. /**
  76569. * Create a new RuntimeAnimation object
  76570. * @param target defines the target of the animation
  76571. * @param animation defines the source animation object
  76572. * @param scene defines the hosting scene
  76573. * @param host defines the initiating Animatable
  76574. */
  76575. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  76576. /**
  76577. * Gets the animation from the runtime animation
  76578. */
  76579. readonly animation: Animation;
  76580. /**
  76581. * Resets the runtime animation to the beginning
  76582. * @param restoreOriginal defines whether to restore the target property to the original value
  76583. */
  76584. reset(restoreOriginal?: boolean): void;
  76585. /**
  76586. * Specifies if the runtime animation is stopped
  76587. * @returns Boolean specifying if the runtime animation is stopped
  76588. */
  76589. isStopped(): boolean;
  76590. /**
  76591. * Disposes of the runtime animation
  76592. */
  76593. dispose(): void;
  76594. /**
  76595. * Interpolates the animation from the current frame
  76596. * @param currentFrame The frame to interpolate the animation to
  76597. * @param repeatCount The number of times that the animation should loop
  76598. * @param loopMode The type of looping mode to use
  76599. * @param offsetValue Animation offset value
  76600. * @param highLimitValue The high limit value
  76601. * @returns The interpolated value
  76602. */
  76603. private _interpolate;
  76604. /**
  76605. * Apply the interpolated value to the target
  76606. * @param currentValue defines the value computed by the animation
  76607. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  76608. */
  76609. setValue(currentValue: any, weight?: number): void;
  76610. private _setValue;
  76611. /**
  76612. * Gets the loop pmode of the runtime animation
  76613. * @returns Loop Mode
  76614. */
  76615. private _getCorrectLoopMode;
  76616. /**
  76617. * Move the current animation to a given frame
  76618. * @param frame defines the frame to move to
  76619. */
  76620. goToFrame(frame: number): void;
  76621. /**
  76622. * @hidden Internal use only
  76623. */
  76624. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  76625. /**
  76626. * Execute the current animation
  76627. * @param delay defines the delay to add to the current frame
  76628. * @param from defines the lower bound of the animation range
  76629. * @param to defines the upper bound of the animation range
  76630. * @param loop defines if the current animation must loop
  76631. * @param speedRatio defines the current speed ratio
  76632. * @param weight defines the weight of the animation (default is -1 so no weight)
  76633. * @param onLoop optional callback called when animation loops
  76634. * @returns a boolean indicating if the animation is running
  76635. */
  76636. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  76637. }
  76638. }
  76639. declare module BABYLON {
  76640. /**
  76641. * Class used to store an actual running animation
  76642. */
  76643. export class Animatable {
  76644. /** defines the target object */
  76645. target: any;
  76646. /** defines the starting frame number (default is 0) */
  76647. fromFrame: number;
  76648. /** defines the ending frame number (default is 100) */
  76649. toFrame: number;
  76650. /** defines if the animation must loop (default is false) */
  76651. loopAnimation: boolean;
  76652. /** defines a callback to call when animation ends if it is not looping */
  76653. onAnimationEnd?: (() => void) | null | undefined;
  76654. /** defines a callback to call when animation loops */
  76655. onAnimationLoop?: (() => void) | null | undefined;
  76656. private _localDelayOffset;
  76657. private _pausedDelay;
  76658. private _runtimeAnimations;
  76659. private _paused;
  76660. private _scene;
  76661. private _speedRatio;
  76662. private _weight;
  76663. private _syncRoot;
  76664. /**
  76665. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  76666. * This will only apply for non looping animation (default is true)
  76667. */
  76668. disposeOnEnd: boolean;
  76669. /**
  76670. * Gets a boolean indicating if the animation has started
  76671. */
  76672. animationStarted: boolean;
  76673. /**
  76674. * Observer raised when the animation ends
  76675. */
  76676. onAnimationEndObservable: Observable<Animatable>;
  76677. /**
  76678. * Observer raised when the animation loops
  76679. */
  76680. onAnimationLoopObservable: Observable<Animatable>;
  76681. /**
  76682. * Gets the root Animatable used to synchronize and normalize animations
  76683. */
  76684. readonly syncRoot: Animatable;
  76685. /**
  76686. * Gets the current frame of the first RuntimeAnimation
  76687. * Used to synchronize Animatables
  76688. */
  76689. readonly masterFrame: number;
  76690. /**
  76691. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  76692. */
  76693. weight: number;
  76694. /**
  76695. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  76696. */
  76697. speedRatio: number;
  76698. /**
  76699. * Creates a new Animatable
  76700. * @param scene defines the hosting scene
  76701. * @param target defines the target object
  76702. * @param fromFrame defines the starting frame number (default is 0)
  76703. * @param toFrame defines the ending frame number (default is 100)
  76704. * @param loopAnimation defines if the animation must loop (default is false)
  76705. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  76706. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  76707. * @param animations defines a group of animation to add to the new Animatable
  76708. * @param onAnimationLoop defines a callback to call when animation loops
  76709. */
  76710. constructor(scene: Scene,
  76711. /** defines the target object */
  76712. target: any,
  76713. /** defines the starting frame number (default is 0) */
  76714. fromFrame?: number,
  76715. /** defines the ending frame number (default is 100) */
  76716. toFrame?: number,
  76717. /** defines if the animation must loop (default is false) */
  76718. loopAnimation?: boolean, speedRatio?: number,
  76719. /** defines a callback to call when animation ends if it is not looping */
  76720. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  76721. /** defines a callback to call when animation loops */
  76722. onAnimationLoop?: (() => void) | null | undefined);
  76723. /**
  76724. * Synchronize and normalize current Animatable with a source Animatable
  76725. * This is useful when using animation weights and when animations are not of the same length
  76726. * @param root defines the root Animatable to synchronize with
  76727. * @returns the current Animatable
  76728. */
  76729. syncWith(root: Animatable): Animatable;
  76730. /**
  76731. * Gets the list of runtime animations
  76732. * @returns an array of RuntimeAnimation
  76733. */
  76734. getAnimations(): RuntimeAnimation[];
  76735. /**
  76736. * Adds more animations to the current animatable
  76737. * @param target defines the target of the animations
  76738. * @param animations defines the new animations to add
  76739. */
  76740. appendAnimations(target: any, animations: Animation[]): void;
  76741. /**
  76742. * Gets the source animation for a specific property
  76743. * @param property defines the propertyu to look for
  76744. * @returns null or the source animation for the given property
  76745. */
  76746. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  76747. /**
  76748. * Gets the runtime animation for a specific property
  76749. * @param property defines the propertyu to look for
  76750. * @returns null or the runtime animation for the given property
  76751. */
  76752. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  76753. /**
  76754. * Resets the animatable to its original state
  76755. */
  76756. reset(): void;
  76757. /**
  76758. * Allows the animatable to blend with current running animations
  76759. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76760. * @param blendingSpeed defines the blending speed to use
  76761. */
  76762. enableBlending(blendingSpeed: number): void;
  76763. /**
  76764. * Disable animation blending
  76765. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76766. */
  76767. disableBlending(): void;
  76768. /**
  76769. * Jump directly to a given frame
  76770. * @param frame defines the frame to jump to
  76771. */
  76772. goToFrame(frame: number): void;
  76773. /**
  76774. * Pause the animation
  76775. */
  76776. pause(): void;
  76777. /**
  76778. * Restart the animation
  76779. */
  76780. restart(): void;
  76781. private _raiseOnAnimationEnd;
  76782. /**
  76783. * Stop and delete the current animation
  76784. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  76785. * @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)
  76786. */
  76787. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  76788. /**
  76789. * Wait asynchronously for the animation to end
  76790. * @returns a promise which will be fullfilled when the animation ends
  76791. */
  76792. waitAsync(): Promise<Animatable>;
  76793. /** @hidden */
  76794. _animate(delay: number): boolean;
  76795. }
  76796. interface Scene {
  76797. /** @hidden */
  76798. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  76799. /** @hidden */
  76800. _processLateAnimationBindingsForMatrices(holder: {
  76801. totalWeight: number;
  76802. animations: RuntimeAnimation[];
  76803. originalValue: Matrix;
  76804. }): any;
  76805. /** @hidden */
  76806. _processLateAnimationBindingsForQuaternions(holder: {
  76807. totalWeight: number;
  76808. animations: RuntimeAnimation[];
  76809. originalValue: Quaternion;
  76810. }, refQuaternion: Quaternion): Quaternion;
  76811. /** @hidden */
  76812. _processLateAnimationBindings(): void;
  76813. /**
  76814. * Will start the animation sequence of a given target
  76815. * @param target defines the target
  76816. * @param from defines from which frame should animation start
  76817. * @param to defines until which frame should animation run.
  76818. * @param weight defines the weight to apply to the animation (1.0 by default)
  76819. * @param loop defines if the animation loops
  76820. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76821. * @param onAnimationEnd defines the function to be executed when the animation ends
  76822. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76823. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76824. * @param onAnimationLoop defines the callback to call when an animation loops
  76825. * @returns the animatable object created for this animation
  76826. */
  76827. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76828. /**
  76829. * Will start the animation sequence of a given target
  76830. * @param target defines the target
  76831. * @param from defines from which frame should animation start
  76832. * @param to defines until which frame should animation run.
  76833. * @param loop defines if the animation loops
  76834. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76835. * @param onAnimationEnd defines the function to be executed when the animation ends
  76836. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76837. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76838. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  76839. * @param onAnimationLoop defines the callback to call when an animation loops
  76840. * @returns the animatable object created for this animation
  76841. */
  76842. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76843. /**
  76844. * Will start the animation sequence of a given target and its hierarchy
  76845. * @param target defines the target
  76846. * @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.
  76847. * @param from defines from which frame should animation start
  76848. * @param to defines until which frame should animation run.
  76849. * @param loop defines if the animation loops
  76850. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76851. * @param onAnimationEnd defines the function to be executed when the animation ends
  76852. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76853. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76854. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76855. * @param onAnimationLoop defines the callback to call when an animation loops
  76856. * @returns the list of created animatables
  76857. */
  76858. 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[];
  76859. /**
  76860. * Begin a new animation on a given node
  76861. * @param target defines the target where the animation will take place
  76862. * @param animations defines the list of animations to start
  76863. * @param from defines the initial value
  76864. * @param to defines the final value
  76865. * @param loop defines if you want animation to loop (off by default)
  76866. * @param speedRatio defines the speed ratio to apply to all animations
  76867. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76868. * @param onAnimationLoop defines the callback to call when an animation loops
  76869. * @returns the list of created animatables
  76870. */
  76871. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  76872. /**
  76873. * Begin a new animation on a given node and its hierarchy
  76874. * @param target defines the root node where the animation will take place
  76875. * @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.
  76876. * @param animations defines the list of animations to start
  76877. * @param from defines the initial value
  76878. * @param to defines the final value
  76879. * @param loop defines if you want animation to loop (off by default)
  76880. * @param speedRatio defines the speed ratio to apply to all animations
  76881. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76882. * @param onAnimationLoop defines the callback to call when an animation loops
  76883. * @returns the list of animatables created for all nodes
  76884. */
  76885. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  76886. /**
  76887. * Gets the animatable associated with a specific target
  76888. * @param target defines the target of the animatable
  76889. * @returns the required animatable if found
  76890. */
  76891. getAnimatableByTarget(target: any): Nullable<Animatable>;
  76892. /**
  76893. * Gets all animatables associated with a given target
  76894. * @param target defines the target to look animatables for
  76895. * @returns an array of Animatables
  76896. */
  76897. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  76898. /**
  76899. * Will stop the animation of the given target
  76900. * @param target - the target
  76901. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  76902. * @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)
  76903. */
  76904. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  76905. /**
  76906. * Stops and removes all animations that have been applied to the scene
  76907. */
  76908. stopAllAnimations(): void;
  76909. }
  76910. interface Bone {
  76911. /**
  76912. * Copy an animation range from another bone
  76913. * @param source defines the source bone
  76914. * @param rangeName defines the range name to copy
  76915. * @param frameOffset defines the frame offset
  76916. * @param rescaleAsRequired defines if rescaling must be applied if required
  76917. * @param skelDimensionsRatio defines the scaling ratio
  76918. * @returns true if operation was successful
  76919. */
  76920. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  76921. }
  76922. }
  76923. declare module BABYLON {
  76924. /**
  76925. * Class used to handle skinning animations
  76926. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  76927. */
  76928. export class Skeleton implements IAnimatable {
  76929. /** defines the skeleton name */
  76930. name: string;
  76931. /** defines the skeleton Id */
  76932. id: string;
  76933. /**
  76934. * Defines the list of child bones
  76935. */
  76936. bones: Bone[];
  76937. /**
  76938. * Defines an estimate of the dimension of the skeleton at rest
  76939. */
  76940. dimensionsAtRest: Vector3;
  76941. /**
  76942. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  76943. */
  76944. needInitialSkinMatrix: boolean;
  76945. /**
  76946. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  76947. */
  76948. overrideMesh: Nullable<AbstractMesh>;
  76949. /**
  76950. * Gets the list of animations attached to this skeleton
  76951. */
  76952. animations: Array<Animation>;
  76953. private _scene;
  76954. private _isDirty;
  76955. private _transformMatrices;
  76956. private _transformMatrixTexture;
  76957. private _meshesWithPoseMatrix;
  76958. private _animatables;
  76959. private _identity;
  76960. private _synchronizedWithMesh;
  76961. private _ranges;
  76962. private _lastAbsoluteTransformsUpdateId;
  76963. private _canUseTextureForBones;
  76964. /** @hidden */
  76965. _numBonesWithLinkedTransformNode: number;
  76966. /**
  76967. * Specifies if the skeleton should be serialized
  76968. */
  76969. doNotSerialize: boolean;
  76970. private _useTextureToStoreBoneMatrices;
  76971. /**
  76972. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  76973. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  76974. */
  76975. useTextureToStoreBoneMatrices: boolean;
  76976. private _animationPropertiesOverride;
  76977. /**
  76978. * Gets or sets the animation properties override
  76979. */
  76980. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76981. /**
  76982. * List of inspectable custom properties (used by the Inspector)
  76983. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  76984. */
  76985. inspectableCustomProperties: IInspectable[];
  76986. /**
  76987. * An observable triggered before computing the skeleton's matrices
  76988. */
  76989. onBeforeComputeObservable: Observable<Skeleton>;
  76990. /**
  76991. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  76992. */
  76993. readonly isUsingTextureForMatrices: boolean;
  76994. /**
  76995. * Creates a new skeleton
  76996. * @param name defines the skeleton name
  76997. * @param id defines the skeleton Id
  76998. * @param scene defines the hosting scene
  76999. */
  77000. constructor(
  77001. /** defines the skeleton name */
  77002. name: string,
  77003. /** defines the skeleton Id */
  77004. id: string, scene: Scene);
  77005. /**
  77006. * Gets the current object class name.
  77007. * @return the class name
  77008. */
  77009. getClassName(): string;
  77010. /**
  77011. * Returns an array containing the root bones
  77012. * @returns an array containing the root bones
  77013. */
  77014. getChildren(): Array<Bone>;
  77015. /**
  77016. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  77017. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  77018. * @returns a Float32Array containing matrices data
  77019. */
  77020. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  77021. /**
  77022. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  77023. * @returns a raw texture containing the data
  77024. */
  77025. getTransformMatrixTexture(): Nullable<RawTexture>;
  77026. /**
  77027. * Gets the current hosting scene
  77028. * @returns a scene object
  77029. */
  77030. getScene(): Scene;
  77031. /**
  77032. * Gets a string representing the current skeleton data
  77033. * @param fullDetails defines a boolean indicating if we want a verbose version
  77034. * @returns a string representing the current skeleton data
  77035. */
  77036. toString(fullDetails?: boolean): string;
  77037. /**
  77038. * Get bone's index searching by name
  77039. * @param name defines bone's name to search for
  77040. * @return the indice of the bone. Returns -1 if not found
  77041. */
  77042. getBoneIndexByName(name: string): number;
  77043. /**
  77044. * Creater a new animation range
  77045. * @param name defines the name of the range
  77046. * @param from defines the start key
  77047. * @param to defines the end key
  77048. */
  77049. createAnimationRange(name: string, from: number, to: number): void;
  77050. /**
  77051. * Delete a specific animation range
  77052. * @param name defines the name of the range
  77053. * @param deleteFrames defines if frames must be removed as well
  77054. */
  77055. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  77056. /**
  77057. * Gets a specific animation range
  77058. * @param name defines the name of the range to look for
  77059. * @returns the requested animation range or null if not found
  77060. */
  77061. getAnimationRange(name: string): Nullable<AnimationRange>;
  77062. /**
  77063. * Gets the list of all animation ranges defined on this skeleton
  77064. * @returns an array
  77065. */
  77066. getAnimationRanges(): Nullable<AnimationRange>[];
  77067. /**
  77068. * Copy animation range from a source skeleton.
  77069. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  77070. * @param source defines the source skeleton
  77071. * @param name defines the name of the range to copy
  77072. * @param rescaleAsRequired defines if rescaling must be applied if required
  77073. * @returns true if operation was successful
  77074. */
  77075. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  77076. /**
  77077. * Forces the skeleton to go to rest pose
  77078. */
  77079. returnToRest(): void;
  77080. private _getHighestAnimationFrame;
  77081. /**
  77082. * Begin a specific animation range
  77083. * @param name defines the name of the range to start
  77084. * @param loop defines if looping must be turned on (false by default)
  77085. * @param speedRatio defines the speed ratio to apply (1 by default)
  77086. * @param onAnimationEnd defines a callback which will be called when animation will end
  77087. * @returns a new animatable
  77088. */
  77089. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  77090. /** @hidden */
  77091. _markAsDirty(): void;
  77092. /** @hidden */
  77093. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77094. /** @hidden */
  77095. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  77096. private _computeTransformMatrices;
  77097. /**
  77098. * Build all resources required to render a skeleton
  77099. */
  77100. prepare(): void;
  77101. /**
  77102. * Gets the list of animatables currently running for this skeleton
  77103. * @returns an array of animatables
  77104. */
  77105. getAnimatables(): IAnimatable[];
  77106. /**
  77107. * Clone the current skeleton
  77108. * @param name defines the name of the new skeleton
  77109. * @param id defines the id of the enw skeleton
  77110. * @returns the new skeleton
  77111. */
  77112. clone(name: string, id: string): Skeleton;
  77113. /**
  77114. * Enable animation blending for this skeleton
  77115. * @param blendingSpeed defines the blending speed to apply
  77116. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77117. */
  77118. enableBlending(blendingSpeed?: number): void;
  77119. /**
  77120. * Releases all resources associated with the current skeleton
  77121. */
  77122. dispose(): void;
  77123. /**
  77124. * Serialize the skeleton in a JSON object
  77125. * @returns a JSON object
  77126. */
  77127. serialize(): any;
  77128. /**
  77129. * Creates a new skeleton from serialized data
  77130. * @param parsedSkeleton defines the serialized data
  77131. * @param scene defines the hosting scene
  77132. * @returns a new skeleton
  77133. */
  77134. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  77135. /**
  77136. * Compute all node absolute transforms
  77137. * @param forceUpdate defines if computation must be done even if cache is up to date
  77138. */
  77139. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  77140. /**
  77141. * Gets the root pose matrix
  77142. * @returns a matrix
  77143. */
  77144. getPoseMatrix(): Nullable<Matrix>;
  77145. /**
  77146. * Sorts bones per internal index
  77147. */
  77148. sortBones(): void;
  77149. private _sortBones;
  77150. }
  77151. }
  77152. declare module BABYLON {
  77153. /**
  77154. * Defines a target to use with MorphTargetManager
  77155. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77156. */
  77157. export class MorphTarget implements IAnimatable {
  77158. /** defines the name of the target */
  77159. name: string;
  77160. /**
  77161. * Gets or sets the list of animations
  77162. */
  77163. animations: Animation[];
  77164. private _scene;
  77165. private _positions;
  77166. private _normals;
  77167. private _tangents;
  77168. private _influence;
  77169. /**
  77170. * Observable raised when the influence changes
  77171. */
  77172. onInfluenceChanged: Observable<boolean>;
  77173. /** @hidden */
  77174. _onDataLayoutChanged: Observable<void>;
  77175. /**
  77176. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  77177. */
  77178. influence: number;
  77179. /**
  77180. * Gets or sets the id of the morph Target
  77181. */
  77182. id: string;
  77183. private _animationPropertiesOverride;
  77184. /**
  77185. * Gets or sets the animation properties override
  77186. */
  77187. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77188. /**
  77189. * Creates a new MorphTarget
  77190. * @param name defines the name of the target
  77191. * @param influence defines the influence to use
  77192. * @param scene defines the scene the morphtarget belongs to
  77193. */
  77194. constructor(
  77195. /** defines the name of the target */
  77196. name: string, influence?: number, scene?: Nullable<Scene>);
  77197. /**
  77198. * Gets a boolean defining if the target contains position data
  77199. */
  77200. readonly hasPositions: boolean;
  77201. /**
  77202. * Gets a boolean defining if the target contains normal data
  77203. */
  77204. readonly hasNormals: boolean;
  77205. /**
  77206. * Gets a boolean defining if the target contains tangent data
  77207. */
  77208. readonly hasTangents: boolean;
  77209. /**
  77210. * Affects position data to this target
  77211. * @param data defines the position data to use
  77212. */
  77213. setPositions(data: Nullable<FloatArray>): void;
  77214. /**
  77215. * Gets the position data stored in this target
  77216. * @returns a FloatArray containing the position data (or null if not present)
  77217. */
  77218. getPositions(): Nullable<FloatArray>;
  77219. /**
  77220. * Affects normal data to this target
  77221. * @param data defines the normal data to use
  77222. */
  77223. setNormals(data: Nullable<FloatArray>): void;
  77224. /**
  77225. * Gets the normal data stored in this target
  77226. * @returns a FloatArray containing the normal data (or null if not present)
  77227. */
  77228. getNormals(): Nullable<FloatArray>;
  77229. /**
  77230. * Affects tangent data to this target
  77231. * @param data defines the tangent data to use
  77232. */
  77233. setTangents(data: Nullable<FloatArray>): void;
  77234. /**
  77235. * Gets the tangent data stored in this target
  77236. * @returns a FloatArray containing the tangent data (or null if not present)
  77237. */
  77238. getTangents(): Nullable<FloatArray>;
  77239. /**
  77240. * Serializes the current target into a Serialization object
  77241. * @returns the serialized object
  77242. */
  77243. serialize(): any;
  77244. /**
  77245. * Returns the string "MorphTarget"
  77246. * @returns "MorphTarget"
  77247. */
  77248. getClassName(): string;
  77249. /**
  77250. * Creates a new target from serialized data
  77251. * @param serializationObject defines the serialized data to use
  77252. * @returns a new MorphTarget
  77253. */
  77254. static Parse(serializationObject: any): MorphTarget;
  77255. /**
  77256. * Creates a MorphTarget from mesh data
  77257. * @param mesh defines the source mesh
  77258. * @param name defines the name to use for the new target
  77259. * @param influence defines the influence to attach to the target
  77260. * @returns a new MorphTarget
  77261. */
  77262. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  77263. }
  77264. }
  77265. declare module BABYLON {
  77266. /**
  77267. * This class is used to deform meshes using morphing between different targets
  77268. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  77269. */
  77270. export class MorphTargetManager {
  77271. private _targets;
  77272. private _targetInfluenceChangedObservers;
  77273. private _targetDataLayoutChangedObservers;
  77274. private _activeTargets;
  77275. private _scene;
  77276. private _influences;
  77277. private _supportsNormals;
  77278. private _supportsTangents;
  77279. private _vertexCount;
  77280. private _uniqueId;
  77281. private _tempInfluences;
  77282. /**
  77283. * Creates a new MorphTargetManager
  77284. * @param scene defines the current scene
  77285. */
  77286. constructor(scene?: Nullable<Scene>);
  77287. /**
  77288. * Gets the unique ID of this manager
  77289. */
  77290. readonly uniqueId: number;
  77291. /**
  77292. * Gets the number of vertices handled by this manager
  77293. */
  77294. readonly vertexCount: number;
  77295. /**
  77296. * Gets a boolean indicating if this manager supports morphing of normals
  77297. */
  77298. readonly supportsNormals: boolean;
  77299. /**
  77300. * Gets a boolean indicating if this manager supports morphing of tangents
  77301. */
  77302. readonly supportsTangents: boolean;
  77303. /**
  77304. * Gets the number of targets stored in this manager
  77305. */
  77306. readonly numTargets: number;
  77307. /**
  77308. * Gets the number of influencers (ie. the number of targets with influences > 0)
  77309. */
  77310. readonly numInfluencers: number;
  77311. /**
  77312. * Gets the list of influences (one per target)
  77313. */
  77314. readonly influences: Float32Array;
  77315. /**
  77316. * Gets the active target at specified index. An active target is a target with an influence > 0
  77317. * @param index defines the index to check
  77318. * @returns the requested target
  77319. */
  77320. getActiveTarget(index: number): MorphTarget;
  77321. /**
  77322. * Gets the target at specified index
  77323. * @param index defines the index to check
  77324. * @returns the requested target
  77325. */
  77326. getTarget(index: number): MorphTarget;
  77327. /**
  77328. * Add a new target to this manager
  77329. * @param target defines the target to add
  77330. */
  77331. addTarget(target: MorphTarget): void;
  77332. /**
  77333. * Removes a target from the manager
  77334. * @param target defines the target to remove
  77335. */
  77336. removeTarget(target: MorphTarget): void;
  77337. /**
  77338. * Serializes the current manager into a Serialization object
  77339. * @returns the serialized object
  77340. */
  77341. serialize(): any;
  77342. private _syncActiveTargets;
  77343. /**
  77344. * Syncrhonize the targets with all the meshes using this morph target manager
  77345. */
  77346. synchronize(): void;
  77347. /**
  77348. * Creates a new MorphTargetManager from serialized data
  77349. * @param serializationObject defines the serialized data
  77350. * @param scene defines the hosting scene
  77351. * @returns the new MorphTargetManager
  77352. */
  77353. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  77354. }
  77355. }
  77356. declare module BABYLON {
  77357. /**
  77358. * Mesh representing the gorund
  77359. */
  77360. export class GroundMesh extends Mesh {
  77361. /** If octree should be generated */
  77362. generateOctree: boolean;
  77363. private _heightQuads;
  77364. /** @hidden */
  77365. _subdivisionsX: number;
  77366. /** @hidden */
  77367. _subdivisionsY: number;
  77368. /** @hidden */
  77369. _width: number;
  77370. /** @hidden */
  77371. _height: number;
  77372. /** @hidden */
  77373. _minX: number;
  77374. /** @hidden */
  77375. _maxX: number;
  77376. /** @hidden */
  77377. _minZ: number;
  77378. /** @hidden */
  77379. _maxZ: number;
  77380. constructor(name: string, scene: Scene);
  77381. /**
  77382. * "GroundMesh"
  77383. * @returns "GroundMesh"
  77384. */
  77385. getClassName(): string;
  77386. /**
  77387. * The minimum of x and y subdivisions
  77388. */
  77389. readonly subdivisions: number;
  77390. /**
  77391. * X subdivisions
  77392. */
  77393. readonly subdivisionsX: number;
  77394. /**
  77395. * Y subdivisions
  77396. */
  77397. readonly subdivisionsY: number;
  77398. /**
  77399. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  77400. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  77401. * @param chunksCount the number of subdivisions for x and y
  77402. * @param octreeBlocksSize (Default: 32)
  77403. */
  77404. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  77405. /**
  77406. * Returns a height (y) value in the Worl system :
  77407. * the ground altitude at the coordinates (x, z) expressed in the World system.
  77408. * @param x x coordinate
  77409. * @param z z coordinate
  77410. * @returns the ground y position if (x, z) are outside the ground surface.
  77411. */
  77412. getHeightAtCoordinates(x: number, z: number): number;
  77413. /**
  77414. * Returns a normalized vector (Vector3) orthogonal to the ground
  77415. * at the ground coordinates (x, z) expressed in the World system.
  77416. * @param x x coordinate
  77417. * @param z z coordinate
  77418. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  77419. */
  77420. getNormalAtCoordinates(x: number, z: number): Vector3;
  77421. /**
  77422. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  77423. * at the ground coordinates (x, z) expressed in the World system.
  77424. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  77425. * @param x x coordinate
  77426. * @param z z coordinate
  77427. * @param ref vector to store the result
  77428. * @returns the GroundMesh.
  77429. */
  77430. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  77431. /**
  77432. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  77433. * if the ground has been updated.
  77434. * This can be used in the render loop.
  77435. * @returns the GroundMesh.
  77436. */
  77437. updateCoordinateHeights(): GroundMesh;
  77438. private _getFacetAt;
  77439. private _initHeightQuads;
  77440. private _computeHeightQuads;
  77441. /**
  77442. * Serializes this ground mesh
  77443. * @param serializationObject object to write serialization to
  77444. */
  77445. serialize(serializationObject: any): void;
  77446. /**
  77447. * Parses a serialized ground mesh
  77448. * @param parsedMesh the serialized mesh
  77449. * @param scene the scene to create the ground mesh in
  77450. * @returns the created ground mesh
  77451. */
  77452. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  77453. }
  77454. }
  77455. declare module BABYLON {
  77456. /**
  77457. * Interface for Physics-Joint data
  77458. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77459. */
  77460. export interface PhysicsJointData {
  77461. /**
  77462. * The main pivot of the joint
  77463. */
  77464. mainPivot?: Vector3;
  77465. /**
  77466. * The connected pivot of the joint
  77467. */
  77468. connectedPivot?: Vector3;
  77469. /**
  77470. * The main axis of the joint
  77471. */
  77472. mainAxis?: Vector3;
  77473. /**
  77474. * The connected axis of the joint
  77475. */
  77476. connectedAxis?: Vector3;
  77477. /**
  77478. * The collision of the joint
  77479. */
  77480. collision?: boolean;
  77481. /**
  77482. * Native Oimo/Cannon/Energy data
  77483. */
  77484. nativeParams?: any;
  77485. }
  77486. /**
  77487. * This is a holder class for the physics joint created by the physics plugin
  77488. * It holds a set of functions to control the underlying joint
  77489. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77490. */
  77491. export class PhysicsJoint {
  77492. /**
  77493. * The type of the physics joint
  77494. */
  77495. type: number;
  77496. /**
  77497. * The data for the physics joint
  77498. */
  77499. jointData: PhysicsJointData;
  77500. private _physicsJoint;
  77501. protected _physicsPlugin: IPhysicsEnginePlugin;
  77502. /**
  77503. * Initializes the physics joint
  77504. * @param type The type of the physics joint
  77505. * @param jointData The data for the physics joint
  77506. */
  77507. constructor(
  77508. /**
  77509. * The type of the physics joint
  77510. */
  77511. type: number,
  77512. /**
  77513. * The data for the physics joint
  77514. */
  77515. jointData: PhysicsJointData);
  77516. /**
  77517. * Gets the physics joint
  77518. */
  77519. /**
  77520. * Sets the physics joint
  77521. */
  77522. physicsJoint: any;
  77523. /**
  77524. * Sets the physics plugin
  77525. */
  77526. physicsPlugin: IPhysicsEnginePlugin;
  77527. /**
  77528. * Execute a function that is physics-plugin specific.
  77529. * @param {Function} func the function that will be executed.
  77530. * It accepts two parameters: the physics world and the physics joint
  77531. */
  77532. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  77533. /**
  77534. * Distance-Joint type
  77535. */
  77536. static DistanceJoint: number;
  77537. /**
  77538. * Hinge-Joint type
  77539. */
  77540. static HingeJoint: number;
  77541. /**
  77542. * Ball-and-Socket joint type
  77543. */
  77544. static BallAndSocketJoint: number;
  77545. /**
  77546. * Wheel-Joint type
  77547. */
  77548. static WheelJoint: number;
  77549. /**
  77550. * Slider-Joint type
  77551. */
  77552. static SliderJoint: number;
  77553. /**
  77554. * Prismatic-Joint type
  77555. */
  77556. static PrismaticJoint: number;
  77557. /**
  77558. * Universal-Joint type
  77559. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  77560. */
  77561. static UniversalJoint: number;
  77562. /**
  77563. * Hinge-Joint 2 type
  77564. */
  77565. static Hinge2Joint: number;
  77566. /**
  77567. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  77568. */
  77569. static PointToPointJoint: number;
  77570. /**
  77571. * Spring-Joint type
  77572. */
  77573. static SpringJoint: number;
  77574. /**
  77575. * Lock-Joint type
  77576. */
  77577. static LockJoint: number;
  77578. }
  77579. /**
  77580. * A class representing a physics distance joint
  77581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77582. */
  77583. export class DistanceJoint extends PhysicsJoint {
  77584. /**
  77585. *
  77586. * @param jointData The data for the Distance-Joint
  77587. */
  77588. constructor(jointData: DistanceJointData);
  77589. /**
  77590. * Update the predefined distance.
  77591. * @param maxDistance The maximum preferred distance
  77592. * @param minDistance The minimum preferred distance
  77593. */
  77594. updateDistance(maxDistance: number, minDistance?: number): void;
  77595. }
  77596. /**
  77597. * Represents a Motor-Enabled Joint
  77598. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77599. */
  77600. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  77601. /**
  77602. * Initializes the Motor-Enabled Joint
  77603. * @param type The type of the joint
  77604. * @param jointData The physica joint data for the joint
  77605. */
  77606. constructor(type: number, jointData: PhysicsJointData);
  77607. /**
  77608. * Set the motor values.
  77609. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77610. * @param force the force to apply
  77611. * @param maxForce max force for this motor.
  77612. */
  77613. setMotor(force?: number, maxForce?: number): void;
  77614. /**
  77615. * Set the motor's limits.
  77616. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77617. * @param upperLimit The upper limit of the motor
  77618. * @param lowerLimit The lower limit of the motor
  77619. */
  77620. setLimit(upperLimit: number, lowerLimit?: number): void;
  77621. }
  77622. /**
  77623. * This class represents a single physics Hinge-Joint
  77624. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77625. */
  77626. export class HingeJoint extends MotorEnabledJoint {
  77627. /**
  77628. * Initializes the Hinge-Joint
  77629. * @param jointData The joint data for the Hinge-Joint
  77630. */
  77631. constructor(jointData: PhysicsJointData);
  77632. /**
  77633. * Set the motor values.
  77634. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77635. * @param {number} force the force to apply
  77636. * @param {number} maxForce max force for this motor.
  77637. */
  77638. setMotor(force?: number, maxForce?: number): void;
  77639. /**
  77640. * Set the motor's limits.
  77641. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77642. * @param upperLimit The upper limit of the motor
  77643. * @param lowerLimit The lower limit of the motor
  77644. */
  77645. setLimit(upperLimit: number, lowerLimit?: number): void;
  77646. }
  77647. /**
  77648. * This class represents a dual hinge physics joint (same as wheel joint)
  77649. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77650. */
  77651. export class Hinge2Joint extends MotorEnabledJoint {
  77652. /**
  77653. * Initializes the Hinge2-Joint
  77654. * @param jointData The joint data for the Hinge2-Joint
  77655. */
  77656. constructor(jointData: PhysicsJointData);
  77657. /**
  77658. * Set the motor values.
  77659. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77660. * @param {number} targetSpeed the speed the motor is to reach
  77661. * @param {number} maxForce max force for this motor.
  77662. * @param {motorIndex} the motor's index, 0 or 1.
  77663. */
  77664. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  77665. /**
  77666. * Set the motor limits.
  77667. * Attention, this function is plugin specific. Engines won't react 100% the same.
  77668. * @param {number} upperLimit the upper limit
  77669. * @param {number} lowerLimit lower limit
  77670. * @param {motorIndex} the motor's index, 0 or 1.
  77671. */
  77672. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  77673. }
  77674. /**
  77675. * Interface for a motor enabled joint
  77676. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77677. */
  77678. export interface IMotorEnabledJoint {
  77679. /**
  77680. * Physics joint
  77681. */
  77682. physicsJoint: any;
  77683. /**
  77684. * Sets the motor of the motor-enabled joint
  77685. * @param force The force of the motor
  77686. * @param maxForce The maximum force of the motor
  77687. * @param motorIndex The index of the motor
  77688. */
  77689. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  77690. /**
  77691. * Sets the limit of the motor
  77692. * @param upperLimit The upper limit of the motor
  77693. * @param lowerLimit The lower limit of the motor
  77694. * @param motorIndex The index of the motor
  77695. */
  77696. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  77697. }
  77698. /**
  77699. * Joint data for a Distance-Joint
  77700. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77701. */
  77702. export interface DistanceJointData extends PhysicsJointData {
  77703. /**
  77704. * Max distance the 2 joint objects can be apart
  77705. */
  77706. maxDistance: number;
  77707. }
  77708. /**
  77709. * Joint data from a spring joint
  77710. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77711. */
  77712. export interface SpringJointData extends PhysicsJointData {
  77713. /**
  77714. * Length of the spring
  77715. */
  77716. length: number;
  77717. /**
  77718. * Stiffness of the spring
  77719. */
  77720. stiffness: number;
  77721. /**
  77722. * Damping of the spring
  77723. */
  77724. damping: number;
  77725. /** this callback will be called when applying the force to the impostors. */
  77726. forceApplicationCallback: () => void;
  77727. }
  77728. }
  77729. declare module BABYLON {
  77730. /**
  77731. * Holds the data for the raycast result
  77732. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77733. */
  77734. export class PhysicsRaycastResult {
  77735. private _hasHit;
  77736. private _hitDistance;
  77737. private _hitNormalWorld;
  77738. private _hitPointWorld;
  77739. private _rayFromWorld;
  77740. private _rayToWorld;
  77741. /**
  77742. * Gets if there was a hit
  77743. */
  77744. readonly hasHit: boolean;
  77745. /**
  77746. * Gets the distance from the hit
  77747. */
  77748. readonly hitDistance: number;
  77749. /**
  77750. * Gets the hit normal/direction in the world
  77751. */
  77752. readonly hitNormalWorld: Vector3;
  77753. /**
  77754. * Gets the hit point in the world
  77755. */
  77756. readonly hitPointWorld: Vector3;
  77757. /**
  77758. * Gets the ray "start point" of the ray in the world
  77759. */
  77760. readonly rayFromWorld: Vector3;
  77761. /**
  77762. * Gets the ray "end point" of the ray in the world
  77763. */
  77764. readonly rayToWorld: Vector3;
  77765. /**
  77766. * Sets the hit data (normal & point in world space)
  77767. * @param hitNormalWorld defines the normal in world space
  77768. * @param hitPointWorld defines the point in world space
  77769. */
  77770. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  77771. /**
  77772. * Sets the distance from the start point to the hit point
  77773. * @param distance
  77774. */
  77775. setHitDistance(distance: number): void;
  77776. /**
  77777. * Calculates the distance manually
  77778. */
  77779. calculateHitDistance(): void;
  77780. /**
  77781. * Resets all the values to default
  77782. * @param from The from point on world space
  77783. * @param to The to point on world space
  77784. */
  77785. reset(from?: Vector3, to?: Vector3): void;
  77786. }
  77787. /**
  77788. * Interface for the size containing width and height
  77789. */
  77790. interface IXYZ {
  77791. /**
  77792. * X
  77793. */
  77794. x: number;
  77795. /**
  77796. * Y
  77797. */
  77798. y: number;
  77799. /**
  77800. * Z
  77801. */
  77802. z: number;
  77803. }
  77804. }
  77805. declare module BABYLON {
  77806. /**
  77807. * Interface used to describe a physics joint
  77808. */
  77809. export interface PhysicsImpostorJoint {
  77810. /** Defines the main impostor to which the joint is linked */
  77811. mainImpostor: PhysicsImpostor;
  77812. /** Defines the impostor that is connected to the main impostor using this joint */
  77813. connectedImpostor: PhysicsImpostor;
  77814. /** Defines the joint itself */
  77815. joint: PhysicsJoint;
  77816. }
  77817. /** @hidden */
  77818. export interface IPhysicsEnginePlugin {
  77819. world: any;
  77820. name: string;
  77821. setGravity(gravity: Vector3): void;
  77822. setTimeStep(timeStep: number): void;
  77823. getTimeStep(): number;
  77824. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  77825. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  77826. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  77827. generatePhysicsBody(impostor: PhysicsImpostor): void;
  77828. removePhysicsBody(impostor: PhysicsImpostor): void;
  77829. generateJoint(joint: PhysicsImpostorJoint): void;
  77830. removeJoint(joint: PhysicsImpostorJoint): void;
  77831. isSupported(): boolean;
  77832. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  77833. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  77834. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  77835. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  77836. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  77837. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  77838. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  77839. getBodyMass(impostor: PhysicsImpostor): number;
  77840. getBodyFriction(impostor: PhysicsImpostor): number;
  77841. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  77842. getBodyRestitution(impostor: PhysicsImpostor): number;
  77843. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  77844. getBodyPressure?(impostor: PhysicsImpostor): number;
  77845. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  77846. getBodyStiffness?(impostor: PhysicsImpostor): number;
  77847. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  77848. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  77849. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  77850. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  77851. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  77852. sleepBody(impostor: PhysicsImpostor): void;
  77853. wakeUpBody(impostor: PhysicsImpostor): void;
  77854. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  77855. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  77856. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  77857. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  77858. getRadius(impostor: PhysicsImpostor): number;
  77859. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  77860. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  77861. dispose(): void;
  77862. }
  77863. /**
  77864. * Interface used to define a physics engine
  77865. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  77866. */
  77867. export interface IPhysicsEngine {
  77868. /**
  77869. * Gets the gravity vector used by the simulation
  77870. */
  77871. gravity: Vector3;
  77872. /**
  77873. * Sets the gravity vector used by the simulation
  77874. * @param gravity defines the gravity vector to use
  77875. */
  77876. setGravity(gravity: Vector3): void;
  77877. /**
  77878. * Set the time step of the physics engine.
  77879. * Default is 1/60.
  77880. * To slow it down, enter 1/600 for example.
  77881. * To speed it up, 1/30
  77882. * @param newTimeStep the new timestep to apply to this world.
  77883. */
  77884. setTimeStep(newTimeStep: number): void;
  77885. /**
  77886. * Get the time step of the physics engine.
  77887. * @returns the current time step
  77888. */
  77889. getTimeStep(): number;
  77890. /**
  77891. * Release all resources
  77892. */
  77893. dispose(): void;
  77894. /**
  77895. * Gets the name of the current physics plugin
  77896. * @returns the name of the plugin
  77897. */
  77898. getPhysicsPluginName(): string;
  77899. /**
  77900. * Adding a new impostor for the impostor tracking.
  77901. * This will be done by the impostor itself.
  77902. * @param impostor the impostor to add
  77903. */
  77904. addImpostor(impostor: PhysicsImpostor): void;
  77905. /**
  77906. * Remove an impostor from the engine.
  77907. * This impostor and its mesh will not longer be updated by the physics engine.
  77908. * @param impostor the impostor to remove
  77909. */
  77910. removeImpostor(impostor: PhysicsImpostor): void;
  77911. /**
  77912. * Add a joint to the physics engine
  77913. * @param mainImpostor defines the main impostor to which the joint is added.
  77914. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  77915. * @param joint defines the joint that will connect both impostors.
  77916. */
  77917. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  77918. /**
  77919. * Removes a joint from the simulation
  77920. * @param mainImpostor defines the impostor used with the joint
  77921. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  77922. * @param joint defines the joint to remove
  77923. */
  77924. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  77925. /**
  77926. * Gets the current plugin used to run the simulation
  77927. * @returns current plugin
  77928. */
  77929. getPhysicsPlugin(): IPhysicsEnginePlugin;
  77930. /**
  77931. * Gets the list of physic impostors
  77932. * @returns an array of PhysicsImpostor
  77933. */
  77934. getImpostors(): Array<PhysicsImpostor>;
  77935. /**
  77936. * Gets the impostor for a physics enabled object
  77937. * @param object defines the object impersonated by the impostor
  77938. * @returns the PhysicsImpostor or null if not found
  77939. */
  77940. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  77941. /**
  77942. * Gets the impostor for a physics body object
  77943. * @param body defines physics body used by the impostor
  77944. * @returns the PhysicsImpostor or null if not found
  77945. */
  77946. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  77947. /**
  77948. * Does a raycast in the physics world
  77949. * @param from when should the ray start?
  77950. * @param to when should the ray end?
  77951. * @returns PhysicsRaycastResult
  77952. */
  77953. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  77954. /**
  77955. * Called by the scene. No need to call it.
  77956. * @param delta defines the timespam between frames
  77957. */
  77958. _step(delta: number): void;
  77959. }
  77960. }
  77961. declare module BABYLON {
  77962. /**
  77963. * The interface for the physics imposter parameters
  77964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  77965. */
  77966. export interface PhysicsImpostorParameters {
  77967. /**
  77968. * The mass of the physics imposter
  77969. */
  77970. mass: number;
  77971. /**
  77972. * The friction of the physics imposter
  77973. */
  77974. friction?: number;
  77975. /**
  77976. * The coefficient of restitution of the physics imposter
  77977. */
  77978. restitution?: number;
  77979. /**
  77980. * The native options of the physics imposter
  77981. */
  77982. nativeOptions?: any;
  77983. /**
  77984. * Specifies if the parent should be ignored
  77985. */
  77986. ignoreParent?: boolean;
  77987. /**
  77988. * Specifies if bi-directional transformations should be disabled
  77989. */
  77990. disableBidirectionalTransformation?: boolean;
  77991. /**
  77992. * The pressure inside the physics imposter, soft object only
  77993. */
  77994. pressure?: number;
  77995. /**
  77996. * The stiffness the physics imposter, soft object only
  77997. */
  77998. stiffness?: number;
  77999. /**
  78000. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  78001. */
  78002. velocityIterations?: number;
  78003. /**
  78004. * The number of iterations used in maintaining consistent vertex positions, soft object only
  78005. */
  78006. positionIterations?: number;
  78007. /**
  78008. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  78009. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  78010. * Add to fix multiple points
  78011. */
  78012. fixedPoints?: number;
  78013. /**
  78014. * The collision margin around a soft object
  78015. */
  78016. margin?: number;
  78017. /**
  78018. * The collision margin around a soft object
  78019. */
  78020. damping?: number;
  78021. }
  78022. /**
  78023. * Interface for a physics-enabled object
  78024. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78025. */
  78026. export interface IPhysicsEnabledObject {
  78027. /**
  78028. * The position of the physics-enabled object
  78029. */
  78030. position: Vector3;
  78031. /**
  78032. * The rotation of the physics-enabled object
  78033. */
  78034. rotationQuaternion: Nullable<Quaternion>;
  78035. /**
  78036. * The scale of the physics-enabled object
  78037. */
  78038. scaling: Vector3;
  78039. /**
  78040. * The rotation of the physics-enabled object
  78041. */
  78042. rotation?: Vector3;
  78043. /**
  78044. * The parent of the physics-enabled object
  78045. */
  78046. parent?: any;
  78047. /**
  78048. * The bounding info of the physics-enabled object
  78049. * @returns The bounding info of the physics-enabled object
  78050. */
  78051. getBoundingInfo(): BoundingInfo;
  78052. /**
  78053. * Computes the world matrix
  78054. * @param force Specifies if the world matrix should be computed by force
  78055. * @returns A world matrix
  78056. */
  78057. computeWorldMatrix(force: boolean): Matrix;
  78058. /**
  78059. * Gets the world matrix
  78060. * @returns A world matrix
  78061. */
  78062. getWorldMatrix?(): Matrix;
  78063. /**
  78064. * Gets the child meshes
  78065. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  78066. * @returns An array of abstract meshes
  78067. */
  78068. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  78069. /**
  78070. * Gets the vertex data
  78071. * @param kind The type of vertex data
  78072. * @returns A nullable array of numbers, or a float32 array
  78073. */
  78074. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  78075. /**
  78076. * Gets the indices from the mesh
  78077. * @returns A nullable array of index arrays
  78078. */
  78079. getIndices?(): Nullable<IndicesArray>;
  78080. /**
  78081. * Gets the scene from the mesh
  78082. * @returns the indices array or null
  78083. */
  78084. getScene?(): Scene;
  78085. /**
  78086. * Gets the absolute position from the mesh
  78087. * @returns the absolute position
  78088. */
  78089. getAbsolutePosition(): Vector3;
  78090. /**
  78091. * Gets the absolute pivot point from the mesh
  78092. * @returns the absolute pivot point
  78093. */
  78094. getAbsolutePivotPoint(): Vector3;
  78095. /**
  78096. * Rotates the mesh
  78097. * @param axis The axis of rotation
  78098. * @param amount The amount of rotation
  78099. * @param space The space of the rotation
  78100. * @returns The rotation transform node
  78101. */
  78102. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  78103. /**
  78104. * Translates the mesh
  78105. * @param axis The axis of translation
  78106. * @param distance The distance of translation
  78107. * @param space The space of the translation
  78108. * @returns The transform node
  78109. */
  78110. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  78111. /**
  78112. * Sets the absolute position of the mesh
  78113. * @param absolutePosition The absolute position of the mesh
  78114. * @returns The transform node
  78115. */
  78116. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  78117. /**
  78118. * Gets the class name of the mesh
  78119. * @returns The class name
  78120. */
  78121. getClassName(): string;
  78122. }
  78123. /**
  78124. * Represents a physics imposter
  78125. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78126. */
  78127. export class PhysicsImpostor {
  78128. /**
  78129. * The physics-enabled object used as the physics imposter
  78130. */
  78131. object: IPhysicsEnabledObject;
  78132. /**
  78133. * The type of the physics imposter
  78134. */
  78135. type: number;
  78136. private _options;
  78137. private _scene?;
  78138. /**
  78139. * The default object size of the imposter
  78140. */
  78141. static DEFAULT_OBJECT_SIZE: Vector3;
  78142. /**
  78143. * The identity quaternion of the imposter
  78144. */
  78145. static IDENTITY_QUATERNION: Quaternion;
  78146. /** @hidden */
  78147. _pluginData: any;
  78148. private _physicsEngine;
  78149. private _physicsBody;
  78150. private _bodyUpdateRequired;
  78151. private _onBeforePhysicsStepCallbacks;
  78152. private _onAfterPhysicsStepCallbacks;
  78153. /** @hidden */
  78154. _onPhysicsCollideCallbacks: Array<{
  78155. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  78156. otherImpostors: Array<PhysicsImpostor>;
  78157. }>;
  78158. private _deltaPosition;
  78159. private _deltaRotation;
  78160. private _deltaRotationConjugated;
  78161. private _parent;
  78162. private _isDisposed;
  78163. private static _tmpVecs;
  78164. private static _tmpQuat;
  78165. /**
  78166. * Specifies if the physics imposter is disposed
  78167. */
  78168. readonly isDisposed: boolean;
  78169. /**
  78170. * Gets the mass of the physics imposter
  78171. */
  78172. mass: number;
  78173. /**
  78174. * Gets the coefficient of friction
  78175. */
  78176. /**
  78177. * Sets the coefficient of friction
  78178. */
  78179. friction: number;
  78180. /**
  78181. * Gets the coefficient of restitution
  78182. */
  78183. /**
  78184. * Sets the coefficient of restitution
  78185. */
  78186. restitution: number;
  78187. /**
  78188. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  78189. */
  78190. /**
  78191. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  78192. */
  78193. pressure: number;
  78194. /**
  78195. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  78196. */
  78197. /**
  78198. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  78199. */
  78200. stiffness: number;
  78201. /**
  78202. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  78203. */
  78204. /**
  78205. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  78206. */
  78207. velocityIterations: number;
  78208. /**
  78209. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  78210. */
  78211. /**
  78212. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  78213. */
  78214. positionIterations: number;
  78215. /**
  78216. * The unique id of the physics imposter
  78217. * set by the physics engine when adding this impostor to the array
  78218. */
  78219. uniqueId: number;
  78220. /**
  78221. * @hidden
  78222. */
  78223. soft: boolean;
  78224. /**
  78225. * @hidden
  78226. */
  78227. segments: number;
  78228. private _joints;
  78229. /**
  78230. * Initializes the physics imposter
  78231. * @param object The physics-enabled object used as the physics imposter
  78232. * @param type The type of the physics imposter
  78233. * @param _options The options for the physics imposter
  78234. * @param _scene The Babylon scene
  78235. */
  78236. constructor(
  78237. /**
  78238. * The physics-enabled object used as the physics imposter
  78239. */
  78240. object: IPhysicsEnabledObject,
  78241. /**
  78242. * The type of the physics imposter
  78243. */
  78244. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  78245. /**
  78246. * This function will completly initialize this impostor.
  78247. * It will create a new body - but only if this mesh has no parent.
  78248. * If it has, this impostor will not be used other than to define the impostor
  78249. * of the child mesh.
  78250. * @hidden
  78251. */
  78252. _init(): void;
  78253. private _getPhysicsParent;
  78254. /**
  78255. * Should a new body be generated.
  78256. * @returns boolean specifying if body initialization is required
  78257. */
  78258. isBodyInitRequired(): boolean;
  78259. /**
  78260. * Sets the updated scaling
  78261. * @param updated Specifies if the scaling is updated
  78262. */
  78263. setScalingUpdated(): void;
  78264. /**
  78265. * Force a regeneration of this or the parent's impostor's body.
  78266. * Use under cautious - This will remove all joints already implemented.
  78267. */
  78268. forceUpdate(): void;
  78269. /**
  78270. * Gets the body that holds this impostor. Either its own, or its parent.
  78271. */
  78272. /**
  78273. * Set the physics body. Used mainly by the physics engine/plugin
  78274. */
  78275. physicsBody: any;
  78276. /**
  78277. * Get the parent of the physics imposter
  78278. * @returns Physics imposter or null
  78279. */
  78280. /**
  78281. * Sets the parent of the physics imposter
  78282. */
  78283. parent: Nullable<PhysicsImpostor>;
  78284. /**
  78285. * Resets the update flags
  78286. */
  78287. resetUpdateFlags(): void;
  78288. /**
  78289. * Gets the object extend size
  78290. * @returns the object extend size
  78291. */
  78292. getObjectExtendSize(): Vector3;
  78293. /**
  78294. * Gets the object center
  78295. * @returns The object center
  78296. */
  78297. getObjectCenter(): Vector3;
  78298. /**
  78299. * Get a specific parametes from the options parameter
  78300. * @param paramName The object parameter name
  78301. * @returns The object parameter
  78302. */
  78303. getParam(paramName: string): any;
  78304. /**
  78305. * Sets a specific parameter in the options given to the physics plugin
  78306. * @param paramName The parameter name
  78307. * @param value The value of the parameter
  78308. */
  78309. setParam(paramName: string, value: number): void;
  78310. /**
  78311. * Specifically change the body's mass option. Won't recreate the physics body object
  78312. * @param mass The mass of the physics imposter
  78313. */
  78314. setMass(mass: number): void;
  78315. /**
  78316. * Gets the linear velocity
  78317. * @returns linear velocity or null
  78318. */
  78319. getLinearVelocity(): Nullable<Vector3>;
  78320. /**
  78321. * Sets the linear velocity
  78322. * @param velocity linear velocity or null
  78323. */
  78324. setLinearVelocity(velocity: Nullable<Vector3>): void;
  78325. /**
  78326. * Gets the angular velocity
  78327. * @returns angular velocity or null
  78328. */
  78329. getAngularVelocity(): Nullable<Vector3>;
  78330. /**
  78331. * Sets the angular velocity
  78332. * @param velocity The velocity or null
  78333. */
  78334. setAngularVelocity(velocity: Nullable<Vector3>): void;
  78335. /**
  78336. * Execute a function with the physics plugin native code
  78337. * Provide a function the will have two variables - the world object and the physics body object
  78338. * @param func The function to execute with the physics plugin native code
  78339. */
  78340. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  78341. /**
  78342. * Register a function that will be executed before the physics world is stepping forward
  78343. * @param func The function to execute before the physics world is stepped forward
  78344. */
  78345. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78346. /**
  78347. * Unregister a function that will be executed before the physics world is stepping forward
  78348. * @param func The function to execute before the physics world is stepped forward
  78349. */
  78350. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78351. /**
  78352. * Register a function that will be executed after the physics step
  78353. * @param func The function to execute after physics step
  78354. */
  78355. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78356. /**
  78357. * Unregisters a function that will be executed after the physics step
  78358. * @param func The function to execute after physics step
  78359. */
  78360. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  78361. /**
  78362. * register a function that will be executed when this impostor collides against a different body
  78363. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  78364. * @param func Callback that is executed on collision
  78365. */
  78366. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  78367. /**
  78368. * Unregisters the physics imposter on contact
  78369. * @param collideAgainst The physics object to collide against
  78370. * @param func Callback to execute on collision
  78371. */
  78372. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  78373. private _tmpQuat;
  78374. private _tmpQuat2;
  78375. /**
  78376. * Get the parent rotation
  78377. * @returns The parent rotation
  78378. */
  78379. getParentsRotation(): Quaternion;
  78380. /**
  78381. * this function is executed by the physics engine.
  78382. */
  78383. beforeStep: () => void;
  78384. /**
  78385. * this function is executed by the physics engine
  78386. */
  78387. afterStep: () => void;
  78388. /**
  78389. * Legacy collision detection event support
  78390. */
  78391. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  78392. /**
  78393. * event and body object due to cannon's event-based architecture.
  78394. */
  78395. onCollide: (e: {
  78396. body: any;
  78397. }) => void;
  78398. /**
  78399. * Apply a force
  78400. * @param force The force to apply
  78401. * @param contactPoint The contact point for the force
  78402. * @returns The physics imposter
  78403. */
  78404. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  78405. /**
  78406. * Apply an impulse
  78407. * @param force The impulse force
  78408. * @param contactPoint The contact point for the impulse force
  78409. * @returns The physics imposter
  78410. */
  78411. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  78412. /**
  78413. * A help function to create a joint
  78414. * @param otherImpostor A physics imposter used to create a joint
  78415. * @param jointType The type of joint
  78416. * @param jointData The data for the joint
  78417. * @returns The physics imposter
  78418. */
  78419. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  78420. /**
  78421. * Add a joint to this impostor with a different impostor
  78422. * @param otherImpostor A physics imposter used to add a joint
  78423. * @param joint The joint to add
  78424. * @returns The physics imposter
  78425. */
  78426. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  78427. /**
  78428. * Will keep this body still, in a sleep mode.
  78429. * @returns the physics imposter
  78430. */
  78431. sleep(): PhysicsImpostor;
  78432. /**
  78433. * Wake the body up.
  78434. * @returns The physics imposter
  78435. */
  78436. wakeUp(): PhysicsImpostor;
  78437. /**
  78438. * Clones the physics imposter
  78439. * @param newObject The physics imposter clones to this physics-enabled object
  78440. * @returns A nullable physics imposter
  78441. */
  78442. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  78443. /**
  78444. * Disposes the physics imposter
  78445. */
  78446. dispose(): void;
  78447. /**
  78448. * Sets the delta position
  78449. * @param position The delta position amount
  78450. */
  78451. setDeltaPosition(position: Vector3): void;
  78452. /**
  78453. * Sets the delta rotation
  78454. * @param rotation The delta rotation amount
  78455. */
  78456. setDeltaRotation(rotation: Quaternion): void;
  78457. /**
  78458. * Gets the box size of the physics imposter and stores the result in the input parameter
  78459. * @param result Stores the box size
  78460. * @returns The physics imposter
  78461. */
  78462. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  78463. /**
  78464. * Gets the radius of the physics imposter
  78465. * @returns Radius of the physics imposter
  78466. */
  78467. getRadius(): number;
  78468. /**
  78469. * Sync a bone with this impostor
  78470. * @param bone The bone to sync to the impostor.
  78471. * @param boneMesh The mesh that the bone is influencing.
  78472. * @param jointPivot The pivot of the joint / bone in local space.
  78473. * @param distToJoint Optional distance from the impostor to the joint.
  78474. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  78475. */
  78476. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  78477. /**
  78478. * Sync impostor to a bone
  78479. * @param bone The bone that the impostor will be synced to.
  78480. * @param boneMesh The mesh that the bone is influencing.
  78481. * @param jointPivot The pivot of the joint / bone in local space.
  78482. * @param distToJoint Optional distance from the impostor to the joint.
  78483. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  78484. * @param boneAxis Optional vector3 axis the bone is aligned with
  78485. */
  78486. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  78487. /**
  78488. * No-Imposter type
  78489. */
  78490. static NoImpostor: number;
  78491. /**
  78492. * Sphere-Imposter type
  78493. */
  78494. static SphereImpostor: number;
  78495. /**
  78496. * Box-Imposter type
  78497. */
  78498. static BoxImpostor: number;
  78499. /**
  78500. * Plane-Imposter type
  78501. */
  78502. static PlaneImpostor: number;
  78503. /**
  78504. * Mesh-imposter type
  78505. */
  78506. static MeshImpostor: number;
  78507. /**
  78508. * Cylinder-Imposter type
  78509. */
  78510. static CylinderImpostor: number;
  78511. /**
  78512. * Particle-Imposter type
  78513. */
  78514. static ParticleImpostor: number;
  78515. /**
  78516. * Heightmap-Imposter type
  78517. */
  78518. static HeightmapImpostor: number;
  78519. /**
  78520. * ConvexHull-Impostor type (Ammo.js plugin only)
  78521. */
  78522. static ConvexHullImpostor: number;
  78523. /**
  78524. * Rope-Imposter type
  78525. */
  78526. static RopeImpostor: number;
  78527. /**
  78528. * Cloth-Imposter type
  78529. */
  78530. static ClothImpostor: number;
  78531. /**
  78532. * Softbody-Imposter type
  78533. */
  78534. static SoftbodyImpostor: number;
  78535. }
  78536. }
  78537. declare module BABYLON {
  78538. /**
  78539. * Class used to represent a specific level of detail of a mesh
  78540. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  78541. */
  78542. export class MeshLODLevel {
  78543. /** Defines the distance where this level should star being displayed */
  78544. distance: number;
  78545. /** Defines the mesh to use to render this level */
  78546. mesh: Nullable<Mesh>;
  78547. /**
  78548. * Creates a new LOD level
  78549. * @param distance defines the distance where this level should star being displayed
  78550. * @param mesh defines the mesh to use to render this level
  78551. */
  78552. constructor(
  78553. /** Defines the distance where this level should star being displayed */
  78554. distance: number,
  78555. /** Defines the mesh to use to render this level */
  78556. mesh: Nullable<Mesh>);
  78557. }
  78558. /**
  78559. * @hidden
  78560. **/
  78561. export class _CreationDataStorage {
  78562. closePath?: boolean;
  78563. closeArray?: boolean;
  78564. idx: number[];
  78565. dashSize: number;
  78566. gapSize: number;
  78567. path3D: Path3D;
  78568. pathArray: Vector3[][];
  78569. arc: number;
  78570. radius: number;
  78571. cap: number;
  78572. tessellation: number;
  78573. }
  78574. /**
  78575. * @hidden
  78576. **/
  78577. class _InstanceDataStorage {
  78578. visibleInstances: any;
  78579. renderIdForInstances: number[];
  78580. batchCache: _InstancesBatch;
  78581. instancesBufferSize: number;
  78582. instancesBuffer: Nullable<Buffer>;
  78583. instancesData: Float32Array;
  78584. overridenInstanceCount: number;
  78585. }
  78586. /**
  78587. * @hidden
  78588. **/
  78589. export class _InstancesBatch {
  78590. mustReturn: boolean;
  78591. visibleInstances: Nullable<InstancedMesh[]>[];
  78592. renderSelf: boolean[];
  78593. }
  78594. /**
  78595. * Class used to represent renderable models
  78596. */
  78597. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  78598. /**
  78599. * Mesh side orientation : usually the external or front surface
  78600. */
  78601. static readonly FRONTSIDE: number;
  78602. /**
  78603. * Mesh side orientation : usually the internal or back surface
  78604. */
  78605. static readonly BACKSIDE: number;
  78606. /**
  78607. * Mesh side orientation : both internal and external or front and back surfaces
  78608. */
  78609. static readonly DOUBLESIDE: number;
  78610. /**
  78611. * Mesh side orientation : by default, `FRONTSIDE`
  78612. */
  78613. static readonly DEFAULTSIDE: number;
  78614. /**
  78615. * Mesh cap setting : no cap
  78616. */
  78617. static readonly NO_CAP: number;
  78618. /**
  78619. * Mesh cap setting : one cap at the beginning of the mesh
  78620. */
  78621. static readonly CAP_START: number;
  78622. /**
  78623. * Mesh cap setting : one cap at the end of the mesh
  78624. */
  78625. static readonly CAP_END: number;
  78626. /**
  78627. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  78628. */
  78629. static readonly CAP_ALL: number;
  78630. /**
  78631. * Gets the default side orientation.
  78632. * @param orientation the orientation to value to attempt to get
  78633. * @returns the default orientation
  78634. * @hidden
  78635. */
  78636. static _GetDefaultSideOrientation(orientation?: number): number;
  78637. private _onBeforeRenderObservable;
  78638. private _onBeforeBindObservable;
  78639. private _onAfterRenderObservable;
  78640. private _onBeforeDrawObservable;
  78641. /**
  78642. * An event triggered before rendering the mesh
  78643. */
  78644. readonly onBeforeRenderObservable: Observable<Mesh>;
  78645. /**
  78646. * An event triggered before binding the mesh
  78647. */
  78648. readonly onBeforeBindObservable: Observable<Mesh>;
  78649. /**
  78650. * An event triggered after rendering the mesh
  78651. */
  78652. readonly onAfterRenderObservable: Observable<Mesh>;
  78653. /**
  78654. * An event triggered before drawing the mesh
  78655. */
  78656. readonly onBeforeDrawObservable: Observable<Mesh>;
  78657. private _onBeforeDrawObserver;
  78658. /**
  78659. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  78660. */
  78661. onBeforeDraw: () => void;
  78662. /**
  78663. * Gets the delay loading state of the mesh (when delay loading is turned on)
  78664. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  78665. */
  78666. delayLoadState: number;
  78667. /**
  78668. * Gets the list of instances created from this mesh
  78669. * it is not supposed to be modified manually.
  78670. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  78671. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  78672. */
  78673. instances: InstancedMesh[];
  78674. /**
  78675. * Gets the file containing delay loading data for this mesh
  78676. */
  78677. delayLoadingFile: string;
  78678. /** @hidden */
  78679. _binaryInfo: any;
  78680. private _LODLevels;
  78681. /**
  78682. * User defined function used to change how LOD level selection is done
  78683. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  78684. */
  78685. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  78686. private _morphTargetManager;
  78687. /**
  78688. * Gets or sets the morph target manager
  78689. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78690. */
  78691. morphTargetManager: Nullable<MorphTargetManager>;
  78692. /** @hidden */
  78693. _creationDataStorage: Nullable<_CreationDataStorage>;
  78694. /** @hidden */
  78695. _geometry: Nullable<Geometry>;
  78696. /** @hidden */
  78697. _delayInfo: Array<string>;
  78698. /** @hidden */
  78699. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  78700. /** @hidden */
  78701. _instanceDataStorage: _InstanceDataStorage;
  78702. private _effectiveMaterial;
  78703. /** @hidden */
  78704. _shouldGenerateFlatShading: boolean;
  78705. private _preActivateId;
  78706. /** @hidden */
  78707. _originalBuilderSideOrientation: number;
  78708. /**
  78709. * Use this property to change the original side orientation defined at construction time
  78710. */
  78711. overrideMaterialSideOrientation: Nullable<number>;
  78712. private _areNormalsFrozen;
  78713. private _sourcePositions;
  78714. private _sourceNormals;
  78715. private _source;
  78716. private meshMap;
  78717. /**
  78718. * Gets the source mesh (the one used to clone this one from)
  78719. */
  78720. readonly source: Nullable<Mesh>;
  78721. /**
  78722. * Gets or sets a boolean indicating that this mesh does not use index buffer
  78723. */
  78724. isUnIndexed: boolean;
  78725. /**
  78726. * @constructor
  78727. * @param name The value used by scene.getMeshByName() to do a lookup.
  78728. * @param scene The scene to add this mesh to.
  78729. * @param parent The parent of this mesh, if it has one
  78730. * @param source An optional Mesh from which geometry is shared, cloned.
  78731. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  78732. * When false, achieved by calling a clone(), also passing False.
  78733. * This will make creation of children, recursive.
  78734. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  78735. */
  78736. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  78737. /**
  78738. * Gets the class name
  78739. * @returns the string "Mesh".
  78740. */
  78741. getClassName(): string;
  78742. /** @hidden */
  78743. readonly _isMesh: boolean;
  78744. /**
  78745. * Returns a description of this mesh
  78746. * @param fullDetails define if full details about this mesh must be used
  78747. * @returns a descriptive string representing this mesh
  78748. */
  78749. toString(fullDetails?: boolean): string;
  78750. /** @hidden */
  78751. _unBindEffect(): void;
  78752. /**
  78753. * Gets a boolean indicating if this mesh has LOD
  78754. */
  78755. readonly hasLODLevels: boolean;
  78756. /**
  78757. * Gets the list of MeshLODLevel associated with the current mesh
  78758. * @returns an array of MeshLODLevel
  78759. */
  78760. getLODLevels(): MeshLODLevel[];
  78761. private _sortLODLevels;
  78762. /**
  78763. * Add a mesh as LOD level triggered at the given distance.
  78764. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78765. * @param distance The distance from the center of the object to show this level
  78766. * @param mesh The mesh to be added as LOD level (can be null)
  78767. * @return This mesh (for chaining)
  78768. */
  78769. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  78770. /**
  78771. * Returns the LOD level mesh at the passed distance or null if not found.
  78772. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78773. * @param distance The distance from the center of the object to show this level
  78774. * @returns a Mesh or `null`
  78775. */
  78776. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  78777. /**
  78778. * Remove a mesh from the LOD array
  78779. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78780. * @param mesh defines the mesh to be removed
  78781. * @return This mesh (for chaining)
  78782. */
  78783. removeLODLevel(mesh: Mesh): Mesh;
  78784. /**
  78785. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  78786. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  78787. * @param camera defines the camera to use to compute distance
  78788. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  78789. * @return This mesh (for chaining)
  78790. */
  78791. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  78792. /**
  78793. * Gets the mesh internal Geometry object
  78794. */
  78795. readonly geometry: Nullable<Geometry>;
  78796. /**
  78797. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  78798. * @returns the total number of vertices
  78799. */
  78800. getTotalVertices(): number;
  78801. /**
  78802. * Returns the content of an associated vertex buffer
  78803. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  78804. * - VertexBuffer.PositionKind
  78805. * - VertexBuffer.UVKind
  78806. * - VertexBuffer.UV2Kind
  78807. * - VertexBuffer.UV3Kind
  78808. * - VertexBuffer.UV4Kind
  78809. * - VertexBuffer.UV5Kind
  78810. * - VertexBuffer.UV6Kind
  78811. * - VertexBuffer.ColorKind
  78812. * - VertexBuffer.MatricesIndicesKind
  78813. * - VertexBuffer.MatricesIndicesExtraKind
  78814. * - VertexBuffer.MatricesWeightsKind
  78815. * - VertexBuffer.MatricesWeightsExtraKind
  78816. * @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
  78817. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  78818. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  78819. */
  78820. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  78821. /**
  78822. * Returns the mesh VertexBuffer object from the requested `kind`
  78823. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  78824. * - VertexBuffer.PositionKind
  78825. * - VertexBuffer.UVKind
  78826. * - VertexBuffer.UV2Kind
  78827. * - VertexBuffer.UV3Kind
  78828. * - VertexBuffer.UV4Kind
  78829. * - VertexBuffer.UV5Kind
  78830. * - VertexBuffer.UV6Kind
  78831. * - VertexBuffer.ColorKind
  78832. * - VertexBuffer.MatricesIndicesKind
  78833. * - VertexBuffer.MatricesIndicesExtraKind
  78834. * - VertexBuffer.MatricesWeightsKind
  78835. * - VertexBuffer.MatricesWeightsExtraKind
  78836. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  78837. */
  78838. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  78839. /**
  78840. * Tests if a specific vertex buffer is associated with this mesh
  78841. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  78842. * - VertexBuffer.PositionKind
  78843. * - VertexBuffer.UVKind
  78844. * - VertexBuffer.UV2Kind
  78845. * - VertexBuffer.UV3Kind
  78846. * - VertexBuffer.UV4Kind
  78847. * - VertexBuffer.UV5Kind
  78848. * - VertexBuffer.UV6Kind
  78849. * - VertexBuffer.ColorKind
  78850. * - VertexBuffer.MatricesIndicesKind
  78851. * - VertexBuffer.MatricesIndicesExtraKind
  78852. * - VertexBuffer.MatricesWeightsKind
  78853. * - VertexBuffer.MatricesWeightsExtraKind
  78854. * @returns a boolean
  78855. */
  78856. isVerticesDataPresent(kind: string): boolean;
  78857. /**
  78858. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  78859. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  78860. * - VertexBuffer.PositionKind
  78861. * - VertexBuffer.UVKind
  78862. * - VertexBuffer.UV2Kind
  78863. * - VertexBuffer.UV3Kind
  78864. * - VertexBuffer.UV4Kind
  78865. * - VertexBuffer.UV5Kind
  78866. * - VertexBuffer.UV6Kind
  78867. * - VertexBuffer.ColorKind
  78868. * - VertexBuffer.MatricesIndicesKind
  78869. * - VertexBuffer.MatricesIndicesExtraKind
  78870. * - VertexBuffer.MatricesWeightsKind
  78871. * - VertexBuffer.MatricesWeightsExtraKind
  78872. * @returns a boolean
  78873. */
  78874. isVertexBufferUpdatable(kind: string): boolean;
  78875. /**
  78876. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  78877. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  78878. * - VertexBuffer.PositionKind
  78879. * - VertexBuffer.UVKind
  78880. * - VertexBuffer.UV2Kind
  78881. * - VertexBuffer.UV3Kind
  78882. * - VertexBuffer.UV4Kind
  78883. * - VertexBuffer.UV5Kind
  78884. * - VertexBuffer.UV6Kind
  78885. * - VertexBuffer.ColorKind
  78886. * - VertexBuffer.MatricesIndicesKind
  78887. * - VertexBuffer.MatricesIndicesExtraKind
  78888. * - VertexBuffer.MatricesWeightsKind
  78889. * - VertexBuffer.MatricesWeightsExtraKind
  78890. * @returns an array of strings
  78891. */
  78892. getVerticesDataKinds(): string[];
  78893. /**
  78894. * Returns a positive integer : the total number of indices in this mesh geometry.
  78895. * @returns the numner of indices or zero if the mesh has no geometry.
  78896. */
  78897. getTotalIndices(): number;
  78898. /**
  78899. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  78900. * @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.
  78901. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  78902. * @returns the indices array or an empty array if the mesh has no geometry
  78903. */
  78904. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  78905. readonly isBlocked: boolean;
  78906. /**
  78907. * Determine if the current mesh is ready to be rendered
  78908. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  78909. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  78910. * @returns true if all associated assets are ready (material, textures, shaders)
  78911. */
  78912. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  78913. /**
  78914. * 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.
  78915. */
  78916. readonly areNormalsFrozen: boolean;
  78917. /**
  78918. * 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.
  78919. * @returns the current mesh
  78920. */
  78921. freezeNormals(): Mesh;
  78922. /**
  78923. * 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
  78924. * @returns the current mesh
  78925. */
  78926. unfreezeNormals(): Mesh;
  78927. /**
  78928. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  78929. */
  78930. overridenInstanceCount: number;
  78931. /** @hidden */
  78932. _preActivate(): Mesh;
  78933. /** @hidden */
  78934. _preActivateForIntermediateRendering(renderId: number): Mesh;
  78935. /** @hidden */
  78936. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  78937. /**
  78938. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  78939. * This means the mesh underlying bounding box and sphere are recomputed.
  78940. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  78941. * @returns the current mesh
  78942. */
  78943. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  78944. /** @hidden */
  78945. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  78946. /**
  78947. * This function will subdivide the mesh into multiple submeshes
  78948. * @param count defines the expected number of submeshes
  78949. */
  78950. subdivide(count: number): void;
  78951. /**
  78952. * Copy a FloatArray into a specific associated vertex buffer
  78953. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  78954. * - VertexBuffer.PositionKind
  78955. * - VertexBuffer.UVKind
  78956. * - VertexBuffer.UV2Kind
  78957. * - VertexBuffer.UV3Kind
  78958. * - VertexBuffer.UV4Kind
  78959. * - VertexBuffer.UV5Kind
  78960. * - VertexBuffer.UV6Kind
  78961. * - VertexBuffer.ColorKind
  78962. * - VertexBuffer.MatricesIndicesKind
  78963. * - VertexBuffer.MatricesIndicesExtraKind
  78964. * - VertexBuffer.MatricesWeightsKind
  78965. * - VertexBuffer.MatricesWeightsExtraKind
  78966. * @param data defines the data source
  78967. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  78968. * @param stride defines the data stride size (can be null)
  78969. * @returns the current mesh
  78970. */
  78971. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  78972. /**
  78973. * Flags an associated vertex buffer as updatable
  78974. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  78975. * - VertexBuffer.PositionKind
  78976. * - VertexBuffer.UVKind
  78977. * - VertexBuffer.UV2Kind
  78978. * - VertexBuffer.UV3Kind
  78979. * - VertexBuffer.UV4Kind
  78980. * - VertexBuffer.UV5Kind
  78981. * - VertexBuffer.UV6Kind
  78982. * - VertexBuffer.ColorKind
  78983. * - VertexBuffer.MatricesIndicesKind
  78984. * - VertexBuffer.MatricesIndicesExtraKind
  78985. * - VertexBuffer.MatricesWeightsKind
  78986. * - VertexBuffer.MatricesWeightsExtraKind
  78987. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  78988. */
  78989. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  78990. /**
  78991. * Sets the mesh global Vertex Buffer
  78992. * @param buffer defines the buffer to use
  78993. * @returns the current mesh
  78994. */
  78995. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  78996. /**
  78997. * Update a specific associated vertex buffer
  78998. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  78999. * - VertexBuffer.PositionKind
  79000. * - VertexBuffer.UVKind
  79001. * - VertexBuffer.UV2Kind
  79002. * - VertexBuffer.UV3Kind
  79003. * - VertexBuffer.UV4Kind
  79004. * - VertexBuffer.UV5Kind
  79005. * - VertexBuffer.UV6Kind
  79006. * - VertexBuffer.ColorKind
  79007. * - VertexBuffer.MatricesIndicesKind
  79008. * - VertexBuffer.MatricesIndicesExtraKind
  79009. * - VertexBuffer.MatricesWeightsKind
  79010. * - VertexBuffer.MatricesWeightsExtraKind
  79011. * @param data defines the data source
  79012. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  79013. * @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)
  79014. * @returns the current mesh
  79015. */
  79016. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  79017. /**
  79018. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  79019. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  79020. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  79021. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  79022. * @returns the current mesh
  79023. */
  79024. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  79025. /**
  79026. * Creates a un-shared specific occurence of the geometry for the mesh.
  79027. * @returns the current mesh
  79028. */
  79029. makeGeometryUnique(): Mesh;
  79030. /**
  79031. * Set the index buffer of this mesh
  79032. * @param indices defines the source data
  79033. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  79034. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  79035. * @returns the current mesh
  79036. */
  79037. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  79038. /**
  79039. * Update the current index buffer
  79040. * @param indices defines the source data
  79041. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  79042. * @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)
  79043. * @returns the current mesh
  79044. */
  79045. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  79046. /**
  79047. * Invert the geometry to move from a right handed system to a left handed one.
  79048. * @returns the current mesh
  79049. */
  79050. toLeftHanded(): Mesh;
  79051. /** @hidden */
  79052. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  79053. /** @hidden */
  79054. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  79055. /**
  79056. * Registers for this mesh a javascript function called just before the rendering process
  79057. * @param func defines the function to call before rendering this mesh
  79058. * @returns the current mesh
  79059. */
  79060. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  79061. /**
  79062. * Disposes a previously registered javascript function called before the rendering
  79063. * @param func defines the function to remove
  79064. * @returns the current mesh
  79065. */
  79066. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  79067. /**
  79068. * Registers for this mesh a javascript function called just after the rendering is complete
  79069. * @param func defines the function to call after rendering this mesh
  79070. * @returns the current mesh
  79071. */
  79072. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  79073. /**
  79074. * Disposes a previously registered javascript function called after the rendering.
  79075. * @param func defines the function to remove
  79076. * @returns the current mesh
  79077. */
  79078. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  79079. /** @hidden */
  79080. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  79081. /** @hidden */
  79082. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  79083. /** @hidden */
  79084. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  79085. /**
  79086. * 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
  79087. * @param subMesh defines the subMesh to render
  79088. * @param enableAlphaMode defines if alpha mode can be changed
  79089. * @returns the current mesh
  79090. */
  79091. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  79092. private _onBeforeDraw;
  79093. /**
  79094. * Renormalize the mesh and patch it up if there are no weights
  79095. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  79096. * However in the case of zero weights then we set just a single influence to 1.
  79097. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  79098. */
  79099. cleanMatrixWeights(): void;
  79100. private normalizeSkinFourWeights;
  79101. private normalizeSkinWeightsAndExtra;
  79102. /**
  79103. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  79104. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  79105. * the user know there was an issue with importing the mesh
  79106. * @returns a validation object with skinned, valid and report string
  79107. */
  79108. validateSkinning(): {
  79109. skinned: boolean;
  79110. valid: boolean;
  79111. report: string;
  79112. };
  79113. /** @hidden */
  79114. _checkDelayState(): Mesh;
  79115. private _queueLoad;
  79116. /**
  79117. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  79118. * A mesh is in the frustum if its bounding box intersects the frustum
  79119. * @param frustumPlanes defines the frustum to test
  79120. * @returns true if the mesh is in the frustum planes
  79121. */
  79122. isInFrustum(frustumPlanes: Plane[]): boolean;
  79123. /**
  79124. * Sets the mesh material by the material or multiMaterial `id` property
  79125. * @param id is a string identifying the material or the multiMaterial
  79126. * @returns the current mesh
  79127. */
  79128. setMaterialByID(id: string): Mesh;
  79129. /**
  79130. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  79131. * @returns an array of IAnimatable
  79132. */
  79133. getAnimatables(): IAnimatable[];
  79134. /**
  79135. * Modifies the mesh geometry according to the passed transformation matrix.
  79136. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  79137. * The mesh normals are modified using the same transformation.
  79138. * Note that, under the hood, this method sets a new VertexBuffer each call.
  79139. * @param transform defines the transform matrix to use
  79140. * @see http://doc.babylonjs.com/resources/baking_transformations
  79141. * @returns the current mesh
  79142. */
  79143. bakeTransformIntoVertices(transform: Matrix): Mesh;
  79144. /**
  79145. * Modifies the mesh geometry according to its own current World Matrix.
  79146. * The mesh World Matrix is then reset.
  79147. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  79148. * Note that, under the hood, this method sets a new VertexBuffer each call.
  79149. * @see http://doc.babylonjs.com/resources/baking_transformations
  79150. * @returns the current mesh
  79151. */
  79152. bakeCurrentTransformIntoVertices(): Mesh;
  79153. /** @hidden */
  79154. readonly _positions: Nullable<Vector3[]>;
  79155. /** @hidden */
  79156. _resetPointsArrayCache(): Mesh;
  79157. /** @hidden */
  79158. _generatePointsArray(): boolean;
  79159. /**
  79160. * Returns a new Mesh object generated from the current mesh properties.
  79161. * This method must not get confused with createInstance()
  79162. * @param name is a string, the name given to the new mesh
  79163. * @param newParent can be any Node object (default `null`)
  79164. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  79165. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  79166. * @returns a new mesh
  79167. */
  79168. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  79169. /**
  79170. * Releases resources associated with this mesh.
  79171. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79172. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79173. */
  79174. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79175. /**
  79176. * Modifies the mesh geometry according to a displacement map.
  79177. * 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.
  79178. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  79179. * @param url is a string, the URL from the image file is to be downloaded.
  79180. * @param minHeight is the lower limit of the displacement.
  79181. * @param maxHeight is the upper limit of the displacement.
  79182. * @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.
  79183. * @param uvOffset is an optional vector2 used to offset UV.
  79184. * @param uvScale is an optional vector2 used to scale UV.
  79185. * @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.
  79186. * @returns the Mesh.
  79187. */
  79188. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  79189. /**
  79190. * Modifies the mesh geometry according to a displacementMap buffer.
  79191. * 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.
  79192. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  79193. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  79194. * @param heightMapWidth is the width of the buffer image.
  79195. * @param heightMapHeight is the height of the buffer image.
  79196. * @param minHeight is the lower limit of the displacement.
  79197. * @param maxHeight is the upper limit of the displacement.
  79198. * @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.
  79199. * @param uvOffset is an optional vector2 used to offset UV.
  79200. * @param uvScale is an optional vector2 used to scale UV.
  79201. * @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.
  79202. * @returns the Mesh.
  79203. */
  79204. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  79205. /**
  79206. * Modify the mesh to get a flat shading rendering.
  79207. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  79208. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  79209. * @returns current mesh
  79210. */
  79211. convertToFlatShadedMesh(): Mesh;
  79212. /**
  79213. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  79214. * In other words, more vertices, no more indices and a single bigger VBO.
  79215. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  79216. * @returns current mesh
  79217. */
  79218. convertToUnIndexedMesh(): Mesh;
  79219. /**
  79220. * Inverses facet orientations.
  79221. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  79222. * @param flipNormals will also inverts the normals
  79223. * @returns current mesh
  79224. */
  79225. flipFaces(flipNormals?: boolean): Mesh;
  79226. /**
  79227. * Increase the number of facets and hence vertices in a mesh
  79228. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  79229. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  79230. */
  79231. increaseVertices(numberPerEdge: number): void;
  79232. /**
  79233. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  79234. * This will undo any application of covertToFlatShadedMesh
  79235. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  79236. */
  79237. forceSharedVertices(): void;
  79238. /** @hidden */
  79239. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  79240. /** @hidden */
  79241. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  79242. /**
  79243. * Creates a new InstancedMesh object from the mesh model.
  79244. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  79245. * @param name defines the name of the new instance
  79246. * @returns a new InstancedMesh
  79247. */
  79248. createInstance(name: string): InstancedMesh;
  79249. /**
  79250. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  79251. * After this call, all the mesh instances have the same submeshes than the current mesh.
  79252. * @returns the current mesh
  79253. */
  79254. synchronizeInstances(): Mesh;
  79255. /**
  79256. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  79257. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  79258. * This should be used together with the simplification to avoid disappearing triangles.
  79259. * @param successCallback an optional success callback to be called after the optimization finished.
  79260. * @returns the current mesh
  79261. */
  79262. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  79263. /**
  79264. * Serialize current mesh
  79265. * @param serializationObject defines the object which will receive the serialization data
  79266. */
  79267. serialize(serializationObject: any): void;
  79268. /** @hidden */
  79269. _syncGeometryWithMorphTargetManager(): void;
  79270. /** @hidden */
  79271. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  79272. /**
  79273. * Returns a new Mesh object parsed from the source provided.
  79274. * @param parsedMesh is the source
  79275. * @param scene defines the hosting scene
  79276. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  79277. * @returns a new Mesh
  79278. */
  79279. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  79280. /**
  79281. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  79282. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  79283. * @param name defines the name of the mesh to create
  79284. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  79285. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  79286. * @param closePath creates a seam between the first and the last points of each path of the path array
  79287. * @param offset is taken in account only if the `pathArray` is containing a single path
  79288. * @param scene defines the hosting scene
  79289. * @param updatable defines if the mesh must be flagged as updatable
  79290. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79291. * @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)
  79292. * @returns a new Mesh
  79293. */
  79294. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  79295. /**
  79296. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  79297. * @param name defines the name of the mesh to create
  79298. * @param radius sets the radius size (float) of the polygon (default 0.5)
  79299. * @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
  79300. * @param scene defines the hosting scene
  79301. * @param updatable defines if the mesh must be flagged as updatable
  79302. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79303. * @returns a new Mesh
  79304. */
  79305. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  79306. /**
  79307. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  79308. * @param name defines the name of the mesh to create
  79309. * @param size sets the size (float) of each box side (default 1)
  79310. * @param scene defines the hosting scene
  79311. * @param updatable defines if the mesh must be flagged as updatable
  79312. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79313. * @returns a new Mesh
  79314. */
  79315. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  79316. /**
  79317. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  79318. * @param name defines the name of the mesh to create
  79319. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  79320. * @param diameter sets the diameter size (float) of the sphere (default 1)
  79321. * @param scene defines the hosting scene
  79322. * @param updatable defines if the mesh must be flagged as updatable
  79323. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79324. * @returns a new Mesh
  79325. */
  79326. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79327. /**
  79328. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  79329. * @param name defines the name of the mesh to create
  79330. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  79331. * @param diameterTop set the top cap diameter (floats, default 1)
  79332. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  79333. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  79334. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  79335. * @param scene defines the hosting scene
  79336. * @param updatable defines if the mesh must be flagged as updatable
  79337. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79338. * @returns a new Mesh
  79339. */
  79340. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  79341. /**
  79342. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  79343. * @param name defines the name of the mesh to create
  79344. * @param diameter sets the diameter size (float) of the torus (default 1)
  79345. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  79346. * @param tessellation sets the number of torus sides (postive integer, default 16)
  79347. * @param scene defines the hosting scene
  79348. * @param updatable defines if the mesh must be flagged as updatable
  79349. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79350. * @returns a new Mesh
  79351. */
  79352. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79353. /**
  79354. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  79355. * @param name defines the name of the mesh to create
  79356. * @param radius sets the global radius size (float) of the torus knot (default 2)
  79357. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  79358. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  79359. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  79360. * @param p the number of windings on X axis (positive integers, default 2)
  79361. * @param q the number of windings on Y axis (positive integers, default 3)
  79362. * @param scene defines the hosting scene
  79363. * @param updatable defines if the mesh must be flagged as updatable
  79364. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79365. * @returns a new Mesh
  79366. */
  79367. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79368. /**
  79369. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  79370. * @param name defines the name of the mesh to create
  79371. * @param points is an array successive Vector3
  79372. * @param scene defines the hosting scene
  79373. * @param updatable defines if the mesh must be flagged as updatable
  79374. * @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).
  79375. * @returns a new Mesh
  79376. */
  79377. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  79378. /**
  79379. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  79380. * @param name defines the name of the mesh to create
  79381. * @param points is an array successive Vector3
  79382. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  79383. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  79384. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  79385. * @param scene defines the hosting scene
  79386. * @param updatable defines if the mesh must be flagged as updatable
  79387. * @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)
  79388. * @returns a new Mesh
  79389. */
  79390. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  79391. /**
  79392. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  79393. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  79394. * 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.
  79395. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79396. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  79397. * Remember you can only change the shape positions, not their number when updating a polygon.
  79398. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  79399. * @param name defines the name of the mesh to create
  79400. * @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
  79401. * @param scene defines the hosting scene
  79402. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  79403. * @param updatable defines if the mesh must be flagged as updatable
  79404. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79405. * @param earcutInjection can be used to inject your own earcut reference
  79406. * @returns a new Mesh
  79407. */
  79408. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  79409. /**
  79410. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  79411. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  79412. * @param name defines the name of the mesh to create
  79413. * @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
  79414. * @param depth defines the height of extrusion
  79415. * @param scene defines the hosting scene
  79416. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  79417. * @param updatable defines if the mesh must be flagged as updatable
  79418. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79419. * @param earcutInjection can be used to inject your own earcut reference
  79420. * @returns a new Mesh
  79421. */
  79422. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  79423. /**
  79424. * Creates an extruded shape mesh.
  79425. * 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
  79426. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  79427. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  79428. * @param name defines the name of the mesh to create
  79429. * @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
  79430. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  79431. * @param scale is the value to scale the shape
  79432. * @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
  79433. * @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
  79434. * @param scene defines the hosting scene
  79435. * @param updatable defines if the mesh must be flagged as updatable
  79436. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79437. * @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)
  79438. * @returns a new Mesh
  79439. */
  79440. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  79441. /**
  79442. * Creates an custom extruded shape mesh.
  79443. * The custom extrusion is a parametric shape.
  79444. * It has no predefined shape. Its final shape will depend on the input parameters.
  79445. * Please consider using the same method from the MeshBuilder class instead
  79446. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  79447. * @param name defines the name of the mesh to create
  79448. * @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
  79449. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  79450. * @param scaleFunction is a custom Javascript function called on each path point
  79451. * @param rotationFunction is a custom Javascript function called on each path point
  79452. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  79453. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  79454. * @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
  79455. * @param scene defines the hosting scene
  79456. * @param updatable defines if the mesh must be flagged as updatable
  79457. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79458. * @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)
  79459. * @returns a new Mesh
  79460. */
  79461. 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;
  79462. /**
  79463. * Creates lathe mesh.
  79464. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  79465. * Please consider using the same method from the MeshBuilder class instead
  79466. * @param name defines the name of the mesh to create
  79467. * @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
  79468. * @param radius is the radius value of the lathe
  79469. * @param tessellation is the side number of the lathe.
  79470. * @param scene defines the hosting scene
  79471. * @param updatable defines if the mesh must be flagged as updatable
  79472. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79473. * @returns a new Mesh
  79474. */
  79475. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79476. /**
  79477. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  79478. * @param name defines the name of the mesh to create
  79479. * @param size sets the size (float) of both sides of the plane at once (default 1)
  79480. * @param scene defines the hosting scene
  79481. * @param updatable defines if the mesh must be flagged as updatable
  79482. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79483. * @returns a new Mesh
  79484. */
  79485. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  79486. /**
  79487. * Creates a ground mesh.
  79488. * Please consider using the same method from the MeshBuilder class instead
  79489. * @param name defines the name of the mesh to create
  79490. * @param width set the width of the ground
  79491. * @param height set the height of the ground
  79492. * @param subdivisions sets the number of subdivisions per side
  79493. * @param scene defines the hosting scene
  79494. * @param updatable defines if the mesh must be flagged as updatable
  79495. * @returns a new Mesh
  79496. */
  79497. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  79498. /**
  79499. * Creates a tiled ground mesh.
  79500. * Please consider using the same method from the MeshBuilder class instead
  79501. * @param name defines the name of the mesh to create
  79502. * @param xmin set the ground minimum X coordinate
  79503. * @param zmin set the ground minimum Y coordinate
  79504. * @param xmax set the ground maximum X coordinate
  79505. * @param zmax set the ground maximum Z coordinate
  79506. * @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
  79507. * @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
  79508. * @param scene defines the hosting scene
  79509. * @param updatable defines if the mesh must be flagged as updatable
  79510. * @returns a new Mesh
  79511. */
  79512. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  79513. w: number;
  79514. h: number;
  79515. }, precision: {
  79516. w: number;
  79517. h: number;
  79518. }, scene: Scene, updatable?: boolean): Mesh;
  79519. /**
  79520. * Creates a ground mesh from a height map.
  79521. * Please consider using the same method from the MeshBuilder class instead
  79522. * @see http://doc.babylonjs.com/babylon101/height_map
  79523. * @param name defines the name of the mesh to create
  79524. * @param url sets the URL of the height map image resource
  79525. * @param width set the ground width size
  79526. * @param height set the ground height size
  79527. * @param subdivisions sets the number of subdivision per side
  79528. * @param minHeight is the minimum altitude on the ground
  79529. * @param maxHeight is the maximum altitude on the ground
  79530. * @param scene defines the hosting scene
  79531. * @param updatable defines if the mesh must be flagged as updatable
  79532. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  79533. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  79534. * @returns a new Mesh
  79535. */
  79536. 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;
  79537. /**
  79538. * Creates a tube mesh.
  79539. * The tube is a parametric shape.
  79540. * It has no predefined shape. Its final shape will depend on the input parameters.
  79541. * Please consider using the same method from the MeshBuilder class instead
  79542. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  79543. * @param name defines the name of the mesh to create
  79544. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  79545. * @param radius sets the tube radius size
  79546. * @param tessellation is the number of sides on the tubular surface
  79547. * @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
  79548. * @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
  79549. * @param scene defines the hosting scene
  79550. * @param updatable defines if the mesh must be flagged as updatable
  79551. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  79552. * @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)
  79553. * @returns a new Mesh
  79554. */
  79555. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  79556. (i: number, distance: number): number;
  79557. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  79558. /**
  79559. * Creates a polyhedron mesh.
  79560. * Please consider using the same method from the MeshBuilder class instead.
  79561. * * 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
  79562. * * The parameter `size` (positive float, default 1) sets the polygon size
  79563. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  79564. * * 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`
  79565. * * 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
  79566. * * 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)`)
  79567. * * 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
  79568. * * 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
  79569. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79570. * * If you create a double-sided mesh, you can choose what parts of 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
  79571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79572. * @param name defines the name of the mesh to create
  79573. * @param options defines the options used to create the mesh
  79574. * @param scene defines the hosting scene
  79575. * @returns a new Mesh
  79576. */
  79577. static CreatePolyhedron(name: string, options: {
  79578. type?: number;
  79579. size?: number;
  79580. sizeX?: number;
  79581. sizeY?: number;
  79582. sizeZ?: number;
  79583. custom?: any;
  79584. faceUV?: Vector4[];
  79585. faceColors?: Color4[];
  79586. updatable?: boolean;
  79587. sideOrientation?: number;
  79588. }, scene: Scene): Mesh;
  79589. /**
  79590. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  79591. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  79592. * * 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`)
  79593. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  79594. * * 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
  79595. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  79596. * * If you create a double-sided mesh, you can choose what parts of 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
  79597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79598. * @param name defines the name of the mesh
  79599. * @param options defines the options used to create the mesh
  79600. * @param scene defines the hosting scene
  79601. * @returns a new Mesh
  79602. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  79603. */
  79604. static CreateIcoSphere(name: string, options: {
  79605. radius?: number;
  79606. flat?: boolean;
  79607. subdivisions?: number;
  79608. sideOrientation?: number;
  79609. updatable?: boolean;
  79610. }, scene: Scene): Mesh;
  79611. /**
  79612. * Creates a decal mesh.
  79613. * Please consider using the same method from the MeshBuilder class instead.
  79614. * A decal is a mesh usually applied as a model onto the surface of another mesh
  79615. * @param name defines the name of the mesh
  79616. * @param sourceMesh defines the mesh receiving the decal
  79617. * @param position sets the position of the decal in world coordinates
  79618. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  79619. * @param size sets the decal scaling
  79620. * @param angle sets the angle to rotate the decal
  79621. * @returns a new Mesh
  79622. */
  79623. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  79624. /**
  79625. * Prepare internal position array for software CPU skinning
  79626. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  79627. */
  79628. setPositionsForCPUSkinning(): Float32Array;
  79629. /**
  79630. * Prepare internal normal array for software CPU skinning
  79631. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  79632. */
  79633. setNormalsForCPUSkinning(): Float32Array;
  79634. /**
  79635. * Updates the vertex buffer by applying transformation from the bones
  79636. * @param skeleton defines the skeleton to apply to current mesh
  79637. * @returns the current mesh
  79638. */
  79639. applySkeleton(skeleton: Skeleton): Mesh;
  79640. /**
  79641. * 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
  79642. * @param meshes defines the list of meshes to scan
  79643. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  79644. */
  79645. static MinMax(meshes: AbstractMesh[]): {
  79646. min: Vector3;
  79647. max: Vector3;
  79648. };
  79649. /**
  79650. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  79651. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  79652. * @returns a vector3
  79653. */
  79654. static Center(meshesOrMinMaxVector: {
  79655. min: Vector3;
  79656. max: Vector3;
  79657. } | AbstractMesh[]): Vector3;
  79658. /**
  79659. * Merge the array of meshes into a single mesh for performance reasons.
  79660. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  79661. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  79662. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  79663. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  79664. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  79665. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  79666. * @returns a new mesh
  79667. */
  79668. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  79669. /** @hidden */
  79670. addInstance(instance: InstancedMesh): void;
  79671. /** @hidden */
  79672. removeInstance(instance: InstancedMesh): void;
  79673. }
  79674. }
  79675. declare module BABYLON {
  79676. /**
  79677. * Base class for the main features of a material in Babylon.js
  79678. */
  79679. export class Material implements IAnimatable {
  79680. /**
  79681. * Returns the triangle fill mode
  79682. */
  79683. static readonly TriangleFillMode: number;
  79684. /**
  79685. * Returns the wireframe mode
  79686. */
  79687. static readonly WireFrameFillMode: number;
  79688. /**
  79689. * Returns the point fill mode
  79690. */
  79691. static readonly PointFillMode: number;
  79692. /**
  79693. * Returns the point list draw mode
  79694. */
  79695. static readonly PointListDrawMode: number;
  79696. /**
  79697. * Returns the line list draw mode
  79698. */
  79699. static readonly LineListDrawMode: number;
  79700. /**
  79701. * Returns the line loop draw mode
  79702. */
  79703. static readonly LineLoopDrawMode: number;
  79704. /**
  79705. * Returns the line strip draw mode
  79706. */
  79707. static readonly LineStripDrawMode: number;
  79708. /**
  79709. * Returns the triangle strip draw mode
  79710. */
  79711. static readonly TriangleStripDrawMode: number;
  79712. /**
  79713. * Returns the triangle fan draw mode
  79714. */
  79715. static readonly TriangleFanDrawMode: number;
  79716. /**
  79717. * Stores the clock-wise side orientation
  79718. */
  79719. static readonly ClockWiseSideOrientation: number;
  79720. /**
  79721. * Stores the counter clock-wise side orientation
  79722. */
  79723. static readonly CounterClockWiseSideOrientation: number;
  79724. /**
  79725. * The dirty texture flag value
  79726. */
  79727. static readonly TextureDirtyFlag: number;
  79728. /**
  79729. * The dirty light flag value
  79730. */
  79731. static readonly LightDirtyFlag: number;
  79732. /**
  79733. * The dirty fresnel flag value
  79734. */
  79735. static readonly FresnelDirtyFlag: number;
  79736. /**
  79737. * The dirty attribute flag value
  79738. */
  79739. static readonly AttributesDirtyFlag: number;
  79740. /**
  79741. * The dirty misc flag value
  79742. */
  79743. static readonly MiscDirtyFlag: number;
  79744. /**
  79745. * The all dirty flag value
  79746. */
  79747. static readonly AllDirtyFlag: number;
  79748. /**
  79749. * The ID of the material
  79750. */
  79751. id: string;
  79752. /**
  79753. * Gets or sets the unique id of the material
  79754. */
  79755. uniqueId: number;
  79756. /**
  79757. * The name of the material
  79758. */
  79759. name: string;
  79760. /**
  79761. * Gets or sets user defined metadata
  79762. */
  79763. metadata: any;
  79764. /**
  79765. * For internal use only. Please do not use.
  79766. */
  79767. reservedDataStore: any;
  79768. /**
  79769. * Specifies if the ready state should be checked on each call
  79770. */
  79771. checkReadyOnEveryCall: boolean;
  79772. /**
  79773. * Specifies if the ready state should be checked once
  79774. */
  79775. checkReadyOnlyOnce: boolean;
  79776. /**
  79777. * The state of the material
  79778. */
  79779. state: string;
  79780. /**
  79781. * The alpha value of the material
  79782. */
  79783. protected _alpha: number;
  79784. /**
  79785. * List of inspectable custom properties (used by the Inspector)
  79786. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79787. */
  79788. inspectableCustomProperties: IInspectable[];
  79789. /**
  79790. * Sets the alpha value of the material
  79791. */
  79792. /**
  79793. * Gets the alpha value of the material
  79794. */
  79795. alpha: number;
  79796. /**
  79797. * Specifies if back face culling is enabled
  79798. */
  79799. protected _backFaceCulling: boolean;
  79800. /**
  79801. * Sets the back-face culling state
  79802. */
  79803. /**
  79804. * Gets the back-face culling state
  79805. */
  79806. backFaceCulling: boolean;
  79807. /**
  79808. * Stores the value for side orientation
  79809. */
  79810. sideOrientation: number;
  79811. /**
  79812. * Callback triggered when the material is compiled
  79813. */
  79814. onCompiled: (effect: Effect) => void;
  79815. /**
  79816. * Callback triggered when an error occurs
  79817. */
  79818. onError: (effect: Effect, errors: string) => void;
  79819. /**
  79820. * Callback triggered to get the render target textures
  79821. */
  79822. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  79823. /**
  79824. * Gets a boolean indicating that current material needs to register RTT
  79825. */
  79826. readonly hasRenderTargetTextures: boolean;
  79827. /**
  79828. * Specifies if the material should be serialized
  79829. */
  79830. doNotSerialize: boolean;
  79831. /**
  79832. * @hidden
  79833. */
  79834. _storeEffectOnSubMeshes: boolean;
  79835. /**
  79836. * Stores the animations for the material
  79837. */
  79838. animations: Array<Animation>;
  79839. /**
  79840. * An event triggered when the material is disposed
  79841. */
  79842. onDisposeObservable: Observable<Material>;
  79843. /**
  79844. * An observer which watches for dispose events
  79845. */
  79846. private _onDisposeObserver;
  79847. private _onUnBindObservable;
  79848. /**
  79849. * Called during a dispose event
  79850. */
  79851. onDispose: () => void;
  79852. private _onBindObservable;
  79853. /**
  79854. * An event triggered when the material is bound
  79855. */
  79856. readonly onBindObservable: Observable<AbstractMesh>;
  79857. /**
  79858. * An observer which watches for bind events
  79859. */
  79860. private _onBindObserver;
  79861. /**
  79862. * Called during a bind event
  79863. */
  79864. onBind: (Mesh: AbstractMesh) => void;
  79865. /**
  79866. * An event triggered when the material is unbound
  79867. */
  79868. readonly onUnBindObservable: Observable<Material>;
  79869. /**
  79870. * Stores the value of the alpha mode
  79871. */
  79872. private _alphaMode;
  79873. /**
  79874. * Sets the value of the alpha mode.
  79875. *
  79876. * | Value | Type | Description |
  79877. * | --- | --- | --- |
  79878. * | 0 | ALPHA_DISABLE | |
  79879. * | 1 | ALPHA_ADD | |
  79880. * | 2 | ALPHA_COMBINE | |
  79881. * | 3 | ALPHA_SUBTRACT | |
  79882. * | 4 | ALPHA_MULTIPLY | |
  79883. * | 5 | ALPHA_MAXIMIZED | |
  79884. * | 6 | ALPHA_ONEONE | |
  79885. * | 7 | ALPHA_PREMULTIPLIED | |
  79886. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  79887. * | 9 | ALPHA_INTERPOLATE | |
  79888. * | 10 | ALPHA_SCREENMODE | |
  79889. *
  79890. */
  79891. /**
  79892. * Gets the value of the alpha mode
  79893. */
  79894. alphaMode: number;
  79895. /**
  79896. * Stores the state of the need depth pre-pass value
  79897. */
  79898. private _needDepthPrePass;
  79899. /**
  79900. * Sets the need depth pre-pass value
  79901. */
  79902. /**
  79903. * Gets the depth pre-pass value
  79904. */
  79905. needDepthPrePass: boolean;
  79906. /**
  79907. * Specifies if depth writing should be disabled
  79908. */
  79909. disableDepthWrite: boolean;
  79910. /**
  79911. * Specifies if depth writing should be forced
  79912. */
  79913. forceDepthWrite: boolean;
  79914. /**
  79915. * Specifies if there should be a separate pass for culling
  79916. */
  79917. separateCullingPass: boolean;
  79918. /**
  79919. * Stores the state specifing if fog should be enabled
  79920. */
  79921. private _fogEnabled;
  79922. /**
  79923. * Sets the state for enabling fog
  79924. */
  79925. /**
  79926. * Gets the value of the fog enabled state
  79927. */
  79928. fogEnabled: boolean;
  79929. /**
  79930. * Stores the size of points
  79931. */
  79932. pointSize: number;
  79933. /**
  79934. * Stores the z offset value
  79935. */
  79936. zOffset: number;
  79937. /**
  79938. * Gets a value specifying if wireframe mode is enabled
  79939. */
  79940. /**
  79941. * Sets the state of wireframe mode
  79942. */
  79943. wireframe: boolean;
  79944. /**
  79945. * Gets the value specifying if point clouds are enabled
  79946. */
  79947. /**
  79948. * Sets the state of point cloud mode
  79949. */
  79950. pointsCloud: boolean;
  79951. /**
  79952. * Gets the material fill mode
  79953. */
  79954. /**
  79955. * Sets the material fill mode
  79956. */
  79957. fillMode: number;
  79958. /**
  79959. * @hidden
  79960. * Stores the effects for the material
  79961. */
  79962. _effect: Nullable<Effect>;
  79963. /**
  79964. * @hidden
  79965. * Specifies if the material was previously ready
  79966. */
  79967. _wasPreviouslyReady: boolean;
  79968. /**
  79969. * Specifies if uniform buffers should be used
  79970. */
  79971. private _useUBO;
  79972. /**
  79973. * Stores a reference to the scene
  79974. */
  79975. private _scene;
  79976. /**
  79977. * Stores the fill mode state
  79978. */
  79979. private _fillMode;
  79980. /**
  79981. * Specifies if the depth write state should be cached
  79982. */
  79983. private _cachedDepthWriteState;
  79984. /**
  79985. * Stores the uniform buffer
  79986. */
  79987. protected _uniformBuffer: UniformBuffer;
  79988. /** @hidden */
  79989. _indexInSceneMaterialArray: number;
  79990. /** @hidden */
  79991. meshMap: Nullable<{
  79992. [id: string]: AbstractMesh | undefined;
  79993. }>;
  79994. /**
  79995. * Creates a material instance
  79996. * @param name defines the name of the material
  79997. * @param scene defines the scene to reference
  79998. * @param doNotAdd specifies if the material should be added to the scene
  79999. */
  80000. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  80001. /**
  80002. * Returns a string representation of the current material
  80003. * @param fullDetails defines a boolean indicating which levels of logging is desired
  80004. * @returns a string with material information
  80005. */
  80006. toString(fullDetails?: boolean): string;
  80007. /**
  80008. * Gets the class name of the material
  80009. * @returns a string with the class name of the material
  80010. */
  80011. getClassName(): string;
  80012. /**
  80013. * Specifies if updates for the material been locked
  80014. */
  80015. readonly isFrozen: boolean;
  80016. /**
  80017. * Locks updates for the material
  80018. */
  80019. freeze(): void;
  80020. /**
  80021. * Unlocks updates for the material
  80022. */
  80023. unfreeze(): void;
  80024. /**
  80025. * Specifies if the material is ready to be used
  80026. * @param mesh defines the mesh to check
  80027. * @param useInstances specifies if instances should be used
  80028. * @returns a boolean indicating if the material is ready to be used
  80029. */
  80030. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  80031. /**
  80032. * Specifies that the submesh is ready to be used
  80033. * @param mesh defines the mesh to check
  80034. * @param subMesh defines which submesh to check
  80035. * @param useInstances specifies that instances should be used
  80036. * @returns a boolean indicating that the submesh is ready or not
  80037. */
  80038. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  80039. /**
  80040. * Returns the material effect
  80041. * @returns the effect associated with the material
  80042. */
  80043. getEffect(): Nullable<Effect>;
  80044. /**
  80045. * Returns the current scene
  80046. * @returns a Scene
  80047. */
  80048. getScene(): Scene;
  80049. /**
  80050. * Specifies if the material will require alpha blending
  80051. * @returns a boolean specifying if alpha blending is needed
  80052. */
  80053. needAlphaBlending(): boolean;
  80054. /**
  80055. * Specifies if the mesh will require alpha blending
  80056. * @param mesh defines the mesh to check
  80057. * @returns a boolean specifying if alpha blending is needed for the mesh
  80058. */
  80059. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  80060. /**
  80061. * Specifies if this material should be rendered in alpha test mode
  80062. * @returns a boolean specifying if an alpha test is needed.
  80063. */
  80064. needAlphaTesting(): boolean;
  80065. /**
  80066. * Gets the texture used for the alpha test
  80067. * @returns the texture to use for alpha testing
  80068. */
  80069. getAlphaTestTexture(): Nullable<BaseTexture>;
  80070. /**
  80071. * Marks the material to indicate that it needs to be re-calculated
  80072. */
  80073. markDirty(): void;
  80074. /** @hidden */
  80075. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  80076. /**
  80077. * Binds the material to the mesh
  80078. * @param world defines the world transformation matrix
  80079. * @param mesh defines the mesh to bind the material to
  80080. */
  80081. bind(world: Matrix, mesh?: Mesh): void;
  80082. /**
  80083. * Binds the submesh to the material
  80084. * @param world defines the world transformation matrix
  80085. * @param mesh defines the mesh containing the submesh
  80086. * @param subMesh defines the submesh to bind the material to
  80087. */
  80088. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  80089. /**
  80090. * Binds the world matrix to the material
  80091. * @param world defines the world transformation matrix
  80092. */
  80093. bindOnlyWorldMatrix(world: Matrix): void;
  80094. /**
  80095. * Binds the scene's uniform buffer to the effect.
  80096. * @param effect defines the effect to bind to the scene uniform buffer
  80097. * @param sceneUbo defines the uniform buffer storing scene data
  80098. */
  80099. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  80100. /**
  80101. * Binds the view matrix to the effect
  80102. * @param effect defines the effect to bind the view matrix to
  80103. */
  80104. bindView(effect: Effect): void;
  80105. /**
  80106. * Binds the view projection matrix to the effect
  80107. * @param effect defines the effect to bind the view projection matrix to
  80108. */
  80109. bindViewProjection(effect: Effect): void;
  80110. /**
  80111. * Specifies if material alpha testing should be turned on for the mesh
  80112. * @param mesh defines the mesh to check
  80113. */
  80114. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  80115. /**
  80116. * Processes to execute after binding the material to a mesh
  80117. * @param mesh defines the rendered mesh
  80118. */
  80119. protected _afterBind(mesh?: Mesh): void;
  80120. /**
  80121. * Unbinds the material from the mesh
  80122. */
  80123. unbind(): void;
  80124. /**
  80125. * Gets the active textures from the material
  80126. * @returns an array of textures
  80127. */
  80128. getActiveTextures(): BaseTexture[];
  80129. /**
  80130. * Specifies if the material uses a texture
  80131. * @param texture defines the texture to check against the material
  80132. * @returns a boolean specifying if the material uses the texture
  80133. */
  80134. hasTexture(texture: BaseTexture): boolean;
  80135. /**
  80136. * Makes a duplicate of the material, and gives it a new name
  80137. * @param name defines the new name for the duplicated material
  80138. * @returns the cloned material
  80139. */
  80140. clone(name: string): Nullable<Material>;
  80141. /**
  80142. * Gets the meshes bound to the material
  80143. * @returns an array of meshes bound to the material
  80144. */
  80145. getBindedMeshes(): AbstractMesh[];
  80146. /**
  80147. * Force shader compilation
  80148. * @param mesh defines the mesh associated with this material
  80149. * @param onCompiled defines a function to execute once the material is compiled
  80150. * @param options defines the options to configure the compilation
  80151. */
  80152. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  80153. clipPlane: boolean;
  80154. }>): void;
  80155. /**
  80156. * Force shader compilation
  80157. * @param mesh defines the mesh that will use this material
  80158. * @param options defines additional options for compiling the shaders
  80159. * @returns a promise that resolves when the compilation completes
  80160. */
  80161. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  80162. clipPlane: boolean;
  80163. }>): Promise<void>;
  80164. private static readonly _ImageProcessingDirtyCallBack;
  80165. private static readonly _TextureDirtyCallBack;
  80166. private static readonly _FresnelDirtyCallBack;
  80167. private static readonly _MiscDirtyCallBack;
  80168. private static readonly _LightsDirtyCallBack;
  80169. private static readonly _AttributeDirtyCallBack;
  80170. private static _FresnelAndMiscDirtyCallBack;
  80171. private static _TextureAndMiscDirtyCallBack;
  80172. private static readonly _DirtyCallbackArray;
  80173. private static readonly _RunDirtyCallBacks;
  80174. /**
  80175. * Marks a define in the material to indicate that it needs to be re-computed
  80176. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  80177. */
  80178. markAsDirty(flag: number): void;
  80179. /**
  80180. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  80181. * @param func defines a function which checks material defines against the submeshes
  80182. */
  80183. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  80184. /**
  80185. * Indicates that image processing needs to be re-calculated for all submeshes
  80186. */
  80187. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  80188. /**
  80189. * Indicates that textures need to be re-calculated for all submeshes
  80190. */
  80191. protected _markAllSubMeshesAsTexturesDirty(): void;
  80192. /**
  80193. * Indicates that fresnel needs to be re-calculated for all submeshes
  80194. */
  80195. protected _markAllSubMeshesAsFresnelDirty(): void;
  80196. /**
  80197. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  80198. */
  80199. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  80200. /**
  80201. * Indicates that lights need to be re-calculated for all submeshes
  80202. */
  80203. protected _markAllSubMeshesAsLightsDirty(): void;
  80204. /**
  80205. * Indicates that attributes need to be re-calculated for all submeshes
  80206. */
  80207. protected _markAllSubMeshesAsAttributesDirty(): void;
  80208. /**
  80209. * Indicates that misc needs to be re-calculated for all submeshes
  80210. */
  80211. protected _markAllSubMeshesAsMiscDirty(): void;
  80212. /**
  80213. * Indicates that textures and misc need to be re-calculated for all submeshes
  80214. */
  80215. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  80216. /**
  80217. * Disposes the material
  80218. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  80219. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  80220. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  80221. */
  80222. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  80223. /** @hidden */
  80224. private releaseVertexArrayObject;
  80225. /**
  80226. * Serializes this material
  80227. * @returns the serialized material object
  80228. */
  80229. serialize(): any;
  80230. /**
  80231. * Creates a material from parsed material data
  80232. * @param parsedMaterial defines parsed material data
  80233. * @param scene defines the hosting scene
  80234. * @param rootUrl defines the root URL to use to load textures
  80235. * @returns a new material
  80236. */
  80237. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  80238. }
  80239. }
  80240. declare module BABYLON {
  80241. /**
  80242. * Base class for submeshes
  80243. */
  80244. export class BaseSubMesh {
  80245. /** @hidden */
  80246. _materialDefines: Nullable<MaterialDefines>;
  80247. /** @hidden */
  80248. _materialEffect: Nullable<Effect>;
  80249. /**
  80250. * Gets associated effect
  80251. */
  80252. readonly effect: Nullable<Effect>;
  80253. /**
  80254. * Sets associated effect (effect used to render this submesh)
  80255. * @param effect defines the effect to associate with
  80256. * @param defines defines the set of defines used to compile this effect
  80257. */
  80258. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  80259. }
  80260. /**
  80261. * Defines a subdivision inside a mesh
  80262. */
  80263. export class SubMesh extends BaseSubMesh implements ICullable {
  80264. /** the material index to use */
  80265. materialIndex: number;
  80266. /** vertex index start */
  80267. verticesStart: number;
  80268. /** vertices count */
  80269. verticesCount: number;
  80270. /** index start */
  80271. indexStart: number;
  80272. /** indices count */
  80273. indexCount: number;
  80274. /** @hidden */
  80275. _linesIndexCount: number;
  80276. private _mesh;
  80277. private _renderingMesh;
  80278. private _boundingInfo;
  80279. private _linesIndexBuffer;
  80280. /** @hidden */
  80281. _lastColliderWorldVertices: Nullable<Vector3[]>;
  80282. /** @hidden */
  80283. _trianglePlanes: Plane[];
  80284. /** @hidden */
  80285. _lastColliderTransformMatrix: Matrix;
  80286. /** @hidden */
  80287. _renderId: number;
  80288. /** @hidden */
  80289. _alphaIndex: number;
  80290. /** @hidden */
  80291. _distanceToCamera: number;
  80292. /** @hidden */
  80293. _id: number;
  80294. private _currentMaterial;
  80295. /**
  80296. * Add a new submesh to a mesh
  80297. * @param materialIndex defines the material index to use
  80298. * @param verticesStart defines vertex index start
  80299. * @param verticesCount defines vertices count
  80300. * @param indexStart defines index start
  80301. * @param indexCount defines indices count
  80302. * @param mesh defines the parent mesh
  80303. * @param renderingMesh defines an optional rendering mesh
  80304. * @param createBoundingBox defines if bounding box should be created for this submesh
  80305. * @returns the new submesh
  80306. */
  80307. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  80308. /**
  80309. * Creates a new submesh
  80310. * @param materialIndex defines the material index to use
  80311. * @param verticesStart defines vertex index start
  80312. * @param verticesCount defines vertices count
  80313. * @param indexStart defines index start
  80314. * @param indexCount defines indices count
  80315. * @param mesh defines the parent mesh
  80316. * @param renderingMesh defines an optional rendering mesh
  80317. * @param createBoundingBox defines if bounding box should be created for this submesh
  80318. */
  80319. constructor(
  80320. /** the material index to use */
  80321. materialIndex: number,
  80322. /** vertex index start */
  80323. verticesStart: number,
  80324. /** vertices count */
  80325. verticesCount: number,
  80326. /** index start */
  80327. indexStart: number,
  80328. /** indices count */
  80329. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  80330. /**
  80331. * Returns true if this submesh covers the entire parent mesh
  80332. * @ignorenaming
  80333. */
  80334. readonly IsGlobal: boolean;
  80335. /**
  80336. * Returns the submesh BoudingInfo object
  80337. * @returns current bounding info (or mesh's one if the submesh is global)
  80338. */
  80339. getBoundingInfo(): BoundingInfo;
  80340. /**
  80341. * Sets the submesh BoundingInfo
  80342. * @param boundingInfo defines the new bounding info to use
  80343. * @returns the SubMesh
  80344. */
  80345. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  80346. /**
  80347. * Returns the mesh of the current submesh
  80348. * @return the parent mesh
  80349. */
  80350. getMesh(): AbstractMesh;
  80351. /**
  80352. * Returns the rendering mesh of the submesh
  80353. * @returns the rendering mesh (could be different from parent mesh)
  80354. */
  80355. getRenderingMesh(): Mesh;
  80356. /**
  80357. * Returns the submesh material
  80358. * @returns null or the current material
  80359. */
  80360. getMaterial(): Nullable<Material>;
  80361. /**
  80362. * Sets a new updated BoundingInfo object to the submesh
  80363. * @returns the SubMesh
  80364. */
  80365. refreshBoundingInfo(): SubMesh;
  80366. /** @hidden */
  80367. _checkCollision(collider: Collider): boolean;
  80368. /**
  80369. * Updates the submesh BoundingInfo
  80370. * @param world defines the world matrix to use to update the bounding info
  80371. * @returns the submesh
  80372. */
  80373. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  80374. /**
  80375. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  80376. * @param frustumPlanes defines the frustum planes
  80377. * @returns true if the submesh is intersecting with the frustum
  80378. */
  80379. isInFrustum(frustumPlanes: Plane[]): boolean;
  80380. /**
  80381. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  80382. * @param frustumPlanes defines the frustum planes
  80383. * @returns true if the submesh is inside the frustum
  80384. */
  80385. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80386. /**
  80387. * Renders the submesh
  80388. * @param enableAlphaMode defines if alpha needs to be used
  80389. * @returns the submesh
  80390. */
  80391. render(enableAlphaMode: boolean): SubMesh;
  80392. /**
  80393. * @hidden
  80394. */
  80395. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  80396. /**
  80397. * Checks if the submesh intersects with a ray
  80398. * @param ray defines the ray to test
  80399. * @returns true is the passed ray intersects the submesh bounding box
  80400. */
  80401. canIntersects(ray: Ray): boolean;
  80402. /**
  80403. * Intersects current submesh with a ray
  80404. * @param ray defines the ray to test
  80405. * @param positions defines mesh's positions array
  80406. * @param indices defines mesh's indices array
  80407. * @param fastCheck defines if only bounding info should be used
  80408. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  80409. * @returns intersection info or null if no intersection
  80410. */
  80411. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  80412. /** @hidden */
  80413. private _intersectLines;
  80414. /** @hidden */
  80415. private _intersectTriangles;
  80416. /** @hidden */
  80417. _rebuild(): void;
  80418. /**
  80419. * Creates a new submesh from the passed mesh
  80420. * @param newMesh defines the new hosting mesh
  80421. * @param newRenderingMesh defines an optional rendering mesh
  80422. * @returns the new submesh
  80423. */
  80424. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  80425. /**
  80426. * Release associated resources
  80427. */
  80428. dispose(): void;
  80429. /**
  80430. * Gets the class name
  80431. * @returns the string "SubMesh".
  80432. */
  80433. getClassName(): string;
  80434. /**
  80435. * Creates a new submesh from indices data
  80436. * @param materialIndex the index of the main mesh material
  80437. * @param startIndex the index where to start the copy in the mesh indices array
  80438. * @param indexCount the number of indices to copy then from the startIndex
  80439. * @param mesh the main mesh to create the submesh from
  80440. * @param renderingMesh the optional rendering mesh
  80441. * @returns a new submesh
  80442. */
  80443. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  80444. }
  80445. }
  80446. declare module BABYLON {
  80447. /**
  80448. * Class used to store geometry data (vertex buffers + index buffer)
  80449. */
  80450. export class Geometry implements IGetSetVerticesData {
  80451. /**
  80452. * Gets or sets the ID of the geometry
  80453. */
  80454. id: string;
  80455. /**
  80456. * Gets or sets the unique ID of the geometry
  80457. */
  80458. uniqueId: number;
  80459. /**
  80460. * Gets the delay loading state of the geometry (none by default which means not delayed)
  80461. */
  80462. delayLoadState: number;
  80463. /**
  80464. * Gets the file containing the data to load when running in delay load state
  80465. */
  80466. delayLoadingFile: Nullable<string>;
  80467. /**
  80468. * Callback called when the geometry is updated
  80469. */
  80470. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  80471. private _scene;
  80472. private _engine;
  80473. private _meshes;
  80474. private _totalVertices;
  80475. /** @hidden */
  80476. _indices: IndicesArray;
  80477. /** @hidden */
  80478. _vertexBuffers: {
  80479. [key: string]: VertexBuffer;
  80480. };
  80481. private _isDisposed;
  80482. private _extend;
  80483. private _boundingBias;
  80484. /** @hidden */
  80485. _delayInfo: Array<string>;
  80486. private _indexBuffer;
  80487. private _indexBufferIsUpdatable;
  80488. /** @hidden */
  80489. _boundingInfo: Nullable<BoundingInfo>;
  80490. /** @hidden */
  80491. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  80492. /** @hidden */
  80493. _softwareSkinningFrameId: number;
  80494. private _vertexArrayObjects;
  80495. private _updatable;
  80496. /** @hidden */
  80497. _positions: Nullable<Vector3[]>;
  80498. /**
  80499. * 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
  80500. */
  80501. /**
  80502. * 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
  80503. */
  80504. boundingBias: Vector2;
  80505. /**
  80506. * Static function used to attach a new empty geometry to a mesh
  80507. * @param mesh defines the mesh to attach the geometry to
  80508. * @returns the new Geometry
  80509. */
  80510. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  80511. /**
  80512. * Creates a new geometry
  80513. * @param id defines the unique ID
  80514. * @param scene defines the hosting scene
  80515. * @param vertexData defines the VertexData used to get geometry data
  80516. * @param updatable defines if geometry must be updatable (false by default)
  80517. * @param mesh defines the mesh that will be associated with the geometry
  80518. */
  80519. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  80520. /**
  80521. * Gets the current extend of the geometry
  80522. */
  80523. readonly extend: {
  80524. minimum: Vector3;
  80525. maximum: Vector3;
  80526. };
  80527. /**
  80528. * Gets the hosting scene
  80529. * @returns the hosting Scene
  80530. */
  80531. getScene(): Scene;
  80532. /**
  80533. * Gets the hosting engine
  80534. * @returns the hosting Engine
  80535. */
  80536. getEngine(): Engine;
  80537. /**
  80538. * Defines if the geometry is ready to use
  80539. * @returns true if the geometry is ready to be used
  80540. */
  80541. isReady(): boolean;
  80542. /**
  80543. * Gets a value indicating that the geometry should not be serialized
  80544. */
  80545. readonly doNotSerialize: boolean;
  80546. /** @hidden */
  80547. _rebuild(): void;
  80548. /**
  80549. * Affects all geometry data in one call
  80550. * @param vertexData defines the geometry data
  80551. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  80552. */
  80553. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  80554. /**
  80555. * Set specific vertex data
  80556. * @param kind defines the data kind (Position, normal, etc...)
  80557. * @param data defines the vertex data to use
  80558. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  80559. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  80560. */
  80561. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  80562. /**
  80563. * Removes a specific vertex data
  80564. * @param kind defines the data kind (Position, normal, etc...)
  80565. */
  80566. removeVerticesData(kind: string): void;
  80567. /**
  80568. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  80569. * @param buffer defines the vertex buffer to use
  80570. * @param totalVertices defines the total number of vertices for position kind (could be null)
  80571. */
  80572. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  80573. /**
  80574. * Update a specific vertex buffer
  80575. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  80576. * It will do nothing if the buffer is not updatable
  80577. * @param kind defines the data kind (Position, normal, etc...)
  80578. * @param data defines the data to use
  80579. * @param offset defines the offset in the target buffer where to store the data
  80580. * @param useBytes set to true if the offset is in bytes
  80581. */
  80582. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  80583. /**
  80584. * Update a specific vertex buffer
  80585. * This function will create a new buffer if the current one is not updatable
  80586. * @param kind defines the data kind (Position, normal, etc...)
  80587. * @param data defines the data to use
  80588. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  80589. */
  80590. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  80591. private _updateBoundingInfo;
  80592. /** @hidden */
  80593. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  80594. /**
  80595. * Gets total number of vertices
  80596. * @returns the total number of vertices
  80597. */
  80598. getTotalVertices(): number;
  80599. /**
  80600. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  80601. * @param kind defines the data kind (Position, normal, etc...)
  80602. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  80603. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80604. * @returns a float array containing vertex data
  80605. */
  80606. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  80607. /**
  80608. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  80609. * @param kind defines the data kind (Position, normal, etc...)
  80610. * @returns true if the vertex buffer with the specified kind is updatable
  80611. */
  80612. isVertexBufferUpdatable(kind: string): boolean;
  80613. /**
  80614. * Gets a specific vertex buffer
  80615. * @param kind defines the data kind (Position, normal, etc...)
  80616. * @returns a VertexBuffer
  80617. */
  80618. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  80619. /**
  80620. * Returns all vertex buffers
  80621. * @return an object holding all vertex buffers indexed by kind
  80622. */
  80623. getVertexBuffers(): Nullable<{
  80624. [key: string]: VertexBuffer;
  80625. }>;
  80626. /**
  80627. * Gets a boolean indicating if specific vertex buffer is present
  80628. * @param kind defines the data kind (Position, normal, etc...)
  80629. * @returns true if data is present
  80630. */
  80631. isVerticesDataPresent(kind: string): boolean;
  80632. /**
  80633. * Gets a list of all attached data kinds (Position, normal, etc...)
  80634. * @returns a list of string containing all kinds
  80635. */
  80636. getVerticesDataKinds(): string[];
  80637. /**
  80638. * Update index buffer
  80639. * @param indices defines the indices to store in the index buffer
  80640. * @param offset defines the offset in the target buffer where to store the data
  80641. * @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)
  80642. */
  80643. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  80644. /**
  80645. * Creates a new index buffer
  80646. * @param indices defines the indices to store in the index buffer
  80647. * @param totalVertices defines the total number of vertices (could be null)
  80648. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  80649. */
  80650. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  80651. /**
  80652. * Return the total number of indices
  80653. * @returns the total number of indices
  80654. */
  80655. getTotalIndices(): number;
  80656. /**
  80657. * Gets the index buffer array
  80658. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  80659. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80660. * @returns the index buffer array
  80661. */
  80662. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  80663. /**
  80664. * Gets the index buffer
  80665. * @return the index buffer
  80666. */
  80667. getIndexBuffer(): Nullable<WebGLBuffer>;
  80668. /** @hidden */
  80669. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  80670. /**
  80671. * Release the associated resources for a specific mesh
  80672. * @param mesh defines the source mesh
  80673. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  80674. */
  80675. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  80676. /**
  80677. * Apply current geometry to a given mesh
  80678. * @param mesh defines the mesh to apply geometry to
  80679. */
  80680. applyToMesh(mesh: Mesh): void;
  80681. private _updateExtend;
  80682. private _applyToMesh;
  80683. private notifyUpdate;
  80684. /**
  80685. * Load the geometry if it was flagged as delay loaded
  80686. * @param scene defines the hosting scene
  80687. * @param onLoaded defines a callback called when the geometry is loaded
  80688. */
  80689. load(scene: Scene, onLoaded?: () => void): void;
  80690. private _queueLoad;
  80691. /**
  80692. * Invert the geometry to move from a right handed system to a left handed one.
  80693. */
  80694. toLeftHanded(): void;
  80695. /** @hidden */
  80696. _resetPointsArrayCache(): void;
  80697. /** @hidden */
  80698. _generatePointsArray(): boolean;
  80699. /**
  80700. * Gets a value indicating if the geometry is disposed
  80701. * @returns true if the geometry was disposed
  80702. */
  80703. isDisposed(): boolean;
  80704. private _disposeVertexArrayObjects;
  80705. /**
  80706. * Free all associated resources
  80707. */
  80708. dispose(): void;
  80709. /**
  80710. * Clone the current geometry into a new geometry
  80711. * @param id defines the unique ID of the new geometry
  80712. * @returns a new geometry object
  80713. */
  80714. copy(id: string): Geometry;
  80715. /**
  80716. * Serialize the current geometry info (and not the vertices data) into a JSON object
  80717. * @return a JSON representation of the current geometry data (without the vertices data)
  80718. */
  80719. serialize(): any;
  80720. private toNumberArray;
  80721. /**
  80722. * Serialize all vertices data into a JSON oject
  80723. * @returns a JSON representation of the current geometry data
  80724. */
  80725. serializeVerticeData(): any;
  80726. /**
  80727. * Extracts a clone of a mesh geometry
  80728. * @param mesh defines the source mesh
  80729. * @param id defines the unique ID of the new geometry object
  80730. * @returns the new geometry object
  80731. */
  80732. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  80733. /**
  80734. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  80735. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  80736. * Be aware Math.random() could cause collisions, but:
  80737. * "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"
  80738. * @returns a string containing a new GUID
  80739. */
  80740. static RandomId(): string;
  80741. /** @hidden */
  80742. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  80743. private static _CleanMatricesWeights;
  80744. /**
  80745. * Create a new geometry from persisted data (Using .babylon file format)
  80746. * @param parsedVertexData defines the persisted data
  80747. * @param scene defines the hosting scene
  80748. * @param rootUrl defines the root url to use to load assets (like delayed data)
  80749. * @returns the new geometry object
  80750. */
  80751. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  80752. }
  80753. }
  80754. declare module BABYLON {
  80755. /**
  80756. * Define an interface for all classes that will get and set the data on vertices
  80757. */
  80758. export interface IGetSetVerticesData {
  80759. /**
  80760. * Gets a boolean indicating if specific vertex data is present
  80761. * @param kind defines the vertex data kind to use
  80762. * @returns true is data kind is present
  80763. */
  80764. isVerticesDataPresent(kind: string): boolean;
  80765. /**
  80766. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  80767. * @param kind defines the data kind (Position, normal, etc...)
  80768. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  80769. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80770. * @returns a float array containing vertex data
  80771. */
  80772. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  80773. /**
  80774. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  80775. * @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.
  80776. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80777. * @returns the indices array or an empty array if the mesh has no geometry
  80778. */
  80779. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  80780. /**
  80781. * Set specific vertex data
  80782. * @param kind defines the data kind (Position, normal, etc...)
  80783. * @param data defines the vertex data to use
  80784. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  80785. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  80786. */
  80787. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  80788. /**
  80789. * Update a specific associated vertex buffer
  80790. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80791. * - VertexBuffer.PositionKind
  80792. * - VertexBuffer.UVKind
  80793. * - VertexBuffer.UV2Kind
  80794. * - VertexBuffer.UV3Kind
  80795. * - VertexBuffer.UV4Kind
  80796. * - VertexBuffer.UV5Kind
  80797. * - VertexBuffer.UV6Kind
  80798. * - VertexBuffer.ColorKind
  80799. * - VertexBuffer.MatricesIndicesKind
  80800. * - VertexBuffer.MatricesIndicesExtraKind
  80801. * - VertexBuffer.MatricesWeightsKind
  80802. * - VertexBuffer.MatricesWeightsExtraKind
  80803. * @param data defines the data source
  80804. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  80805. * @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)
  80806. */
  80807. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  80808. /**
  80809. * Creates a new index buffer
  80810. * @param indices defines the indices to store in the index buffer
  80811. * @param totalVertices defines the total number of vertices (could be null)
  80812. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  80813. */
  80814. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  80815. }
  80816. /**
  80817. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  80818. */
  80819. export class VertexData {
  80820. /**
  80821. * Mesh side orientation : usually the external or front surface
  80822. */
  80823. static readonly FRONTSIDE: number;
  80824. /**
  80825. * Mesh side orientation : usually the internal or back surface
  80826. */
  80827. static readonly BACKSIDE: number;
  80828. /**
  80829. * Mesh side orientation : both internal and external or front and back surfaces
  80830. */
  80831. static readonly DOUBLESIDE: number;
  80832. /**
  80833. * Mesh side orientation : by default, `FRONTSIDE`
  80834. */
  80835. static readonly DEFAULTSIDE: number;
  80836. /**
  80837. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  80838. */
  80839. positions: Nullable<FloatArray>;
  80840. /**
  80841. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  80842. */
  80843. normals: Nullable<FloatArray>;
  80844. /**
  80845. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  80846. */
  80847. tangents: Nullable<FloatArray>;
  80848. /**
  80849. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80850. */
  80851. uvs: Nullable<FloatArray>;
  80852. /**
  80853. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80854. */
  80855. uvs2: Nullable<FloatArray>;
  80856. /**
  80857. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80858. */
  80859. uvs3: Nullable<FloatArray>;
  80860. /**
  80861. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80862. */
  80863. uvs4: Nullable<FloatArray>;
  80864. /**
  80865. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80866. */
  80867. uvs5: Nullable<FloatArray>;
  80868. /**
  80869. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  80870. */
  80871. uvs6: Nullable<FloatArray>;
  80872. /**
  80873. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  80874. */
  80875. colors: Nullable<FloatArray>;
  80876. /**
  80877. * 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).
  80878. */
  80879. matricesIndices: Nullable<FloatArray>;
  80880. /**
  80881. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  80882. */
  80883. matricesWeights: Nullable<FloatArray>;
  80884. /**
  80885. * An array extending the number of possible indices
  80886. */
  80887. matricesIndicesExtra: Nullable<FloatArray>;
  80888. /**
  80889. * An array extending the number of possible weights when the number of indices is extended
  80890. */
  80891. matricesWeightsExtra: Nullable<FloatArray>;
  80892. /**
  80893. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  80894. */
  80895. indices: Nullable<IndicesArray>;
  80896. /**
  80897. * Uses the passed data array to set the set the values for the specified kind of data
  80898. * @param data a linear array of floating numbers
  80899. * @param kind the type of data that is being set, eg positions, colors etc
  80900. */
  80901. set(data: FloatArray, kind: string): void;
  80902. /**
  80903. * Associates the vertexData to the passed Mesh.
  80904. * Sets it as updatable or not (default `false`)
  80905. * @param mesh the mesh the vertexData is applied to
  80906. * @param updatable when used and having the value true allows new data to update the vertexData
  80907. * @returns the VertexData
  80908. */
  80909. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  80910. /**
  80911. * Associates the vertexData to the passed Geometry.
  80912. * Sets it as updatable or not (default `false`)
  80913. * @param geometry the geometry the vertexData is applied to
  80914. * @param updatable when used and having the value true allows new data to update the vertexData
  80915. * @returns VertexData
  80916. */
  80917. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  80918. /**
  80919. * Updates the associated mesh
  80920. * @param mesh the mesh to be updated
  80921. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  80922. * @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
  80923. * @returns VertexData
  80924. */
  80925. updateMesh(mesh: Mesh): VertexData;
  80926. /**
  80927. * Updates the associated geometry
  80928. * @param geometry the geometry to be updated
  80929. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  80930. * @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
  80931. * @returns VertexData.
  80932. */
  80933. updateGeometry(geometry: Geometry): VertexData;
  80934. private _applyTo;
  80935. private _update;
  80936. /**
  80937. * Transforms each position and each normal of the vertexData according to the passed Matrix
  80938. * @param matrix the transforming matrix
  80939. * @returns the VertexData
  80940. */
  80941. transform(matrix: Matrix): VertexData;
  80942. /**
  80943. * Merges the passed VertexData into the current one
  80944. * @param other the VertexData to be merged into the current one
  80945. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  80946. * @returns the modified VertexData
  80947. */
  80948. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  80949. private _mergeElement;
  80950. private _validate;
  80951. /**
  80952. * Serializes the VertexData
  80953. * @returns a serialized object
  80954. */
  80955. serialize(): any;
  80956. /**
  80957. * Extracts the vertexData from a mesh
  80958. * @param mesh the mesh from which to extract the VertexData
  80959. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  80960. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  80961. * @returns the object VertexData associated to the passed mesh
  80962. */
  80963. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  80964. /**
  80965. * Extracts the vertexData from the geometry
  80966. * @param geometry the geometry from which to extract the VertexData
  80967. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  80968. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  80969. * @returns the object VertexData associated to the passed mesh
  80970. */
  80971. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  80972. private static _ExtractFrom;
  80973. /**
  80974. * Creates the VertexData for a Ribbon
  80975. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  80976. * * pathArray array of paths, each of which an array of successive Vector3
  80977. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  80978. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  80979. * * 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
  80980. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80981. * * 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)
  80982. * * 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)
  80983. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  80984. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  80985. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  80986. * @returns the VertexData of the ribbon
  80987. */
  80988. static CreateRibbon(options: {
  80989. pathArray: Vector3[][];
  80990. closeArray?: boolean;
  80991. closePath?: boolean;
  80992. offset?: number;
  80993. sideOrientation?: number;
  80994. frontUVs?: Vector4;
  80995. backUVs?: Vector4;
  80996. invertUV?: boolean;
  80997. uvs?: Vector2[];
  80998. colors?: Color4[];
  80999. }): VertexData;
  81000. /**
  81001. * Creates the VertexData for a box
  81002. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81003. * * size sets the width, height and depth of the box to the value of size, optional default 1
  81004. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  81005. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  81006. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  81007. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  81008. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  81009. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81010. * * 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)
  81011. * * 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)
  81012. * @returns the VertexData of the box
  81013. */
  81014. static CreateBox(options: {
  81015. size?: number;
  81016. width?: number;
  81017. height?: number;
  81018. depth?: number;
  81019. faceUV?: Vector4[];
  81020. faceColors?: Color4[];
  81021. sideOrientation?: number;
  81022. frontUVs?: Vector4;
  81023. backUVs?: Vector4;
  81024. }): VertexData;
  81025. /**
  81026. * Creates the VertexData for an ellipsoid, defaults to a sphere
  81027. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81028. * * segments sets the number of horizontal strips optional, default 32
  81029. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  81030. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  81031. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  81032. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  81033. * * 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
  81034. * * 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
  81035. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81036. * * 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)
  81037. * * 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)
  81038. * @returns the VertexData of the ellipsoid
  81039. */
  81040. static CreateSphere(options: {
  81041. segments?: number;
  81042. diameter?: number;
  81043. diameterX?: number;
  81044. diameterY?: number;
  81045. diameterZ?: number;
  81046. arc?: number;
  81047. slice?: number;
  81048. sideOrientation?: number;
  81049. frontUVs?: Vector4;
  81050. backUVs?: Vector4;
  81051. }): VertexData;
  81052. /**
  81053. * Creates the VertexData for a cylinder, cone or prism
  81054. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81055. * * height sets the height (y direction) of the cylinder, optional, default 2
  81056. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  81057. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  81058. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  81059. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  81060. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  81061. * * 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
  81062. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  81063. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  81064. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  81065. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  81066. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81067. * * 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)
  81068. * * 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)
  81069. * @returns the VertexData of the cylinder, cone or prism
  81070. */
  81071. static CreateCylinder(options: {
  81072. height?: number;
  81073. diameterTop?: number;
  81074. diameterBottom?: number;
  81075. diameter?: number;
  81076. tessellation?: number;
  81077. subdivisions?: number;
  81078. arc?: number;
  81079. faceColors?: Color4[];
  81080. faceUV?: Vector4[];
  81081. hasRings?: boolean;
  81082. enclose?: boolean;
  81083. sideOrientation?: number;
  81084. frontUVs?: Vector4;
  81085. backUVs?: Vector4;
  81086. }): VertexData;
  81087. /**
  81088. * Creates the VertexData for a torus
  81089. * @param options an object used to set the following optional parameters for the box, required but can be empty
  81090. * * diameter the diameter of the torus, optional default 1
  81091. * * thickness the diameter of the tube forming the torus, optional default 0.5
  81092. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  81093. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81094. * * 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)
  81095. * * 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)
  81096. * @returns the VertexData of the torus
  81097. */
  81098. static CreateTorus(options: {
  81099. diameter?: number;
  81100. thickness?: number;
  81101. tessellation?: number;
  81102. sideOrientation?: number;
  81103. frontUVs?: Vector4;
  81104. backUVs?: Vector4;
  81105. }): VertexData;
  81106. /**
  81107. * Creates the VertexData of the LineSystem
  81108. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  81109. * - lines an array of lines, each line being an array of successive Vector3
  81110. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  81111. * @returns the VertexData of the LineSystem
  81112. */
  81113. static CreateLineSystem(options: {
  81114. lines: Vector3[][];
  81115. colors?: Nullable<Color4[][]>;
  81116. }): VertexData;
  81117. /**
  81118. * Create the VertexData for a DashedLines
  81119. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  81120. * - points an array successive Vector3
  81121. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  81122. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  81123. * - dashNb the intended total number of dashes, optional, default 200
  81124. * @returns the VertexData for the DashedLines
  81125. */
  81126. static CreateDashedLines(options: {
  81127. points: Vector3[];
  81128. dashSize?: number;
  81129. gapSize?: number;
  81130. dashNb?: number;
  81131. }): VertexData;
  81132. /**
  81133. * Creates the VertexData for a Ground
  81134. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  81135. * - width the width (x direction) of the ground, optional, default 1
  81136. * - height the height (z direction) of the ground, optional, default 1
  81137. * - subdivisions the number of subdivisions per side, optional, default 1
  81138. * @returns the VertexData of the Ground
  81139. */
  81140. static CreateGround(options: {
  81141. width?: number;
  81142. height?: number;
  81143. subdivisions?: number;
  81144. subdivisionsX?: number;
  81145. subdivisionsY?: number;
  81146. }): VertexData;
  81147. /**
  81148. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  81149. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  81150. * * xmin the ground minimum X coordinate, optional, default -1
  81151. * * zmin the ground minimum Z coordinate, optional, default -1
  81152. * * xmax the ground maximum X coordinate, optional, default 1
  81153. * * zmax the ground maximum Z coordinate, optional, default 1
  81154. * * 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}
  81155. * * 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}
  81156. * @returns the VertexData of the TiledGround
  81157. */
  81158. static CreateTiledGround(options: {
  81159. xmin: number;
  81160. zmin: number;
  81161. xmax: number;
  81162. zmax: number;
  81163. subdivisions?: {
  81164. w: number;
  81165. h: number;
  81166. };
  81167. precision?: {
  81168. w: number;
  81169. h: number;
  81170. };
  81171. }): VertexData;
  81172. /**
  81173. * Creates the VertexData of the Ground designed from a heightmap
  81174. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  81175. * * width the width (x direction) of the ground
  81176. * * height the height (z direction) of the ground
  81177. * * subdivisions the number of subdivisions per side
  81178. * * minHeight the minimum altitude on the ground, optional, default 0
  81179. * * maxHeight the maximum altitude on the ground, optional default 1
  81180. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  81181. * * buffer the array holding the image color data
  81182. * * bufferWidth the width of image
  81183. * * bufferHeight the height of image
  81184. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  81185. * @returns the VertexData of the Ground designed from a heightmap
  81186. */
  81187. static CreateGroundFromHeightMap(options: {
  81188. width: number;
  81189. height: number;
  81190. subdivisions: number;
  81191. minHeight: number;
  81192. maxHeight: number;
  81193. colorFilter: Color3;
  81194. buffer: Uint8Array;
  81195. bufferWidth: number;
  81196. bufferHeight: number;
  81197. alphaFilter: number;
  81198. }): VertexData;
  81199. /**
  81200. * Creates the VertexData for a Plane
  81201. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  81202. * * size sets the width and height of the plane to the value of size, optional default 1
  81203. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  81204. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  81205. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81206. * * 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)
  81207. * * 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)
  81208. * @returns the VertexData of the box
  81209. */
  81210. static CreatePlane(options: {
  81211. size?: number;
  81212. width?: number;
  81213. height?: number;
  81214. sideOrientation?: number;
  81215. frontUVs?: Vector4;
  81216. backUVs?: Vector4;
  81217. }): VertexData;
  81218. /**
  81219. * Creates the VertexData of the Disc or regular Polygon
  81220. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  81221. * * radius the radius of the disc, optional default 0.5
  81222. * * tessellation the number of polygon sides, optional, default 64
  81223. * * 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
  81224. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81225. * * 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)
  81226. * * 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)
  81227. * @returns the VertexData of the box
  81228. */
  81229. static CreateDisc(options: {
  81230. radius?: number;
  81231. tessellation?: number;
  81232. arc?: number;
  81233. sideOrientation?: number;
  81234. frontUVs?: Vector4;
  81235. backUVs?: Vector4;
  81236. }): VertexData;
  81237. /**
  81238. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  81239. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  81240. * @param polygon a mesh built from polygonTriangulation.build()
  81241. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81242. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  81243. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  81244. * @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)
  81245. * @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)
  81246. * @returns the VertexData of the Polygon
  81247. */
  81248. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  81249. /**
  81250. * Creates the VertexData of the IcoSphere
  81251. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  81252. * * radius the radius of the IcoSphere, optional default 1
  81253. * * radiusX allows stretching in the x direction, optional, default radius
  81254. * * radiusY allows stretching in the y direction, optional, default radius
  81255. * * radiusZ allows stretching in the z direction, optional, default radius
  81256. * * flat when true creates a flat shaded mesh, optional, default true
  81257. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  81258. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81259. * * 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)
  81260. * * 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)
  81261. * @returns the VertexData of the IcoSphere
  81262. */
  81263. static CreateIcoSphere(options: {
  81264. radius?: number;
  81265. radiusX?: number;
  81266. radiusY?: number;
  81267. radiusZ?: number;
  81268. flat?: boolean;
  81269. subdivisions?: number;
  81270. sideOrientation?: number;
  81271. frontUVs?: Vector4;
  81272. backUVs?: Vector4;
  81273. }): VertexData;
  81274. /**
  81275. * Creates the VertexData for a Polyhedron
  81276. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  81277. * * type provided types are:
  81278. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  81279. * * 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)
  81280. * * size the size of the IcoSphere, optional default 1
  81281. * * sizeX allows stretching in the x direction, optional, default size
  81282. * * sizeY allows stretching in the y direction, optional, default size
  81283. * * sizeZ allows stretching in the z direction, optional, default size
  81284. * * 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
  81285. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  81286. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  81287. * * flat when true creates a flat shaded mesh, optional, default true
  81288. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  81289. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81290. * * 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)
  81291. * * 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)
  81292. * @returns the VertexData of the Polyhedron
  81293. */
  81294. static CreatePolyhedron(options: {
  81295. type?: number;
  81296. size?: number;
  81297. sizeX?: number;
  81298. sizeY?: number;
  81299. sizeZ?: number;
  81300. custom?: any;
  81301. faceUV?: Vector4[];
  81302. faceColors?: Color4[];
  81303. flat?: boolean;
  81304. sideOrientation?: number;
  81305. frontUVs?: Vector4;
  81306. backUVs?: Vector4;
  81307. }): VertexData;
  81308. /**
  81309. * Creates the VertexData for a TorusKnot
  81310. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  81311. * * radius the radius of the torus knot, optional, default 2
  81312. * * tube the thickness of the tube, optional, default 0.5
  81313. * * radialSegments the number of sides on each tube segments, optional, default 32
  81314. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  81315. * * p the number of windings around the z axis, optional, default 2
  81316. * * q the number of windings around the x axis, optional, default 3
  81317. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81318. * * 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)
  81319. * * 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)
  81320. * @returns the VertexData of the Torus Knot
  81321. */
  81322. static CreateTorusKnot(options: {
  81323. radius?: number;
  81324. tube?: number;
  81325. radialSegments?: number;
  81326. tubularSegments?: number;
  81327. p?: number;
  81328. q?: number;
  81329. sideOrientation?: number;
  81330. frontUVs?: Vector4;
  81331. backUVs?: Vector4;
  81332. }): VertexData;
  81333. /**
  81334. * Compute normals for given positions and indices
  81335. * @param positions an array of vertex positions, [...., x, y, z, ......]
  81336. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  81337. * @param normals an array of vertex normals, [...., x, y, z, ......]
  81338. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  81339. * * facetNormals : optional array of facet normals (vector3)
  81340. * * facetPositions : optional array of facet positions (vector3)
  81341. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  81342. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  81343. * * bInfo : optional bounding info, required for facetPartitioning computation
  81344. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  81345. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  81346. * * useRightHandedSystem: optional boolean to for right handed system computation
  81347. * * depthSort : optional boolean to enable the facet depth sort computation
  81348. * * distanceTo : optional Vector3 to compute the facet depth from this location
  81349. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  81350. */
  81351. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  81352. facetNormals?: any;
  81353. facetPositions?: any;
  81354. facetPartitioning?: any;
  81355. ratio?: number;
  81356. bInfo?: any;
  81357. bbSize?: Vector3;
  81358. subDiv?: any;
  81359. useRightHandedSystem?: boolean;
  81360. depthSort?: boolean;
  81361. distanceTo?: Vector3;
  81362. depthSortedFacets?: any;
  81363. }): void;
  81364. /** @hidden */
  81365. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  81366. /**
  81367. * Applies VertexData created from the imported parameters to the geometry
  81368. * @param parsedVertexData the parsed data from an imported file
  81369. * @param geometry the geometry to apply the VertexData to
  81370. */
  81371. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  81372. }
  81373. }
  81374. declare module BABYLON {
  81375. /**
  81376. * Class containing static functions to help procedurally build meshes
  81377. */
  81378. export class DiscBuilder {
  81379. /**
  81380. * Creates a plane polygonal mesh. By default, this is a disc
  81381. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  81382. * * 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
  81383. * * 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
  81384. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  81385. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  81386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81387. * @param name defines the name of the mesh
  81388. * @param options defines the options used to create the mesh
  81389. * @param scene defines the hosting scene
  81390. * @returns the plane polygonal mesh
  81391. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  81392. */
  81393. static CreateDisc(name: string, options: {
  81394. radius?: number;
  81395. tessellation?: number;
  81396. arc?: number;
  81397. updatable?: boolean;
  81398. sideOrientation?: number;
  81399. frontUVs?: Vector4;
  81400. backUVs?: Vector4;
  81401. }, scene?: Nullable<Scene>): Mesh;
  81402. }
  81403. }
  81404. declare module BABYLON {
  81405. /**
  81406. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  81407. *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.
  81408. * The SPS is also a particle system. It provides some methods to manage the particles.
  81409. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  81410. *
  81411. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  81412. */
  81413. export class SolidParticleSystem implements IDisposable {
  81414. /**
  81415. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  81416. * Example : var p = SPS.particles[i];
  81417. */
  81418. particles: SolidParticle[];
  81419. /**
  81420. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  81421. */
  81422. nbParticles: number;
  81423. /**
  81424. * If the particles must ever face the camera (default false). Useful for planar particles.
  81425. */
  81426. billboard: boolean;
  81427. /**
  81428. * Recompute normals when adding a shape
  81429. */
  81430. recomputeNormals: boolean;
  81431. /**
  81432. * This a counter ofr your own usage. It's not set by any SPS functions.
  81433. */
  81434. counter: number;
  81435. /**
  81436. * The SPS name. This name is also given to the underlying mesh.
  81437. */
  81438. name: string;
  81439. /**
  81440. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  81441. */
  81442. mesh: Mesh;
  81443. /**
  81444. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  81445. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  81446. */
  81447. vars: any;
  81448. /**
  81449. * This array is populated when the SPS is set as 'pickable'.
  81450. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  81451. * Each element of this array is an object `{idx: int, faceId: int}`.
  81452. * `idx` is the picked particle index in the `SPS.particles` array
  81453. * `faceId` is the picked face index counted within this particle.
  81454. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  81455. */
  81456. pickedParticles: {
  81457. idx: number;
  81458. faceId: number;
  81459. }[];
  81460. /**
  81461. * This array is populated when `enableDepthSort` is set to true.
  81462. * Each element of this array is an instance of the class DepthSortedParticle.
  81463. */
  81464. depthSortedParticles: DepthSortedParticle[];
  81465. /**
  81466. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  81467. * @hidden
  81468. */
  81469. _bSphereOnly: boolean;
  81470. /**
  81471. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  81472. * @hidden
  81473. */
  81474. _bSphereRadiusFactor: number;
  81475. private _scene;
  81476. private _positions;
  81477. private _indices;
  81478. private _normals;
  81479. private _colors;
  81480. private _uvs;
  81481. private _indices32;
  81482. private _positions32;
  81483. private _normals32;
  81484. private _fixedNormal32;
  81485. private _colors32;
  81486. private _uvs32;
  81487. private _index;
  81488. private _updatable;
  81489. private _pickable;
  81490. private _isVisibilityBoxLocked;
  81491. private _alwaysVisible;
  81492. private _depthSort;
  81493. private _shapeCounter;
  81494. private _copy;
  81495. private _color;
  81496. private _computeParticleColor;
  81497. private _computeParticleTexture;
  81498. private _computeParticleRotation;
  81499. private _computeParticleVertex;
  81500. private _computeBoundingBox;
  81501. private _depthSortParticles;
  81502. private _camera;
  81503. private _mustUnrotateFixedNormals;
  81504. private _particlesIntersect;
  81505. private _needs32Bits;
  81506. /**
  81507. * Creates a SPS (Solid Particle System) object.
  81508. * @param name (String) is the SPS name, this will be the underlying mesh name.
  81509. * @param scene (Scene) is the scene in which the SPS is added.
  81510. * @param options defines the options of the sps e.g.
  81511. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  81512. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  81513. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  81514. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  81515. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  81516. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  81517. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  81518. */
  81519. constructor(name: string, scene: Scene, options?: {
  81520. updatable?: boolean;
  81521. isPickable?: boolean;
  81522. enableDepthSort?: boolean;
  81523. particleIntersection?: boolean;
  81524. boundingSphereOnly?: boolean;
  81525. bSphereRadiusFactor?: number;
  81526. });
  81527. /**
  81528. * Builds the SPS underlying mesh. Returns a standard Mesh.
  81529. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  81530. * @returns the created mesh
  81531. */
  81532. buildMesh(): Mesh;
  81533. /**
  81534. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  81535. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  81536. * Thus the particles generated from `digest()` have their property `position` set yet.
  81537. * @param mesh ( Mesh ) is the mesh to be digested
  81538. * @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
  81539. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  81540. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  81541. * @returns the current SPS
  81542. */
  81543. digest(mesh: Mesh, options?: {
  81544. facetNb?: number;
  81545. number?: number;
  81546. delta?: number;
  81547. }): SolidParticleSystem;
  81548. private _unrotateFixedNormals;
  81549. private _resetCopy;
  81550. private _meshBuilder;
  81551. private _posToShape;
  81552. private _uvsToShapeUV;
  81553. private _addParticle;
  81554. /**
  81555. * Adds some particles to the SPS from the model shape. Returns the shape id.
  81556. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  81557. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  81558. * @param nb (positive integer) the number of particles to be created from this model
  81559. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  81560. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  81561. * @returns the number of shapes in the system
  81562. */
  81563. addShape(mesh: Mesh, nb: number, options?: {
  81564. positionFunction?: any;
  81565. vertexFunction?: any;
  81566. }): number;
  81567. private _rebuildParticle;
  81568. /**
  81569. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  81570. * @returns the SPS.
  81571. */
  81572. rebuildMesh(): SolidParticleSystem;
  81573. /**
  81574. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  81575. * This method calls `updateParticle()` for each particle of the SPS.
  81576. * For an animated SPS, it is usually called within the render loop.
  81577. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  81578. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  81579. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  81580. * @returns the SPS.
  81581. */
  81582. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  81583. /**
  81584. * Disposes the SPS.
  81585. */
  81586. dispose(): void;
  81587. /**
  81588. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  81589. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81590. * @returns the SPS.
  81591. */
  81592. refreshVisibleSize(): SolidParticleSystem;
  81593. /**
  81594. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  81595. * @param size the size (float) of the visibility box
  81596. * note : this doesn't lock the SPS mesh bounding box.
  81597. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81598. */
  81599. setVisibilityBox(size: number): void;
  81600. /**
  81601. * Gets whether the SPS as always visible or not
  81602. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81603. */
  81604. /**
  81605. * Sets the SPS as always visible or not
  81606. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81607. */
  81608. isAlwaysVisible: boolean;
  81609. /**
  81610. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  81611. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81612. */
  81613. /**
  81614. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  81615. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  81616. */
  81617. isVisibilityBoxLocked: boolean;
  81618. /**
  81619. * Tells to `setParticles()` to compute the particle rotations or not.
  81620. * Default value : true. The SPS is faster when it's set to false.
  81621. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  81622. */
  81623. /**
  81624. * Gets if `setParticles()` computes the particle rotations or not.
  81625. * Default value : true. The SPS is faster when it's set to false.
  81626. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  81627. */
  81628. computeParticleRotation: boolean;
  81629. /**
  81630. * Tells to `setParticles()` to compute the particle colors or not.
  81631. * Default value : true. The SPS is faster when it's set to false.
  81632. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  81633. */
  81634. /**
  81635. * Gets if `setParticles()` computes the particle colors or not.
  81636. * Default value : true. The SPS is faster when it's set to false.
  81637. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  81638. */
  81639. computeParticleColor: boolean;
  81640. /**
  81641. * Gets if `setParticles()` computes the particle textures or not.
  81642. * Default value : true. The SPS is faster when it's set to false.
  81643. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  81644. */
  81645. computeParticleTexture: boolean;
  81646. /**
  81647. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  81648. * Default value : false. The SPS is faster when it's set to false.
  81649. * Note : the particle custom vertex positions aren't stored values.
  81650. */
  81651. /**
  81652. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  81653. * Default value : false. The SPS is faster when it's set to false.
  81654. * Note : the particle custom vertex positions aren't stored values.
  81655. */
  81656. computeParticleVertex: boolean;
  81657. /**
  81658. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  81659. */
  81660. /**
  81661. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  81662. */
  81663. computeBoundingBox: boolean;
  81664. /**
  81665. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  81666. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  81667. * Default : `true`
  81668. */
  81669. /**
  81670. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  81671. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  81672. * Default : `true`
  81673. */
  81674. depthSortParticles: boolean;
  81675. /**
  81676. * This function does nothing. It may be overwritten to set all the particle first values.
  81677. * The SPS doesn't call this function, you may have to call it by your own.
  81678. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  81679. */
  81680. initParticles(): void;
  81681. /**
  81682. * This function does nothing. It may be overwritten to recycle a particle.
  81683. * The SPS doesn't call this function, you may have to call it by your own.
  81684. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  81685. * @param particle The particle to recycle
  81686. * @returns the recycled particle
  81687. */
  81688. recycleParticle(particle: SolidParticle): SolidParticle;
  81689. /**
  81690. * Updates a particle : this function should be overwritten by the user.
  81691. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  81692. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  81693. * @example : just set a particle position or velocity and recycle conditions
  81694. * @param particle The particle to update
  81695. * @returns the updated particle
  81696. */
  81697. updateParticle(particle: SolidParticle): SolidParticle;
  81698. /**
  81699. * Updates a vertex of a particle : it can be overwritten by the user.
  81700. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  81701. * @param particle the current particle
  81702. * @param vertex the current index of the current particle
  81703. * @param pt the index of the current vertex in the particle shape
  81704. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  81705. * @example : just set a vertex particle position
  81706. * @returns the updated vertex
  81707. */
  81708. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  81709. /**
  81710. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  81711. * This does nothing and may be overwritten by the user.
  81712. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  81713. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  81714. * @param update the boolean update value actually passed to setParticles()
  81715. */
  81716. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  81717. /**
  81718. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  81719. * This will be passed three parameters.
  81720. * This does nothing and may be overwritten by the user.
  81721. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  81722. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  81723. * @param update the boolean update value actually passed to setParticles()
  81724. */
  81725. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  81726. }
  81727. }
  81728. declare module BABYLON {
  81729. /**
  81730. * Represents one particle of a solid particle system.
  81731. */
  81732. export class SolidParticle {
  81733. /**
  81734. * particle global index
  81735. */
  81736. idx: number;
  81737. /**
  81738. * The color of the particle
  81739. */
  81740. color: Nullable<Color4>;
  81741. /**
  81742. * The world space position of the particle.
  81743. */
  81744. position: Vector3;
  81745. /**
  81746. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  81747. */
  81748. rotation: Vector3;
  81749. /**
  81750. * The world space rotation quaternion of the particle.
  81751. */
  81752. rotationQuaternion: Nullable<Quaternion>;
  81753. /**
  81754. * The scaling of the particle.
  81755. */
  81756. scaling: Vector3;
  81757. /**
  81758. * The uvs of the particle.
  81759. */
  81760. uvs: Vector4;
  81761. /**
  81762. * The current speed of the particle.
  81763. */
  81764. velocity: Vector3;
  81765. /**
  81766. * The pivot point in the particle local space.
  81767. */
  81768. pivot: Vector3;
  81769. /**
  81770. * Must the particle be translated from its pivot point in its local space ?
  81771. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  81772. * Default : false
  81773. */
  81774. translateFromPivot: boolean;
  81775. /**
  81776. * Is the particle active or not ?
  81777. */
  81778. alive: boolean;
  81779. /**
  81780. * Is the particle visible or not ?
  81781. */
  81782. isVisible: boolean;
  81783. /**
  81784. * Index of this particle in the global "positions" array (Internal use)
  81785. * @hidden
  81786. */
  81787. _pos: number;
  81788. /**
  81789. * @hidden Index of this particle in the global "indices" array (Internal use)
  81790. */
  81791. _ind: number;
  81792. /**
  81793. * @hidden ModelShape of this particle (Internal use)
  81794. */
  81795. _model: ModelShape;
  81796. /**
  81797. * ModelShape id of this particle
  81798. */
  81799. shapeId: number;
  81800. /**
  81801. * Index of the particle in its shape id (Internal use)
  81802. */
  81803. idxInShape: number;
  81804. /**
  81805. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  81806. */
  81807. _modelBoundingInfo: BoundingInfo;
  81808. /**
  81809. * @hidden Particle BoundingInfo object (Internal use)
  81810. */
  81811. _boundingInfo: BoundingInfo;
  81812. /**
  81813. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  81814. */
  81815. _sps: SolidParticleSystem;
  81816. /**
  81817. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  81818. */
  81819. _stillInvisible: boolean;
  81820. /**
  81821. * @hidden Last computed particle rotation matrix
  81822. */
  81823. _rotationMatrix: number[];
  81824. /**
  81825. * Parent particle Id, if any.
  81826. * Default null.
  81827. */
  81828. parentId: Nullable<number>;
  81829. /**
  81830. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  81831. * The possible values are :
  81832. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  81833. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  81834. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  81835. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  81836. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  81837. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  81838. * */
  81839. cullingStrategy: number;
  81840. /**
  81841. * @hidden Internal global position in the SPS.
  81842. */
  81843. _globalPosition: Vector3;
  81844. /**
  81845. * Creates a Solid Particle object.
  81846. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  81847. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  81848. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  81849. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  81850. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  81851. * @param shapeId (integer) is the model shape identifier in the SPS.
  81852. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  81853. * @param sps defines the sps it is associated to
  81854. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  81855. */
  81856. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  81857. /**
  81858. * Legacy support, changed scale to scaling
  81859. */
  81860. /**
  81861. * Legacy support, changed scale to scaling
  81862. */
  81863. scale: Vector3;
  81864. /**
  81865. * Legacy support, changed quaternion to rotationQuaternion
  81866. */
  81867. /**
  81868. * Legacy support, changed quaternion to rotationQuaternion
  81869. */
  81870. quaternion: Nullable<Quaternion>;
  81871. /**
  81872. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  81873. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  81874. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  81875. * @returns true if it intersects
  81876. */
  81877. intersectsMesh(target: Mesh | SolidParticle): boolean;
  81878. /**
  81879. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  81880. * A particle is in the frustum if its bounding box intersects the frustum
  81881. * @param frustumPlanes defines the frustum to test
  81882. * @returns true if the particle is in the frustum planes
  81883. */
  81884. isInFrustum(frustumPlanes: Plane[]): boolean;
  81885. /**
  81886. * get the rotation matrix of the particle
  81887. * @hidden
  81888. */
  81889. getRotationMatrix(m: Matrix): void;
  81890. }
  81891. /**
  81892. * Represents the shape of the model used by one particle of a solid particle system.
  81893. * SPS internal tool, don't use it manually.
  81894. */
  81895. export class ModelShape {
  81896. /**
  81897. * The shape id
  81898. * @hidden
  81899. */
  81900. shapeID: number;
  81901. /**
  81902. * flat array of model positions (internal use)
  81903. * @hidden
  81904. */
  81905. _shape: Vector3[];
  81906. /**
  81907. * flat array of model UVs (internal use)
  81908. * @hidden
  81909. */
  81910. _shapeUV: number[];
  81911. /**
  81912. * length of the shape in the model indices array (internal use)
  81913. * @hidden
  81914. */
  81915. _indicesLength: number;
  81916. /**
  81917. * Custom position function (internal use)
  81918. * @hidden
  81919. */
  81920. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  81921. /**
  81922. * Custom vertex function (internal use)
  81923. * @hidden
  81924. */
  81925. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  81926. /**
  81927. * 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.
  81928. * SPS internal tool, don't use it manually.
  81929. * @hidden
  81930. */
  81931. 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>);
  81932. }
  81933. /**
  81934. * Represents a Depth Sorted Particle in the solid particle system.
  81935. */
  81936. export class DepthSortedParticle {
  81937. /**
  81938. * Index of the particle in the "indices" array
  81939. */
  81940. ind: number;
  81941. /**
  81942. * Length of the particle shape in the "indices" array
  81943. */
  81944. indicesLength: number;
  81945. /**
  81946. * Squared distance from the particle to the camera
  81947. */
  81948. sqDistance: number;
  81949. }
  81950. }
  81951. declare module BABYLON {
  81952. /**
  81953. * Class used to store all common mesh properties
  81954. */
  81955. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  81956. /** No occlusion */
  81957. static OCCLUSION_TYPE_NONE: number;
  81958. /** Occlusion set to optimisitic */
  81959. static OCCLUSION_TYPE_OPTIMISTIC: number;
  81960. /** Occlusion set to strict */
  81961. static OCCLUSION_TYPE_STRICT: number;
  81962. /** Use an accurante occlusion algorithm */
  81963. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  81964. /** Use a conservative occlusion algorithm */
  81965. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  81966. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  81967. * Test order :
  81968. * Is the bounding sphere outside the frustum ?
  81969. * If not, are the bounding box vertices outside the frustum ?
  81970. * It not, then the cullable object is in the frustum.
  81971. */
  81972. static readonly CULLINGSTRATEGY_STANDARD: number;
  81973. /** Culling strategy : Bounding Sphere Only.
  81974. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  81975. * It's also less accurate than the standard because some not visible objects can still be selected.
  81976. * Test : is the bounding sphere outside the frustum ?
  81977. * If not, then the cullable object is in the frustum.
  81978. */
  81979. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  81980. /** Culling strategy : Optimistic Inclusion.
  81981. * This in an inclusion test first, then the standard exclusion test.
  81982. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  81983. * 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.
  81984. * Anyway, it's as accurate as the standard strategy.
  81985. * Test :
  81986. * Is the cullable object bounding sphere center in the frustum ?
  81987. * If not, apply the default culling strategy.
  81988. */
  81989. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  81990. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  81991. * This in an inclusion test first, then the bounding sphere only exclusion test.
  81992. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  81993. * 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.
  81994. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  81995. * Test :
  81996. * Is the cullable object bounding sphere center in the frustum ?
  81997. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  81998. */
  81999. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  82000. /**
  82001. * No billboard
  82002. */
  82003. static readonly BILLBOARDMODE_NONE: number;
  82004. /** Billboard on X axis */
  82005. static readonly BILLBOARDMODE_X: number;
  82006. /** Billboard on Y axis */
  82007. static readonly BILLBOARDMODE_Y: number;
  82008. /** Billboard on Z axis */
  82009. static readonly BILLBOARDMODE_Z: number;
  82010. /** Billboard on all axes */
  82011. static readonly BILLBOARDMODE_ALL: number;
  82012. private _facetData;
  82013. /**
  82014. * The culling strategy to use to check whether the mesh must be rendered or not.
  82015. * This value can be changed at any time and will be used on the next render mesh selection.
  82016. * The possible values are :
  82017. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  82018. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  82019. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  82020. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  82021. * Please read each static variable documentation to get details about the culling process.
  82022. * */
  82023. cullingStrategy: number;
  82024. /**
  82025. * Gets the number of facets in the mesh
  82026. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  82027. */
  82028. readonly facetNb: number;
  82029. /**
  82030. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  82031. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  82032. */
  82033. partitioningSubdivisions: number;
  82034. /**
  82035. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  82036. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  82037. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  82038. */
  82039. partitioningBBoxRatio: number;
  82040. /**
  82041. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  82042. * Works only for updatable meshes.
  82043. * Doesn't work with multi-materials
  82044. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  82045. */
  82046. mustDepthSortFacets: boolean;
  82047. /**
  82048. * The location (Vector3) where the facet depth sort must be computed from.
  82049. * By default, the active camera position.
  82050. * Used only when facet depth sort is enabled
  82051. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  82052. */
  82053. facetDepthSortFrom: Vector3;
  82054. /**
  82055. * gets a boolean indicating if facetData is enabled
  82056. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  82057. */
  82058. readonly isFacetDataEnabled: boolean;
  82059. /** @hidden */
  82060. _updateNonUniformScalingState(value: boolean): boolean;
  82061. /**
  82062. * An event triggered when this mesh collides with another one
  82063. */
  82064. onCollideObservable: Observable<AbstractMesh>;
  82065. private _onCollideObserver;
  82066. /** Set a function to call when this mesh collides with another one */
  82067. onCollide: () => void;
  82068. /**
  82069. * An event triggered when the collision's position changes
  82070. */
  82071. onCollisionPositionChangeObservable: Observable<Vector3>;
  82072. private _onCollisionPositionChangeObserver;
  82073. /** Set a function to call when the collision's position changes */
  82074. onCollisionPositionChange: () => void;
  82075. /**
  82076. * An event triggered when material is changed
  82077. */
  82078. onMaterialChangedObservable: Observable<AbstractMesh>;
  82079. /**
  82080. * Gets or sets the orientation for POV movement & rotation
  82081. */
  82082. definedFacingForward: boolean;
  82083. /** @hidden */
  82084. _occlusionQuery: Nullable<WebGLQuery>;
  82085. private _visibility;
  82086. /**
  82087. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  82088. */
  82089. /**
  82090. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  82091. */
  82092. visibility: number;
  82093. /** Gets or sets the alpha index used to sort transparent meshes
  82094. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  82095. */
  82096. alphaIndex: number;
  82097. /**
  82098. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  82099. */
  82100. isVisible: boolean;
  82101. /**
  82102. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  82103. */
  82104. isPickable: boolean;
  82105. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  82106. showSubMeshesBoundingBox: boolean;
  82107. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  82108. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  82109. */
  82110. isBlocker: boolean;
  82111. /**
  82112. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  82113. */
  82114. enablePointerMoveEvents: boolean;
  82115. /**
  82116. * Specifies the rendering group id for this mesh (0 by default)
  82117. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  82118. */
  82119. renderingGroupId: number;
  82120. private _material;
  82121. /** Gets or sets current material */
  82122. material: Nullable<Material>;
  82123. private _receiveShadows;
  82124. /**
  82125. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  82126. * @see http://doc.babylonjs.com/babylon101/shadows
  82127. */
  82128. receiveShadows: boolean;
  82129. /** Defines color to use when rendering outline */
  82130. outlineColor: Color3;
  82131. /** Define width to use when rendering outline */
  82132. outlineWidth: number;
  82133. /** Defines color to use when rendering overlay */
  82134. overlayColor: Color3;
  82135. /** Defines alpha to use when rendering overlay */
  82136. overlayAlpha: number;
  82137. private _hasVertexAlpha;
  82138. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  82139. hasVertexAlpha: boolean;
  82140. private _useVertexColors;
  82141. /** 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) */
  82142. useVertexColors: boolean;
  82143. private _computeBonesUsingShaders;
  82144. /**
  82145. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  82146. */
  82147. computeBonesUsingShaders: boolean;
  82148. private _numBoneInfluencers;
  82149. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  82150. numBoneInfluencers: number;
  82151. private _applyFog;
  82152. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  82153. applyFog: boolean;
  82154. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  82155. useOctreeForRenderingSelection: boolean;
  82156. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  82157. useOctreeForPicking: boolean;
  82158. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  82159. useOctreeForCollisions: boolean;
  82160. private _layerMask;
  82161. /**
  82162. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  82163. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  82164. */
  82165. layerMask: number;
  82166. /**
  82167. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  82168. */
  82169. alwaysSelectAsActiveMesh: boolean;
  82170. /**
  82171. * Gets or sets the current action manager
  82172. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82173. */
  82174. actionManager: Nullable<AbstractActionManager>;
  82175. private _checkCollisions;
  82176. private _collisionMask;
  82177. private _collisionGroup;
  82178. /**
  82179. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  82180. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82181. */
  82182. ellipsoid: Vector3;
  82183. /**
  82184. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  82185. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82186. */
  82187. ellipsoidOffset: Vector3;
  82188. private _collider;
  82189. private _oldPositionForCollisions;
  82190. private _diffPositionForCollisions;
  82191. /**
  82192. * Gets or sets a collision mask used to mask collisions (default is -1).
  82193. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  82194. */
  82195. collisionMask: number;
  82196. /**
  82197. * Gets or sets the current collision group mask (-1 by default).
  82198. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  82199. */
  82200. collisionGroup: number;
  82201. /**
  82202. * Defines edge width used when edgesRenderer is enabled
  82203. * @see https://www.babylonjs-playground.com/#10OJSG#13
  82204. */
  82205. edgesWidth: number;
  82206. /**
  82207. * Defines edge color used when edgesRenderer is enabled
  82208. * @see https://www.babylonjs-playground.com/#10OJSG#13
  82209. */
  82210. edgesColor: Color4;
  82211. /** @hidden */
  82212. _edgesRenderer: Nullable<IEdgesRenderer>;
  82213. /** @hidden */
  82214. _masterMesh: Nullable<AbstractMesh>;
  82215. /** @hidden */
  82216. _boundingInfo: Nullable<BoundingInfo>;
  82217. /** @hidden */
  82218. _renderId: number;
  82219. /**
  82220. * Gets or sets the list of subMeshes
  82221. * @see http://doc.babylonjs.com/how_to/multi_materials
  82222. */
  82223. subMeshes: SubMesh[];
  82224. /** @hidden */
  82225. _intersectionsInProgress: AbstractMesh[];
  82226. /** @hidden */
  82227. _unIndexed: boolean;
  82228. /** @hidden */
  82229. _lightSources: Light[];
  82230. /** @hidden */
  82231. readonly _positions: Nullable<Vector3[]>;
  82232. /** @hidden */
  82233. _waitingActions: any;
  82234. /** @hidden */
  82235. _waitingFreezeWorldMatrix: Nullable<boolean>;
  82236. private _skeleton;
  82237. /** @hidden */
  82238. _bonesTransformMatrices: Nullable<Float32Array>;
  82239. /**
  82240. * Gets or sets a skeleton to apply skining transformations
  82241. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82242. */
  82243. skeleton: Nullable<Skeleton>;
  82244. /**
  82245. * An event triggered when the mesh is rebuilt.
  82246. */
  82247. onRebuildObservable: Observable<AbstractMesh>;
  82248. /**
  82249. * Creates a new AbstractMesh
  82250. * @param name defines the name of the mesh
  82251. * @param scene defines the hosting scene
  82252. */
  82253. constructor(name: string, scene?: Nullable<Scene>);
  82254. /**
  82255. * Returns the string "AbstractMesh"
  82256. * @returns "AbstractMesh"
  82257. */
  82258. getClassName(): string;
  82259. /**
  82260. * Gets a string representation of the current mesh
  82261. * @param fullDetails defines a boolean indicating if full details must be included
  82262. * @returns a string representation of the current mesh
  82263. */
  82264. toString(fullDetails?: boolean): string;
  82265. /** @hidden */
  82266. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  82267. /** @hidden */
  82268. _rebuild(): void;
  82269. /** @hidden */
  82270. _resyncLightSources(): void;
  82271. /** @hidden */
  82272. _resyncLighSource(light: Light): void;
  82273. /** @hidden */
  82274. _unBindEffect(): void;
  82275. /** @hidden */
  82276. _removeLightSource(light: Light): void;
  82277. private _markSubMeshesAsDirty;
  82278. /** @hidden */
  82279. _markSubMeshesAsLightDirty(): void;
  82280. /** @hidden */
  82281. _markSubMeshesAsAttributesDirty(): void;
  82282. /** @hidden */
  82283. _markSubMeshesAsMiscDirty(): void;
  82284. /**
  82285. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  82286. */
  82287. scaling: Vector3;
  82288. /**
  82289. * Returns true if the mesh is blocked. Implemented by child classes
  82290. */
  82291. readonly isBlocked: boolean;
  82292. /**
  82293. * Returns the mesh itself by default. Implemented by child classes
  82294. * @param camera defines the camera to use to pick the right LOD level
  82295. * @returns the currentAbstractMesh
  82296. */
  82297. getLOD(camera: Camera): Nullable<AbstractMesh>;
  82298. /**
  82299. * Returns 0 by default. Implemented by child classes
  82300. * @returns an integer
  82301. */
  82302. getTotalVertices(): number;
  82303. /**
  82304. * Returns a positive integer : the total number of indices in this mesh geometry.
  82305. * @returns the numner of indices or zero if the mesh has no geometry.
  82306. */
  82307. getTotalIndices(): number;
  82308. /**
  82309. * Returns null by default. Implemented by child classes
  82310. * @returns null
  82311. */
  82312. getIndices(): Nullable<IndicesArray>;
  82313. /**
  82314. * Returns the array of the requested vertex data kind. Implemented by child classes
  82315. * @param kind defines the vertex data kind to use
  82316. * @returns null
  82317. */
  82318. getVerticesData(kind: string): Nullable<FloatArray>;
  82319. /**
  82320. * Sets the vertex data of the mesh geometry for the requested `kind`.
  82321. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  82322. * Note that a new underlying VertexBuffer object is created each call.
  82323. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  82324. * @param kind defines vertex data kind:
  82325. * * VertexBuffer.PositionKind
  82326. * * VertexBuffer.UVKind
  82327. * * VertexBuffer.UV2Kind
  82328. * * VertexBuffer.UV3Kind
  82329. * * VertexBuffer.UV4Kind
  82330. * * VertexBuffer.UV5Kind
  82331. * * VertexBuffer.UV6Kind
  82332. * * VertexBuffer.ColorKind
  82333. * * VertexBuffer.MatricesIndicesKind
  82334. * * VertexBuffer.MatricesIndicesExtraKind
  82335. * * VertexBuffer.MatricesWeightsKind
  82336. * * VertexBuffer.MatricesWeightsExtraKind
  82337. * @param data defines the data source
  82338. * @param updatable defines if the data must be flagged as updatable (or static)
  82339. * @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
  82340. * @returns the current mesh
  82341. */
  82342. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  82343. /**
  82344. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  82345. * If the mesh has no geometry, it is simply returned as it is.
  82346. * @param kind defines vertex data kind:
  82347. * * VertexBuffer.PositionKind
  82348. * * VertexBuffer.UVKind
  82349. * * VertexBuffer.UV2Kind
  82350. * * VertexBuffer.UV3Kind
  82351. * * VertexBuffer.UV4Kind
  82352. * * VertexBuffer.UV5Kind
  82353. * * VertexBuffer.UV6Kind
  82354. * * VertexBuffer.ColorKind
  82355. * * VertexBuffer.MatricesIndicesKind
  82356. * * VertexBuffer.MatricesIndicesExtraKind
  82357. * * VertexBuffer.MatricesWeightsKind
  82358. * * VertexBuffer.MatricesWeightsExtraKind
  82359. * @param data defines the data source
  82360. * @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
  82361. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  82362. * @returns the current mesh
  82363. */
  82364. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  82365. /**
  82366. * Sets the mesh indices,
  82367. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  82368. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  82369. * @param totalVertices Defines the total number of vertices
  82370. * @returns the current mesh
  82371. */
  82372. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  82373. /**
  82374. * Gets a boolean indicating if specific vertex data is present
  82375. * @param kind defines the vertex data kind to use
  82376. * @returns true is data kind is present
  82377. */
  82378. isVerticesDataPresent(kind: string): boolean;
  82379. /**
  82380. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  82381. * @returns a BoundingInfo
  82382. */
  82383. getBoundingInfo(): BoundingInfo;
  82384. /**
  82385. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  82386. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  82387. * @returns the current mesh
  82388. */
  82389. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  82390. /**
  82391. * Overwrite the current bounding info
  82392. * @param boundingInfo defines the new bounding info
  82393. * @returns the current mesh
  82394. */
  82395. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  82396. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  82397. readonly useBones: boolean;
  82398. /** @hidden */
  82399. _preActivate(): void;
  82400. /** @hidden */
  82401. _preActivateForIntermediateRendering(renderId: number): void;
  82402. /** @hidden */
  82403. _activate(renderId: number): void;
  82404. /**
  82405. * Gets the current world matrix
  82406. * @returns a Matrix
  82407. */
  82408. getWorldMatrix(): Matrix;
  82409. /** @hidden */
  82410. _getWorldMatrixDeterminant(): number;
  82411. /**
  82412. * Perform relative position change from the point of view of behind the front of the mesh.
  82413. * This is performed taking into account the meshes current rotation, so you do not have to care.
  82414. * Supports definition of mesh facing forward or backward
  82415. * @param amountRight defines the distance on the right axis
  82416. * @param amountUp defines the distance on the up axis
  82417. * @param amountForward defines the distance on the forward axis
  82418. * @returns the current mesh
  82419. */
  82420. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  82421. /**
  82422. * Calculate relative position change from the point of view of behind the front of the mesh.
  82423. * This is performed taking into account the meshes current rotation, so you do not have to care.
  82424. * Supports definition of mesh facing forward or backward
  82425. * @param amountRight defines the distance on the right axis
  82426. * @param amountUp defines the distance on the up axis
  82427. * @param amountForward defines the distance on the forward axis
  82428. * @returns the new displacement vector
  82429. */
  82430. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  82431. /**
  82432. * Perform relative rotation change from the point of view of behind the front of the mesh.
  82433. * Supports definition of mesh facing forward or backward
  82434. * @param flipBack defines the flip
  82435. * @param twirlClockwise defines the twirl
  82436. * @param tiltRight defines the tilt
  82437. * @returns the current mesh
  82438. */
  82439. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  82440. /**
  82441. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  82442. * Supports definition of mesh facing forward or backward.
  82443. * @param flipBack defines the flip
  82444. * @param twirlClockwise defines the twirl
  82445. * @param tiltRight defines the tilt
  82446. * @returns the new rotation vector
  82447. */
  82448. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  82449. /**
  82450. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  82451. * @param includeDescendants Include bounding info from descendants as well (true by default)
  82452. * @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
  82453. * @returns the new bounding vectors
  82454. */
  82455. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  82456. min: Vector3;
  82457. max: Vector3;
  82458. };
  82459. /**
  82460. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  82461. * This means the mesh underlying bounding box and sphere are recomputed.
  82462. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  82463. * @returns the current mesh
  82464. */
  82465. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  82466. /** @hidden */
  82467. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  82468. /** @hidden */
  82469. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  82470. /** @hidden */
  82471. _updateBoundingInfo(): AbstractMesh;
  82472. /** @hidden */
  82473. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  82474. /** @hidden */
  82475. protected _afterComputeWorldMatrix(): void;
  82476. /**
  82477. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  82478. * A mesh is in the frustum if its bounding box intersects the frustum
  82479. * @param frustumPlanes defines the frustum to test
  82480. * @returns true if the mesh is in the frustum planes
  82481. */
  82482. isInFrustum(frustumPlanes: Plane[]): boolean;
  82483. /**
  82484. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  82485. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  82486. * @param frustumPlanes defines the frustum to test
  82487. * @returns true if the mesh is completely in the frustum planes
  82488. */
  82489. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  82490. /**
  82491. * True if the mesh intersects another mesh or a SolidParticle object
  82492. * @param mesh defines a target mesh or SolidParticle to test
  82493. * @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)
  82494. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  82495. * @returns true if there is an intersection
  82496. */
  82497. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  82498. /**
  82499. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  82500. * @param point defines the point to test
  82501. * @returns true if there is an intersection
  82502. */
  82503. intersectsPoint(point: Vector3): boolean;
  82504. /**
  82505. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  82506. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82507. */
  82508. checkCollisions: boolean;
  82509. /**
  82510. * Gets Collider object used to compute collisions (not physics)
  82511. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82512. */
  82513. readonly collider: Collider;
  82514. /**
  82515. * Move the mesh using collision engine
  82516. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  82517. * @param displacement defines the requested displacement vector
  82518. * @returns the current mesh
  82519. */
  82520. moveWithCollisions(displacement: Vector3): AbstractMesh;
  82521. private _onCollisionPositionChange;
  82522. /** @hidden */
  82523. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  82524. /** @hidden */
  82525. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  82526. /** @hidden */
  82527. _checkCollision(collider: Collider): AbstractMesh;
  82528. /** @hidden */
  82529. _generatePointsArray(): boolean;
  82530. /**
  82531. * Checks if the passed Ray intersects with the mesh
  82532. * @param ray defines the ray to use
  82533. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  82534. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  82535. * @returns the picking info
  82536. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  82537. */
  82538. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  82539. /**
  82540. * Clones the current mesh
  82541. * @param name defines the mesh name
  82542. * @param newParent defines the new mesh parent
  82543. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  82544. * @returns the new mesh
  82545. */
  82546. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  82547. /**
  82548. * Disposes all the submeshes of the current meshnp
  82549. * @returns the current mesh
  82550. */
  82551. releaseSubMeshes(): AbstractMesh;
  82552. /**
  82553. * Releases resources associated with this abstract mesh.
  82554. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  82555. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  82556. */
  82557. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82558. /**
  82559. * Adds the passed mesh as a child to the current mesh
  82560. * @param mesh defines the child mesh
  82561. * @returns the current mesh
  82562. */
  82563. addChild(mesh: AbstractMesh): AbstractMesh;
  82564. /**
  82565. * Removes the passed mesh from the current mesh children list
  82566. * @param mesh defines the child mesh
  82567. * @returns the current mesh
  82568. */
  82569. removeChild(mesh: AbstractMesh): AbstractMesh;
  82570. /** @hidden */
  82571. private _initFacetData;
  82572. /**
  82573. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  82574. * This method can be called within the render loop.
  82575. * 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
  82576. * @returns the current mesh
  82577. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82578. */
  82579. updateFacetData(): AbstractMesh;
  82580. /**
  82581. * Returns the facetLocalNormals array.
  82582. * The normals are expressed in the mesh local spac
  82583. * @returns an array of Vector3
  82584. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82585. */
  82586. getFacetLocalNormals(): Vector3[];
  82587. /**
  82588. * Returns the facetLocalPositions array.
  82589. * The facet positions are expressed in the mesh local space
  82590. * @returns an array of Vector3
  82591. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82592. */
  82593. getFacetLocalPositions(): Vector3[];
  82594. /**
  82595. * Returns the facetLocalPartioning array
  82596. * @returns an array of array of numbers
  82597. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82598. */
  82599. getFacetLocalPartitioning(): number[][];
  82600. /**
  82601. * Returns the i-th facet position in the world system.
  82602. * This method allocates a new Vector3 per call
  82603. * @param i defines the facet index
  82604. * @returns a new Vector3
  82605. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82606. */
  82607. getFacetPosition(i: number): Vector3;
  82608. /**
  82609. * Sets the reference Vector3 with the i-th facet position in the world system
  82610. * @param i defines the facet index
  82611. * @param ref defines the target vector
  82612. * @returns the current mesh
  82613. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82614. */
  82615. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  82616. /**
  82617. * Returns the i-th facet normal in the world system.
  82618. * This method allocates a new Vector3 per call
  82619. * @param i defines the facet index
  82620. * @returns a new Vector3
  82621. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82622. */
  82623. getFacetNormal(i: number): Vector3;
  82624. /**
  82625. * Sets the reference Vector3 with the i-th facet normal in the world system
  82626. * @param i defines the facet index
  82627. * @param ref defines the target vector
  82628. * @returns the current mesh
  82629. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82630. */
  82631. getFacetNormalToRef(i: number, ref: Vector3): this;
  82632. /**
  82633. * 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)
  82634. * @param x defines x coordinate
  82635. * @param y defines y coordinate
  82636. * @param z defines z coordinate
  82637. * @returns the array of facet indexes
  82638. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82639. */
  82640. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  82641. /**
  82642. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  82643. * @param projected sets as the (x,y,z) world projection on the facet
  82644. * @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
  82645. * @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
  82646. * @param x defines x coordinate
  82647. * @param y defines y coordinate
  82648. * @param z defines z coordinate
  82649. * @returns the face index if found (or null instead)
  82650. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82651. */
  82652. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  82653. /**
  82654. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  82655. * @param projected sets as the (x,y,z) local projection on the facet
  82656. * @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
  82657. * @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
  82658. * @param x defines x coordinate
  82659. * @param y defines y coordinate
  82660. * @param z defines z coordinate
  82661. * @returns the face index if found (or null instead)
  82662. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82663. */
  82664. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  82665. /**
  82666. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  82667. * @returns the parameters
  82668. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82669. */
  82670. getFacetDataParameters(): any;
  82671. /**
  82672. * Disables the feature FacetData and frees the related memory
  82673. * @returns the current mesh
  82674. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  82675. */
  82676. disableFacetData(): AbstractMesh;
  82677. /**
  82678. * Updates the AbstractMesh indices array
  82679. * @param indices defines the data source
  82680. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  82681. * @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)
  82682. * @returns the current mesh
  82683. */
  82684. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  82685. /**
  82686. * Creates new normals data for the mesh
  82687. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  82688. * @returns the current mesh
  82689. */
  82690. createNormals(updatable: boolean): AbstractMesh;
  82691. /**
  82692. * Align the mesh with a normal
  82693. * @param normal defines the normal to use
  82694. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  82695. * @returns the current mesh
  82696. */
  82697. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  82698. /** @hidden */
  82699. _checkOcclusionQuery(): boolean;
  82700. }
  82701. }
  82702. declare module BABYLON {
  82703. /**
  82704. * Interface used to define ActionEvent
  82705. */
  82706. export interface IActionEvent {
  82707. /** The mesh or sprite that triggered the action */
  82708. source: any;
  82709. /** The X mouse cursor position at the time of the event */
  82710. pointerX: number;
  82711. /** The Y mouse cursor position at the time of the event */
  82712. pointerY: number;
  82713. /** The mesh that is currently pointed at (can be null) */
  82714. meshUnderPointer: Nullable<AbstractMesh>;
  82715. /** the original (browser) event that triggered the ActionEvent */
  82716. sourceEvent?: any;
  82717. /** additional data for the event */
  82718. additionalData?: any;
  82719. }
  82720. /**
  82721. * ActionEvent is the event being sent when an action is triggered.
  82722. */
  82723. export class ActionEvent implements IActionEvent {
  82724. /** The mesh or sprite that triggered the action */
  82725. source: any;
  82726. /** The X mouse cursor position at the time of the event */
  82727. pointerX: number;
  82728. /** The Y mouse cursor position at the time of the event */
  82729. pointerY: number;
  82730. /** The mesh that is currently pointed at (can be null) */
  82731. meshUnderPointer: Nullable<AbstractMesh>;
  82732. /** the original (browser) event that triggered the ActionEvent */
  82733. sourceEvent?: any;
  82734. /** additional data for the event */
  82735. additionalData?: any;
  82736. /**
  82737. * Creates a new ActionEvent
  82738. * @param source The mesh or sprite that triggered the action
  82739. * @param pointerX The X mouse cursor position at the time of the event
  82740. * @param pointerY The Y mouse cursor position at the time of the event
  82741. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  82742. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  82743. * @param additionalData additional data for the event
  82744. */
  82745. constructor(
  82746. /** The mesh or sprite that triggered the action */
  82747. source: any,
  82748. /** The X mouse cursor position at the time of the event */
  82749. pointerX: number,
  82750. /** The Y mouse cursor position at the time of the event */
  82751. pointerY: number,
  82752. /** The mesh that is currently pointed at (can be null) */
  82753. meshUnderPointer: Nullable<AbstractMesh>,
  82754. /** the original (browser) event that triggered the ActionEvent */
  82755. sourceEvent?: any,
  82756. /** additional data for the event */
  82757. additionalData?: any);
  82758. /**
  82759. * Helper function to auto-create an ActionEvent from a source mesh.
  82760. * @param source The source mesh that triggered the event
  82761. * @param evt The original (browser) event
  82762. * @param additionalData additional data for the event
  82763. * @returns the new ActionEvent
  82764. */
  82765. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  82766. /**
  82767. * Helper function to auto-create an ActionEvent from a source sprite
  82768. * @param source The source sprite that triggered the event
  82769. * @param scene Scene associated with the sprite
  82770. * @param evt The original (browser) event
  82771. * @param additionalData additional data for the event
  82772. * @returns the new ActionEvent
  82773. */
  82774. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  82775. /**
  82776. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  82777. * @param scene the scene where the event occurred
  82778. * @param evt The original (browser) event
  82779. * @returns the new ActionEvent
  82780. */
  82781. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  82782. /**
  82783. * Helper function to auto-create an ActionEvent from a primitive
  82784. * @param prim defines the target primitive
  82785. * @param pointerPos defines the pointer position
  82786. * @param evt The original (browser) event
  82787. * @param additionalData additional data for the event
  82788. * @returns the new ActionEvent
  82789. */
  82790. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  82791. }
  82792. }
  82793. declare module BABYLON {
  82794. /**
  82795. * Abstract class used to decouple action Manager from scene and meshes.
  82796. * Do not instantiate.
  82797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82798. */
  82799. export abstract class AbstractActionManager implements IDisposable {
  82800. /** Gets the list of active triggers */
  82801. static Triggers: {
  82802. [key: string]: number;
  82803. };
  82804. /** Gets the cursor to use when hovering items */
  82805. hoverCursor: string;
  82806. /** Gets the list of actions */
  82807. actions: IAction[];
  82808. /**
  82809. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  82810. */
  82811. isRecursive: boolean;
  82812. /**
  82813. * Releases all associated resources
  82814. */
  82815. abstract dispose(): void;
  82816. /**
  82817. * Does this action manager has pointer triggers
  82818. */
  82819. abstract readonly hasPointerTriggers: boolean;
  82820. /**
  82821. * Does this action manager has pick triggers
  82822. */
  82823. abstract readonly hasPickTriggers: boolean;
  82824. /**
  82825. * Process a specific trigger
  82826. * @param trigger defines the trigger to process
  82827. * @param evt defines the event details to be processed
  82828. */
  82829. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  82830. /**
  82831. * Does this action manager handles actions of any of the given triggers
  82832. * @param triggers defines the triggers to be tested
  82833. * @return a boolean indicating whether one (or more) of the triggers is handled
  82834. */
  82835. abstract hasSpecificTriggers(triggers: number[]): boolean;
  82836. /**
  82837. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  82838. * speed.
  82839. * @param triggerA defines the trigger to be tested
  82840. * @param triggerB defines the trigger to be tested
  82841. * @return a boolean indicating whether one (or more) of the triggers is handled
  82842. */
  82843. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  82844. /**
  82845. * Does this action manager handles actions of a given trigger
  82846. * @param trigger defines the trigger to be tested
  82847. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  82848. * @return whether the trigger is handled
  82849. */
  82850. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  82851. /**
  82852. * Serialize this manager to a JSON object
  82853. * @param name defines the property name to store this manager
  82854. * @returns a JSON representation of this manager
  82855. */
  82856. abstract serialize(name: string): any;
  82857. /**
  82858. * Registers an action to this action manager
  82859. * @param action defines the action to be registered
  82860. * @return the action amended (prepared) after registration
  82861. */
  82862. abstract registerAction(action: IAction): Nullable<IAction>;
  82863. /**
  82864. * Unregisters an action to this action manager
  82865. * @param action defines the action to be unregistered
  82866. * @return a boolean indicating whether the action has been unregistered
  82867. */
  82868. abstract unregisterAction(action: IAction): Boolean;
  82869. /**
  82870. * Does exist one action manager with at least one trigger
  82871. **/
  82872. static readonly HasTriggers: boolean;
  82873. /**
  82874. * Does exist one action manager with at least one pick trigger
  82875. **/
  82876. static readonly HasPickTriggers: boolean;
  82877. /**
  82878. * Does exist one action manager that handles actions of a given trigger
  82879. * @param trigger defines the trigger to be tested
  82880. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  82881. **/
  82882. static HasSpecificTrigger(trigger: number): boolean;
  82883. }
  82884. }
  82885. declare module BABYLON {
  82886. /**
  82887. * Defines how a node can be built from a string name.
  82888. */
  82889. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  82890. /**
  82891. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  82892. */
  82893. export class Node implements IBehaviorAware<Node> {
  82894. /** @hidden */
  82895. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  82896. private static _NodeConstructors;
  82897. /**
  82898. * Add a new node constructor
  82899. * @param type defines the type name of the node to construct
  82900. * @param constructorFunc defines the constructor function
  82901. */
  82902. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  82903. /**
  82904. * Returns a node constructor based on type name
  82905. * @param type defines the type name
  82906. * @param name defines the new node name
  82907. * @param scene defines the hosting scene
  82908. * @param options defines optional options to transmit to constructors
  82909. * @returns the new constructor or null
  82910. */
  82911. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  82912. /**
  82913. * Gets or sets the name of the node
  82914. */
  82915. name: string;
  82916. /**
  82917. * Gets or sets the id of the node
  82918. */
  82919. id: string;
  82920. /**
  82921. * Gets or sets the unique id of the node
  82922. */
  82923. uniqueId: number;
  82924. /**
  82925. * Gets or sets a string used to store user defined state for the node
  82926. */
  82927. state: string;
  82928. /**
  82929. * Gets or sets an object used to store user defined information for the node
  82930. */
  82931. metadata: any;
  82932. /**
  82933. * For internal use only. Please do not use.
  82934. */
  82935. reservedDataStore: any;
  82936. /**
  82937. * List of inspectable custom properties (used by the Inspector)
  82938. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82939. */
  82940. inspectableCustomProperties: IInspectable[];
  82941. /**
  82942. * Gets or sets a boolean used to define if the node must be serialized
  82943. */
  82944. doNotSerialize: boolean;
  82945. /** @hidden */
  82946. _isDisposed: boolean;
  82947. /**
  82948. * Gets a list of Animations associated with the node
  82949. */
  82950. animations: Animation[];
  82951. protected _ranges: {
  82952. [name: string]: Nullable<AnimationRange>;
  82953. };
  82954. /**
  82955. * Callback raised when the node is ready to be used
  82956. */
  82957. onReady: (node: Node) => void;
  82958. private _isEnabled;
  82959. private _isParentEnabled;
  82960. private _isReady;
  82961. /** @hidden */
  82962. _currentRenderId: number;
  82963. private _parentRenderId;
  82964. protected _childRenderId: number;
  82965. /** @hidden */
  82966. _waitingParentId: Nullable<string>;
  82967. /** @hidden */
  82968. _scene: Scene;
  82969. /** @hidden */
  82970. _cache: any;
  82971. private _parentNode;
  82972. private _children;
  82973. /** @hidden */
  82974. _worldMatrix: Matrix;
  82975. /** @hidden */
  82976. _worldMatrixDeterminant: number;
  82977. /** @hidden */
  82978. private _sceneRootNodesIndex;
  82979. /**
  82980. * Gets a boolean indicating if the node has been disposed
  82981. * @returns true if the node was disposed
  82982. */
  82983. isDisposed(): boolean;
  82984. /**
  82985. * Gets or sets the parent of the node
  82986. */
  82987. parent: Nullable<Node>;
  82988. private addToSceneRootNodes;
  82989. private removeFromSceneRootNodes;
  82990. private _animationPropertiesOverride;
  82991. /**
  82992. * Gets or sets the animation properties override
  82993. */
  82994. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  82995. /**
  82996. * Gets a string idenfifying the name of the class
  82997. * @returns "Node" string
  82998. */
  82999. getClassName(): string;
  83000. /** @hidden */
  83001. readonly _isNode: boolean;
  83002. /**
  83003. * An event triggered when the mesh is disposed
  83004. */
  83005. onDisposeObservable: Observable<Node>;
  83006. private _onDisposeObserver;
  83007. /**
  83008. * Sets a callback that will be raised when the node will be disposed
  83009. */
  83010. onDispose: () => void;
  83011. /**
  83012. * Creates a new Node
  83013. * @param name the name and id to be given to this node
  83014. * @param scene the scene this node will be added to
  83015. * @param addToRootNodes the node will be added to scene.rootNodes
  83016. */
  83017. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  83018. /**
  83019. * Gets the scene of the node
  83020. * @returns a scene
  83021. */
  83022. getScene(): Scene;
  83023. /**
  83024. * Gets the engine of the node
  83025. * @returns a Engine
  83026. */
  83027. getEngine(): Engine;
  83028. private _behaviors;
  83029. /**
  83030. * Attach a behavior to the node
  83031. * @see http://doc.babylonjs.com/features/behaviour
  83032. * @param behavior defines the behavior to attach
  83033. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  83034. * @returns the current Node
  83035. */
  83036. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  83037. /**
  83038. * Remove an attached behavior
  83039. * @see http://doc.babylonjs.com/features/behaviour
  83040. * @param behavior defines the behavior to attach
  83041. * @returns the current Node
  83042. */
  83043. removeBehavior(behavior: Behavior<Node>): Node;
  83044. /**
  83045. * Gets the list of attached behaviors
  83046. * @see http://doc.babylonjs.com/features/behaviour
  83047. */
  83048. readonly behaviors: Behavior<Node>[];
  83049. /**
  83050. * Gets an attached behavior by name
  83051. * @param name defines the name of the behavior to look for
  83052. * @see http://doc.babylonjs.com/features/behaviour
  83053. * @returns null if behavior was not found else the requested behavior
  83054. */
  83055. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  83056. /**
  83057. * Returns the latest update of the World matrix
  83058. * @returns a Matrix
  83059. */
  83060. getWorldMatrix(): Matrix;
  83061. /** @hidden */
  83062. _getWorldMatrixDeterminant(): number;
  83063. /**
  83064. * Returns directly the latest state of the mesh World matrix.
  83065. * A Matrix is returned.
  83066. */
  83067. readonly worldMatrixFromCache: Matrix;
  83068. /** @hidden */
  83069. _initCache(): void;
  83070. /** @hidden */
  83071. updateCache(force?: boolean): void;
  83072. /** @hidden */
  83073. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  83074. /** @hidden */
  83075. _updateCache(ignoreParentClass?: boolean): void;
  83076. /** @hidden */
  83077. _isSynchronized(): boolean;
  83078. /** @hidden */
  83079. _markSyncedWithParent(): void;
  83080. /** @hidden */
  83081. isSynchronizedWithParent(): boolean;
  83082. /** @hidden */
  83083. isSynchronized(): boolean;
  83084. /**
  83085. * Is this node ready to be used/rendered
  83086. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  83087. * @return true if the node is ready
  83088. */
  83089. isReady(completeCheck?: boolean): boolean;
  83090. /**
  83091. * Is this node enabled?
  83092. * 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
  83093. * @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
  83094. * @return whether this node (and its parent) is enabled
  83095. */
  83096. isEnabled(checkAncestors?: boolean): boolean;
  83097. /** @hidden */
  83098. protected _syncParentEnabledState(): void;
  83099. /**
  83100. * Set the enabled state of this node
  83101. * @param value defines the new enabled state
  83102. */
  83103. setEnabled(value: boolean): void;
  83104. /**
  83105. * Is this node a descendant of the given node?
  83106. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  83107. * @param ancestor defines the parent node to inspect
  83108. * @returns a boolean indicating if this node is a descendant of the given node
  83109. */
  83110. isDescendantOf(ancestor: Node): boolean;
  83111. /** @hidden */
  83112. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  83113. /**
  83114. * Will return all nodes that have this node as ascendant
  83115. * @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
  83116. * @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
  83117. * @return all children nodes of all types
  83118. */
  83119. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  83120. /**
  83121. * Get all child-meshes of this node
  83122. * @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)
  83123. * @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
  83124. * @returns an array of AbstractMesh
  83125. */
  83126. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  83127. /**
  83128. * Get all direct children of this node
  83129. * @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
  83130. * @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)
  83131. * @returns an array of Node
  83132. */
  83133. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  83134. /** @hidden */
  83135. _setReady(state: boolean): void;
  83136. /**
  83137. * Get an animation by name
  83138. * @param name defines the name of the animation to look for
  83139. * @returns null if not found else the requested animation
  83140. */
  83141. getAnimationByName(name: string): Nullable<Animation>;
  83142. /**
  83143. * Creates an animation range for this node
  83144. * @param name defines the name of the range
  83145. * @param from defines the starting key
  83146. * @param to defines the end key
  83147. */
  83148. createAnimationRange(name: string, from: number, to: number): void;
  83149. /**
  83150. * Delete a specific animation range
  83151. * @param name defines the name of the range to delete
  83152. * @param deleteFrames defines if animation frames from the range must be deleted as well
  83153. */
  83154. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  83155. /**
  83156. * Get an animation range by name
  83157. * @param name defines the name of the animation range to look for
  83158. * @returns null if not found else the requested animation range
  83159. */
  83160. getAnimationRange(name: string): Nullable<AnimationRange>;
  83161. /**
  83162. * Gets the list of all animation ranges defined on this node
  83163. * @returns an array
  83164. */
  83165. getAnimationRanges(): Nullable<AnimationRange>[];
  83166. /**
  83167. * Will start the animation sequence
  83168. * @param name defines the range frames for animation sequence
  83169. * @param loop defines if the animation should loop (false by default)
  83170. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  83171. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  83172. * @returns the object created for this animation. If range does not exist, it will return null
  83173. */
  83174. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  83175. /**
  83176. * Serialize animation ranges into a JSON compatible object
  83177. * @returns serialization object
  83178. */
  83179. serializeAnimationRanges(): any;
  83180. /**
  83181. * Computes the world matrix of the node
  83182. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83183. * @returns the world matrix
  83184. */
  83185. computeWorldMatrix(force?: boolean): Matrix;
  83186. /**
  83187. * Releases resources associated with this node.
  83188. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83189. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83190. */
  83191. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83192. /**
  83193. * Parse animation range data from a serialization object and store them into a given node
  83194. * @param node defines where to store the animation ranges
  83195. * @param parsedNode defines the serialization object to read data from
  83196. * @param scene defines the hosting scene
  83197. */
  83198. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  83199. }
  83200. }
  83201. declare module BABYLON {
  83202. /**
  83203. * Class used to store any kind of animation
  83204. */
  83205. export class Animation {
  83206. /**Name of the animation */
  83207. name: string;
  83208. /**Property to animate */
  83209. targetProperty: string;
  83210. /**The frames per second of the animation */
  83211. framePerSecond: number;
  83212. /**The data type of the animation */
  83213. dataType: number;
  83214. /**The loop mode of the animation */
  83215. loopMode?: number | undefined;
  83216. /**Specifies if blending should be enabled */
  83217. enableBlending?: boolean | undefined;
  83218. /**
  83219. * Use matrix interpolation instead of using direct key value when animating matrices
  83220. */
  83221. static AllowMatricesInterpolation: boolean;
  83222. /**
  83223. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  83224. */
  83225. static AllowMatrixDecomposeForInterpolation: boolean;
  83226. /**
  83227. * Stores the key frames of the animation
  83228. */
  83229. private _keys;
  83230. /**
  83231. * Stores the easing function of the animation
  83232. */
  83233. private _easingFunction;
  83234. /**
  83235. * @hidden Internal use only
  83236. */
  83237. _runtimeAnimations: RuntimeAnimation[];
  83238. /**
  83239. * The set of event that will be linked to this animation
  83240. */
  83241. private _events;
  83242. /**
  83243. * Stores an array of target property paths
  83244. */
  83245. targetPropertyPath: string[];
  83246. /**
  83247. * Stores the blending speed of the animation
  83248. */
  83249. blendingSpeed: number;
  83250. /**
  83251. * Stores the animation ranges for the animation
  83252. */
  83253. private _ranges;
  83254. /**
  83255. * @hidden Internal use
  83256. */
  83257. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  83258. /**
  83259. * Sets up an animation
  83260. * @param property The property to animate
  83261. * @param animationType The animation type to apply
  83262. * @param framePerSecond The frames per second of the animation
  83263. * @param easingFunction The easing function used in the animation
  83264. * @returns The created animation
  83265. */
  83266. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  83267. /**
  83268. * Create and start an animation on a node
  83269. * @param name defines the name of the global animation that will be run on all nodes
  83270. * @param node defines the root node where the animation will take place
  83271. * @param targetProperty defines property to animate
  83272. * @param framePerSecond defines the number of frame per second yo use
  83273. * @param totalFrame defines the number of frames in total
  83274. * @param from defines the initial value
  83275. * @param to defines the final value
  83276. * @param loopMode defines which loop mode you want to use (off by default)
  83277. * @param easingFunction defines the easing function to use (linear by default)
  83278. * @param onAnimationEnd defines the callback to call when animation end
  83279. * @returns the animatable created for this animation
  83280. */
  83281. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  83282. /**
  83283. * Create and start an animation on a node and its descendants
  83284. * @param name defines the name of the global animation that will be run on all nodes
  83285. * @param node defines the root node where the animation will take place
  83286. * @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
  83287. * @param targetProperty defines property to animate
  83288. * @param framePerSecond defines the number of frame per second to use
  83289. * @param totalFrame defines the number of frames in total
  83290. * @param from defines the initial value
  83291. * @param to defines the final value
  83292. * @param loopMode defines which loop mode you want to use (off by default)
  83293. * @param easingFunction defines the easing function to use (linear by default)
  83294. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  83295. * @returns the list of animatables created for all nodes
  83296. * @example https://www.babylonjs-playground.com/#MH0VLI
  83297. */
  83298. 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[]>;
  83299. /**
  83300. * Creates a new animation, merges it with the existing animations and starts it
  83301. * @param name Name of the animation
  83302. * @param node Node which contains the scene that begins the animations
  83303. * @param targetProperty Specifies which property to animate
  83304. * @param framePerSecond The frames per second of the animation
  83305. * @param totalFrame The total number of frames
  83306. * @param from The frame at the beginning of the animation
  83307. * @param to The frame at the end of the animation
  83308. * @param loopMode Specifies the loop mode of the animation
  83309. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  83310. * @param onAnimationEnd Callback to run once the animation is complete
  83311. * @returns Nullable animation
  83312. */
  83313. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  83314. /**
  83315. * Transition property of an host to the target Value
  83316. * @param property The property to transition
  83317. * @param targetValue The target Value of the property
  83318. * @param host The object where the property to animate belongs
  83319. * @param scene Scene used to run the animation
  83320. * @param frameRate Framerate (in frame/s) to use
  83321. * @param transition The transition type we want to use
  83322. * @param duration The duration of the animation, in milliseconds
  83323. * @param onAnimationEnd Callback trigger at the end of the animation
  83324. * @returns Nullable animation
  83325. */
  83326. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  83327. /**
  83328. * Return the array of runtime animations currently using this animation
  83329. */
  83330. readonly runtimeAnimations: RuntimeAnimation[];
  83331. /**
  83332. * Specifies if any of the runtime animations are currently running
  83333. */
  83334. readonly hasRunningRuntimeAnimations: boolean;
  83335. /**
  83336. * Initializes the animation
  83337. * @param name Name of the animation
  83338. * @param targetProperty Property to animate
  83339. * @param framePerSecond The frames per second of the animation
  83340. * @param dataType The data type of the animation
  83341. * @param loopMode The loop mode of the animation
  83342. * @param enableBlending Specifies if blending should be enabled
  83343. */
  83344. constructor(
  83345. /**Name of the animation */
  83346. name: string,
  83347. /**Property to animate */
  83348. targetProperty: string,
  83349. /**The frames per second of the animation */
  83350. framePerSecond: number,
  83351. /**The data type of the animation */
  83352. dataType: number,
  83353. /**The loop mode of the animation */
  83354. loopMode?: number | undefined,
  83355. /**Specifies if blending should be enabled */
  83356. enableBlending?: boolean | undefined);
  83357. /**
  83358. * Converts the animation to a string
  83359. * @param fullDetails support for multiple levels of logging within scene loading
  83360. * @returns String form of the animation
  83361. */
  83362. toString(fullDetails?: boolean): string;
  83363. /**
  83364. * Add an event to this animation
  83365. * @param event Event to add
  83366. */
  83367. addEvent(event: AnimationEvent): void;
  83368. /**
  83369. * Remove all events found at the given frame
  83370. * @param frame The frame to remove events from
  83371. */
  83372. removeEvents(frame: number): void;
  83373. /**
  83374. * Retrieves all the events from the animation
  83375. * @returns Events from the animation
  83376. */
  83377. getEvents(): AnimationEvent[];
  83378. /**
  83379. * Creates an animation range
  83380. * @param name Name of the animation range
  83381. * @param from Starting frame of the animation range
  83382. * @param to Ending frame of the animation
  83383. */
  83384. createRange(name: string, from: number, to: number): void;
  83385. /**
  83386. * Deletes an animation range by name
  83387. * @param name Name of the animation range to delete
  83388. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  83389. */
  83390. deleteRange(name: string, deleteFrames?: boolean): void;
  83391. /**
  83392. * Gets the animation range by name, or null if not defined
  83393. * @param name Name of the animation range
  83394. * @returns Nullable animation range
  83395. */
  83396. getRange(name: string): Nullable<AnimationRange>;
  83397. /**
  83398. * Gets the key frames from the animation
  83399. * @returns The key frames of the animation
  83400. */
  83401. getKeys(): Array<IAnimationKey>;
  83402. /**
  83403. * Gets the highest frame rate of the animation
  83404. * @returns Highest frame rate of the animation
  83405. */
  83406. getHighestFrame(): number;
  83407. /**
  83408. * Gets the easing function of the animation
  83409. * @returns Easing function of the animation
  83410. */
  83411. getEasingFunction(): IEasingFunction;
  83412. /**
  83413. * Sets the easing function of the animation
  83414. * @param easingFunction A custom mathematical formula for animation
  83415. */
  83416. setEasingFunction(easingFunction: EasingFunction): void;
  83417. /**
  83418. * Interpolates a scalar linearly
  83419. * @param startValue Start value of the animation curve
  83420. * @param endValue End value of the animation curve
  83421. * @param gradient Scalar amount to interpolate
  83422. * @returns Interpolated scalar value
  83423. */
  83424. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  83425. /**
  83426. * Interpolates a scalar cubically
  83427. * @param startValue Start value of the animation curve
  83428. * @param outTangent End tangent of the animation
  83429. * @param endValue End value of the animation curve
  83430. * @param inTangent Start tangent of the animation curve
  83431. * @param gradient Scalar amount to interpolate
  83432. * @returns Interpolated scalar value
  83433. */
  83434. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  83435. /**
  83436. * Interpolates a quaternion using a spherical linear interpolation
  83437. * @param startValue Start value of the animation curve
  83438. * @param endValue End value of the animation curve
  83439. * @param gradient Scalar amount to interpolate
  83440. * @returns Interpolated quaternion value
  83441. */
  83442. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  83443. /**
  83444. * Interpolates a quaternion cubically
  83445. * @param startValue Start value of the animation curve
  83446. * @param outTangent End tangent of the animation curve
  83447. * @param endValue End value of the animation curve
  83448. * @param inTangent Start tangent of the animation curve
  83449. * @param gradient Scalar amount to interpolate
  83450. * @returns Interpolated quaternion value
  83451. */
  83452. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  83453. /**
  83454. * Interpolates a Vector3 linearl
  83455. * @param startValue Start value of the animation curve
  83456. * @param endValue End value of the animation curve
  83457. * @param gradient Scalar amount to interpolate
  83458. * @returns Interpolated scalar value
  83459. */
  83460. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  83461. /**
  83462. * Interpolates a Vector3 cubically
  83463. * @param startValue Start value of the animation curve
  83464. * @param outTangent End tangent of the animation
  83465. * @param endValue End value of the animation curve
  83466. * @param inTangent Start tangent of the animation curve
  83467. * @param gradient Scalar amount to interpolate
  83468. * @returns InterpolatedVector3 value
  83469. */
  83470. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  83471. /**
  83472. * Interpolates a Vector2 linearly
  83473. * @param startValue Start value of the animation curve
  83474. * @param endValue End value of the animation curve
  83475. * @param gradient Scalar amount to interpolate
  83476. * @returns Interpolated Vector2 value
  83477. */
  83478. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  83479. /**
  83480. * Interpolates a Vector2 cubically
  83481. * @param startValue Start value of the animation curve
  83482. * @param outTangent End tangent of the animation
  83483. * @param endValue End value of the animation curve
  83484. * @param inTangent Start tangent of the animation curve
  83485. * @param gradient Scalar amount to interpolate
  83486. * @returns Interpolated Vector2 value
  83487. */
  83488. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  83489. /**
  83490. * Interpolates a size linearly
  83491. * @param startValue Start value of the animation curve
  83492. * @param endValue End value of the animation curve
  83493. * @param gradient Scalar amount to interpolate
  83494. * @returns Interpolated Size value
  83495. */
  83496. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  83497. /**
  83498. * Interpolates a Color3 linearly
  83499. * @param startValue Start value of the animation curve
  83500. * @param endValue End value of the animation curve
  83501. * @param gradient Scalar amount to interpolate
  83502. * @returns Interpolated Color3 value
  83503. */
  83504. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  83505. /**
  83506. * @hidden Internal use only
  83507. */
  83508. _getKeyValue(value: any): any;
  83509. /**
  83510. * @hidden Internal use only
  83511. */
  83512. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  83513. /**
  83514. * Defines the function to use to interpolate matrices
  83515. * @param startValue defines the start matrix
  83516. * @param endValue defines the end matrix
  83517. * @param gradient defines the gradient between both matrices
  83518. * @param result defines an optional target matrix where to store the interpolation
  83519. * @returns the interpolated matrix
  83520. */
  83521. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  83522. /**
  83523. * Makes a copy of the animation
  83524. * @returns Cloned animation
  83525. */
  83526. clone(): Animation;
  83527. /**
  83528. * Sets the key frames of the animation
  83529. * @param values The animation key frames to set
  83530. */
  83531. setKeys(values: Array<IAnimationKey>): void;
  83532. /**
  83533. * Serializes the animation to an object
  83534. * @returns Serialized object
  83535. */
  83536. serialize(): any;
  83537. /**
  83538. * Float animation type
  83539. */
  83540. private static _ANIMATIONTYPE_FLOAT;
  83541. /**
  83542. * Vector3 animation type
  83543. */
  83544. private static _ANIMATIONTYPE_VECTOR3;
  83545. /**
  83546. * Quaternion animation type
  83547. */
  83548. private static _ANIMATIONTYPE_QUATERNION;
  83549. /**
  83550. * Matrix animation type
  83551. */
  83552. private static _ANIMATIONTYPE_MATRIX;
  83553. /**
  83554. * Color3 animation type
  83555. */
  83556. private static _ANIMATIONTYPE_COLOR3;
  83557. /**
  83558. * Vector2 animation type
  83559. */
  83560. private static _ANIMATIONTYPE_VECTOR2;
  83561. /**
  83562. * Size animation type
  83563. */
  83564. private static _ANIMATIONTYPE_SIZE;
  83565. /**
  83566. * Relative Loop Mode
  83567. */
  83568. private static _ANIMATIONLOOPMODE_RELATIVE;
  83569. /**
  83570. * Cycle Loop Mode
  83571. */
  83572. private static _ANIMATIONLOOPMODE_CYCLE;
  83573. /**
  83574. * Constant Loop Mode
  83575. */
  83576. private static _ANIMATIONLOOPMODE_CONSTANT;
  83577. /**
  83578. * Get the float animation type
  83579. */
  83580. static readonly ANIMATIONTYPE_FLOAT: number;
  83581. /**
  83582. * Get the Vector3 animation type
  83583. */
  83584. static readonly ANIMATIONTYPE_VECTOR3: number;
  83585. /**
  83586. * Get the Vector2 animation type
  83587. */
  83588. static readonly ANIMATIONTYPE_VECTOR2: number;
  83589. /**
  83590. * Get the Size animation type
  83591. */
  83592. static readonly ANIMATIONTYPE_SIZE: number;
  83593. /**
  83594. * Get the Quaternion animation type
  83595. */
  83596. static readonly ANIMATIONTYPE_QUATERNION: number;
  83597. /**
  83598. * Get the Matrix animation type
  83599. */
  83600. static readonly ANIMATIONTYPE_MATRIX: number;
  83601. /**
  83602. * Get the Color3 animation type
  83603. */
  83604. static readonly ANIMATIONTYPE_COLOR3: number;
  83605. /**
  83606. * Get the Relative Loop Mode
  83607. */
  83608. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  83609. /**
  83610. * Get the Cycle Loop Mode
  83611. */
  83612. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  83613. /**
  83614. * Get the Constant Loop Mode
  83615. */
  83616. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  83617. /** @hidden */
  83618. static _UniversalLerp(left: any, right: any, amount: number): any;
  83619. /**
  83620. * Parses an animation object and creates an animation
  83621. * @param parsedAnimation Parsed animation object
  83622. * @returns Animation object
  83623. */
  83624. static Parse(parsedAnimation: any): Animation;
  83625. /**
  83626. * Appends the serialized animations from the source animations
  83627. * @param source Source containing the animations
  83628. * @param destination Target to store the animations
  83629. */
  83630. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  83631. }
  83632. }
  83633. declare module BABYLON {
  83634. /**
  83635. * Base class of all the textures in babylon.
  83636. * It groups all the common properties the materials, post process, lights... might need
  83637. * in order to make a correct use of the texture.
  83638. */
  83639. export class BaseTexture implements IAnimatable {
  83640. /**
  83641. * Default anisotropic filtering level for the application.
  83642. * It is set to 4 as a good tradeoff between perf and quality.
  83643. */
  83644. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  83645. /**
  83646. * Gets or sets the unique id of the texture
  83647. */
  83648. uniqueId: number;
  83649. /**
  83650. * Define the name of the texture.
  83651. */
  83652. name: string;
  83653. /**
  83654. * Gets or sets an object used to store user defined information.
  83655. */
  83656. metadata: any;
  83657. /**
  83658. * For internal use only. Please do not use.
  83659. */
  83660. reservedDataStore: any;
  83661. private _hasAlpha;
  83662. /**
  83663. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  83664. */
  83665. hasAlpha: boolean;
  83666. /**
  83667. * Defines if the alpha value should be determined via the rgb values.
  83668. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  83669. */
  83670. getAlphaFromRGB: boolean;
  83671. /**
  83672. * Intensity or strength of the texture.
  83673. * It is commonly used by materials to fine tune the intensity of the texture
  83674. */
  83675. level: number;
  83676. /**
  83677. * Define the UV chanel to use starting from 0 and defaulting to 0.
  83678. * This is part of the texture as textures usually maps to one uv set.
  83679. */
  83680. coordinatesIndex: number;
  83681. private _coordinatesMode;
  83682. /**
  83683. * How a texture is mapped.
  83684. *
  83685. * | Value | Type | Description |
  83686. * | ----- | ----------------------------------- | ----------- |
  83687. * | 0 | EXPLICIT_MODE | |
  83688. * | 1 | SPHERICAL_MODE | |
  83689. * | 2 | PLANAR_MODE | |
  83690. * | 3 | CUBIC_MODE | |
  83691. * | 4 | PROJECTION_MODE | |
  83692. * | 5 | SKYBOX_MODE | |
  83693. * | 6 | INVCUBIC_MODE | |
  83694. * | 7 | EQUIRECTANGULAR_MODE | |
  83695. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  83696. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  83697. */
  83698. coordinatesMode: number;
  83699. /**
  83700. * | Value | Type | Description |
  83701. * | ----- | ------------------ | ----------- |
  83702. * | 0 | CLAMP_ADDRESSMODE | |
  83703. * | 1 | WRAP_ADDRESSMODE | |
  83704. * | 2 | MIRROR_ADDRESSMODE | |
  83705. */
  83706. wrapU: number;
  83707. /**
  83708. * | Value | Type | Description |
  83709. * | ----- | ------------------ | ----------- |
  83710. * | 0 | CLAMP_ADDRESSMODE | |
  83711. * | 1 | WRAP_ADDRESSMODE | |
  83712. * | 2 | MIRROR_ADDRESSMODE | |
  83713. */
  83714. wrapV: number;
  83715. /**
  83716. * | Value | Type | Description |
  83717. * | ----- | ------------------ | ----------- |
  83718. * | 0 | CLAMP_ADDRESSMODE | |
  83719. * | 1 | WRAP_ADDRESSMODE | |
  83720. * | 2 | MIRROR_ADDRESSMODE | |
  83721. */
  83722. wrapR: number;
  83723. /**
  83724. * With compliant hardware and browser (supporting anisotropic filtering)
  83725. * this defines the level of anisotropic filtering in the texture.
  83726. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  83727. */
  83728. anisotropicFilteringLevel: number;
  83729. /**
  83730. * Define if the texture is a cube texture or if false a 2d texture.
  83731. */
  83732. isCube: boolean;
  83733. /**
  83734. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  83735. */
  83736. is3D: boolean;
  83737. /**
  83738. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  83739. * HDR texture are usually stored in linear space.
  83740. * This only impacts the PBR and Background materials
  83741. */
  83742. gammaSpace: boolean;
  83743. /**
  83744. * Gets whether or not the texture contains RGBD data.
  83745. */
  83746. readonly isRGBD: boolean;
  83747. /**
  83748. * Is Z inverted in the texture (useful in a cube texture).
  83749. */
  83750. invertZ: boolean;
  83751. /**
  83752. * Are mip maps generated for this texture or not.
  83753. */
  83754. readonly noMipmap: boolean;
  83755. /**
  83756. * @hidden
  83757. */
  83758. lodLevelInAlpha: boolean;
  83759. /**
  83760. * With prefiltered texture, defined the offset used during the prefiltering steps.
  83761. */
  83762. lodGenerationOffset: number;
  83763. /**
  83764. * With prefiltered texture, defined the scale used during the prefiltering steps.
  83765. */
  83766. lodGenerationScale: number;
  83767. /**
  83768. * Define if the texture is a render target.
  83769. */
  83770. isRenderTarget: boolean;
  83771. /**
  83772. * Define the unique id of the texture in the scene.
  83773. */
  83774. readonly uid: string;
  83775. /**
  83776. * Return a string representation of the texture.
  83777. * @returns the texture as a string
  83778. */
  83779. toString(): string;
  83780. /**
  83781. * Get the class name of the texture.
  83782. * @returns "BaseTexture"
  83783. */
  83784. getClassName(): string;
  83785. /**
  83786. * Define the list of animation attached to the texture.
  83787. */
  83788. animations: Animation[];
  83789. /**
  83790. * An event triggered when the texture is disposed.
  83791. */
  83792. onDisposeObservable: Observable<BaseTexture>;
  83793. private _onDisposeObserver;
  83794. /**
  83795. * Callback triggered when the texture has been disposed.
  83796. * Kept for back compatibility, you can use the onDisposeObservable instead.
  83797. */
  83798. onDispose: () => void;
  83799. /**
  83800. * Define the current state of the loading sequence when in delayed load mode.
  83801. */
  83802. delayLoadState: number;
  83803. private _scene;
  83804. /** @hidden */
  83805. _texture: Nullable<InternalTexture>;
  83806. private _uid;
  83807. /**
  83808. * Define if the texture is preventinga material to render or not.
  83809. * If not and the texture is not ready, the engine will use a default black texture instead.
  83810. */
  83811. readonly isBlocking: boolean;
  83812. /**
  83813. * Instantiates a new BaseTexture.
  83814. * Base class of all the textures in babylon.
  83815. * It groups all the common properties the materials, post process, lights... might need
  83816. * in order to make a correct use of the texture.
  83817. * @param scene Define the scene the texture blongs to
  83818. */
  83819. constructor(scene: Nullable<Scene>);
  83820. /**
  83821. * Get the scene the texture belongs to.
  83822. * @returns the scene or null if undefined
  83823. */
  83824. getScene(): Nullable<Scene>;
  83825. /**
  83826. * Get the texture transform matrix used to offset tile the texture for istance.
  83827. * @returns the transformation matrix
  83828. */
  83829. getTextureMatrix(): Matrix;
  83830. /**
  83831. * Get the texture reflection matrix used to rotate/transform the reflection.
  83832. * @returns the reflection matrix
  83833. */
  83834. getReflectionTextureMatrix(): Matrix;
  83835. /**
  83836. * Get the underlying lower level texture from Babylon.
  83837. * @returns the insternal texture
  83838. */
  83839. getInternalTexture(): Nullable<InternalTexture>;
  83840. /**
  83841. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  83842. * @returns true if ready or not blocking
  83843. */
  83844. isReadyOrNotBlocking(): boolean;
  83845. /**
  83846. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  83847. * @returns true if fully ready
  83848. */
  83849. isReady(): boolean;
  83850. private _cachedSize;
  83851. /**
  83852. * Get the size of the texture.
  83853. * @returns the texture size.
  83854. */
  83855. getSize(): ISize;
  83856. /**
  83857. * Get the base size of the texture.
  83858. * It can be different from the size if the texture has been resized for POT for instance
  83859. * @returns the base size
  83860. */
  83861. getBaseSize(): ISize;
  83862. /**
  83863. * Update the sampling mode of the texture.
  83864. * Default is Trilinear mode.
  83865. *
  83866. * | Value | Type | Description |
  83867. * | ----- | ------------------ | ----------- |
  83868. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  83869. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  83870. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  83871. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  83872. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  83873. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  83874. * | 7 | NEAREST_LINEAR | |
  83875. * | 8 | NEAREST_NEAREST | |
  83876. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  83877. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  83878. * | 11 | LINEAR_LINEAR | |
  83879. * | 12 | LINEAR_NEAREST | |
  83880. *
  83881. * > _mag_: magnification filter (close to the viewer)
  83882. * > _min_: minification filter (far from the viewer)
  83883. * > _mip_: filter used between mip map levels
  83884. *@param samplingMode Define the new sampling mode of the texture
  83885. */
  83886. updateSamplingMode(samplingMode: number): void;
  83887. /**
  83888. * Scales the texture if is `canRescale()`
  83889. * @param ratio the resize factor we want to use to rescale
  83890. */
  83891. scale(ratio: number): void;
  83892. /**
  83893. * Get if the texture can rescale.
  83894. */
  83895. readonly canRescale: boolean;
  83896. /** @hidden */
  83897. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  83898. /** @hidden */
  83899. _rebuild(): void;
  83900. /**
  83901. * Triggers the load sequence in delayed load mode.
  83902. */
  83903. delayLoad(): void;
  83904. /**
  83905. * Clones the texture.
  83906. * @returns the cloned texture
  83907. */
  83908. clone(): Nullable<BaseTexture>;
  83909. /**
  83910. * Get the texture underlying type (INT, FLOAT...)
  83911. */
  83912. readonly textureType: number;
  83913. /**
  83914. * Get the texture underlying format (RGB, RGBA...)
  83915. */
  83916. readonly textureFormat: number;
  83917. /**
  83918. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  83919. * This will returns an RGBA array buffer containing either in values (0-255) or
  83920. * float values (0-1) depending of the underlying buffer type.
  83921. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  83922. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  83923. * @param buffer defines a user defined buffer to fill with data (can be null)
  83924. * @returns The Array buffer containing the pixels data.
  83925. */
  83926. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  83927. /**
  83928. * Release and destroy the underlying lower level texture aka internalTexture.
  83929. */
  83930. releaseInternalTexture(): void;
  83931. /**
  83932. * Get the polynomial representation of the texture data.
  83933. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  83934. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  83935. */
  83936. sphericalPolynomial: Nullable<SphericalPolynomial>;
  83937. /** @hidden */
  83938. readonly _lodTextureHigh: Nullable<BaseTexture>;
  83939. /** @hidden */
  83940. readonly _lodTextureMid: Nullable<BaseTexture>;
  83941. /** @hidden */
  83942. readonly _lodTextureLow: Nullable<BaseTexture>;
  83943. /**
  83944. * Dispose the texture and release its associated resources.
  83945. */
  83946. dispose(): void;
  83947. /**
  83948. * Serialize the texture into a JSON representation that can be parsed later on.
  83949. * @returns the JSON representation of the texture
  83950. */
  83951. serialize(): any;
  83952. /**
  83953. * Helper function to be called back once a list of texture contains only ready textures.
  83954. * @param textures Define the list of textures to wait for
  83955. * @param callback Define the callback triggered once the entire list will be ready
  83956. */
  83957. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  83958. }
  83959. }
  83960. declare module BABYLON {
  83961. /**
  83962. * Uniform buffer objects.
  83963. *
  83964. * Handles blocks of uniform on the GPU.
  83965. *
  83966. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  83967. *
  83968. * For more information, please refer to :
  83969. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  83970. */
  83971. export class UniformBuffer {
  83972. private _engine;
  83973. private _buffer;
  83974. private _data;
  83975. private _bufferData;
  83976. private _dynamic?;
  83977. private _uniformLocations;
  83978. private _uniformSizes;
  83979. private _uniformLocationPointer;
  83980. private _needSync;
  83981. private _noUBO;
  83982. private _currentEffect;
  83983. private static _MAX_UNIFORM_SIZE;
  83984. private static _tempBuffer;
  83985. /**
  83986. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  83987. * This is dynamic to allow compat with webgl 1 and 2.
  83988. * You will need to pass the name of the uniform as well as the value.
  83989. */
  83990. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  83991. /**
  83992. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  83993. * This is dynamic to allow compat with webgl 1 and 2.
  83994. * You will need to pass the name of the uniform as well as the value.
  83995. */
  83996. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  83997. /**
  83998. * Lambda to Update a single float in a uniform buffer.
  83999. * This is dynamic to allow compat with webgl 1 and 2.
  84000. * You will need to pass the name of the uniform as well as the value.
  84001. */
  84002. updateFloat: (name: string, x: number) => void;
  84003. /**
  84004. * Lambda to Update a vec2 of float in a uniform buffer.
  84005. * This is dynamic to allow compat with webgl 1 and 2.
  84006. * You will need to pass the name of the uniform as well as the value.
  84007. */
  84008. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  84009. /**
  84010. * Lambda to Update a vec3 of float in a uniform buffer.
  84011. * This is dynamic to allow compat with webgl 1 and 2.
  84012. * You will need to pass the name of the uniform as well as the value.
  84013. */
  84014. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  84015. /**
  84016. * Lambda to Update a vec4 of float in a uniform buffer.
  84017. * This is dynamic to allow compat with webgl 1 and 2.
  84018. * You will need to pass the name of the uniform as well as the value.
  84019. */
  84020. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  84021. /**
  84022. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  84023. * This is dynamic to allow compat with webgl 1 and 2.
  84024. * You will need to pass the name of the uniform as well as the value.
  84025. */
  84026. updateMatrix: (name: string, mat: Matrix) => void;
  84027. /**
  84028. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  84029. * This is dynamic to allow compat with webgl 1 and 2.
  84030. * You will need to pass the name of the uniform as well as the value.
  84031. */
  84032. updateVector3: (name: string, vector: Vector3) => void;
  84033. /**
  84034. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  84035. * This is dynamic to allow compat with webgl 1 and 2.
  84036. * You will need to pass the name of the uniform as well as the value.
  84037. */
  84038. updateVector4: (name: string, vector: Vector4) => void;
  84039. /**
  84040. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  84041. * This is dynamic to allow compat with webgl 1 and 2.
  84042. * You will need to pass the name of the uniform as well as the value.
  84043. */
  84044. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  84045. /**
  84046. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  84047. * This is dynamic to allow compat with webgl 1 and 2.
  84048. * You will need to pass the name of the uniform as well as the value.
  84049. */
  84050. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  84051. /**
  84052. * Instantiates a new Uniform buffer objects.
  84053. *
  84054. * Handles blocks of uniform on the GPU.
  84055. *
  84056. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  84057. *
  84058. * For more information, please refer to :
  84059. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  84060. * @param engine Define the engine the buffer is associated with
  84061. * @param data Define the data contained in the buffer
  84062. * @param dynamic Define if the buffer is updatable
  84063. */
  84064. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  84065. /**
  84066. * Indicates if the buffer is using the WebGL2 UBO implementation,
  84067. * or just falling back on setUniformXXX calls.
  84068. */
  84069. readonly useUbo: boolean;
  84070. /**
  84071. * Indicates if the WebGL underlying uniform buffer is in sync
  84072. * with the javascript cache data.
  84073. */
  84074. readonly isSync: boolean;
  84075. /**
  84076. * Indicates if the WebGL underlying uniform buffer is dynamic.
  84077. * Also, a dynamic UniformBuffer will disable cache verification and always
  84078. * update the underlying WebGL uniform buffer to the GPU.
  84079. * @returns if Dynamic, otherwise false
  84080. */
  84081. isDynamic(): boolean;
  84082. /**
  84083. * The data cache on JS side.
  84084. * @returns the underlying data as a float array
  84085. */
  84086. getData(): Float32Array;
  84087. /**
  84088. * The underlying WebGL Uniform buffer.
  84089. * @returns the webgl buffer
  84090. */
  84091. getBuffer(): Nullable<WebGLBuffer>;
  84092. /**
  84093. * std140 layout specifies how to align data within an UBO structure.
  84094. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  84095. * for specs.
  84096. */
  84097. private _fillAlignment;
  84098. /**
  84099. * Adds an uniform in the buffer.
  84100. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  84101. * for the layout to be correct !
  84102. * @param name Name of the uniform, as used in the uniform block in the shader.
  84103. * @param size Data size, or data directly.
  84104. */
  84105. addUniform(name: string, size: number | number[]): void;
  84106. /**
  84107. * Adds a Matrix 4x4 to the uniform buffer.
  84108. * @param name Name of the uniform, as used in the uniform block in the shader.
  84109. * @param mat A 4x4 matrix.
  84110. */
  84111. addMatrix(name: string, mat: Matrix): void;
  84112. /**
  84113. * Adds a vec2 to the uniform buffer.
  84114. * @param name Name of the uniform, as used in the uniform block in the shader.
  84115. * @param x Define the x component value of the vec2
  84116. * @param y Define the y component value of the vec2
  84117. */
  84118. addFloat2(name: string, x: number, y: number): void;
  84119. /**
  84120. * Adds a vec3 to the uniform buffer.
  84121. * @param name Name of the uniform, as used in the uniform block in the shader.
  84122. * @param x Define the x component value of the vec3
  84123. * @param y Define the y component value of the vec3
  84124. * @param z Define the z component value of the vec3
  84125. */
  84126. addFloat3(name: string, x: number, y: number, z: number): void;
  84127. /**
  84128. * Adds a vec3 to the uniform buffer.
  84129. * @param name Name of the uniform, as used in the uniform block in the shader.
  84130. * @param color Define the vec3 from a Color
  84131. */
  84132. addColor3(name: string, color: Color3): void;
  84133. /**
  84134. * Adds a vec4 to the uniform buffer.
  84135. * @param name Name of the uniform, as used in the uniform block in the shader.
  84136. * @param color Define the rgb components from a Color
  84137. * @param alpha Define the a component of the vec4
  84138. */
  84139. addColor4(name: string, color: Color3, alpha: number): void;
  84140. /**
  84141. * Adds a vec3 to the uniform buffer.
  84142. * @param name Name of the uniform, as used in the uniform block in the shader.
  84143. * @param vector Define the vec3 components from a Vector
  84144. */
  84145. addVector3(name: string, vector: Vector3): void;
  84146. /**
  84147. * Adds a Matrix 3x3 to the uniform buffer.
  84148. * @param name Name of the uniform, as used in the uniform block in the shader.
  84149. */
  84150. addMatrix3x3(name: string): void;
  84151. /**
  84152. * Adds a Matrix 2x2 to the uniform buffer.
  84153. * @param name Name of the uniform, as used in the uniform block in the shader.
  84154. */
  84155. addMatrix2x2(name: string): void;
  84156. /**
  84157. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  84158. */
  84159. create(): void;
  84160. /** @hidden */
  84161. _rebuild(): void;
  84162. /**
  84163. * Updates the WebGL Uniform Buffer on the GPU.
  84164. * If the `dynamic` flag is set to true, no cache comparison is done.
  84165. * Otherwise, the buffer will be updated only if the cache differs.
  84166. */
  84167. update(): void;
  84168. /**
  84169. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  84170. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  84171. * @param data Define the flattened data
  84172. * @param size Define the size of the data.
  84173. */
  84174. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  84175. private _updateMatrix3x3ForUniform;
  84176. private _updateMatrix3x3ForEffect;
  84177. private _updateMatrix2x2ForEffect;
  84178. private _updateMatrix2x2ForUniform;
  84179. private _updateFloatForEffect;
  84180. private _updateFloatForUniform;
  84181. private _updateFloat2ForEffect;
  84182. private _updateFloat2ForUniform;
  84183. private _updateFloat3ForEffect;
  84184. private _updateFloat3ForUniform;
  84185. private _updateFloat4ForEffect;
  84186. private _updateFloat4ForUniform;
  84187. private _updateMatrixForEffect;
  84188. private _updateMatrixForUniform;
  84189. private _updateVector3ForEffect;
  84190. private _updateVector3ForUniform;
  84191. private _updateVector4ForEffect;
  84192. private _updateVector4ForUniform;
  84193. private _updateColor3ForEffect;
  84194. private _updateColor3ForUniform;
  84195. private _updateColor4ForEffect;
  84196. private _updateColor4ForUniform;
  84197. /**
  84198. * Sets a sampler uniform on the effect.
  84199. * @param name Define the name of the sampler.
  84200. * @param texture Define the texture to set in the sampler
  84201. */
  84202. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  84203. /**
  84204. * Directly updates the value of the uniform in the cache AND on the GPU.
  84205. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  84206. * @param data Define the flattened data
  84207. */
  84208. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  84209. /**
  84210. * Binds this uniform buffer to an effect.
  84211. * @param effect Define the effect to bind the buffer to
  84212. * @param name Name of the uniform block in the shader.
  84213. */
  84214. bindToEffect(effect: Effect, name: string): void;
  84215. /**
  84216. * Disposes the uniform buffer.
  84217. */
  84218. dispose(): void;
  84219. }
  84220. }
  84221. declare module BABYLON {
  84222. /**
  84223. * This represents the required contract to create a new type of texture loader.
  84224. */
  84225. export interface IInternalTextureLoader {
  84226. /**
  84227. * Defines wether the loader supports cascade loading the different faces.
  84228. */
  84229. supportCascades: boolean;
  84230. /**
  84231. * This returns if the loader support the current file information.
  84232. * @param extension defines the file extension of the file being loaded
  84233. * @param textureFormatInUse defines the current compressed format in use iun the engine
  84234. * @param fallback defines the fallback internal texture if any
  84235. * @param isBase64 defines whether the texture is encoded as a base64
  84236. * @param isBuffer defines whether the texture data are stored as a buffer
  84237. * @returns true if the loader can load the specified file
  84238. */
  84239. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  84240. /**
  84241. * Transform the url before loading if required.
  84242. * @param rootUrl the url of the texture
  84243. * @param textureFormatInUse defines the current compressed format in use iun the engine
  84244. * @returns the transformed texture
  84245. */
  84246. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  84247. /**
  84248. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  84249. * @param rootUrl the url of the texture
  84250. * @param textureFormatInUse defines the current compressed format in use iun the engine
  84251. * @returns the fallback texture
  84252. */
  84253. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  84254. /**
  84255. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  84256. * @param data contains the texture data
  84257. * @param texture defines the BabylonJS internal texture
  84258. * @param createPolynomials will be true if polynomials have been requested
  84259. * @param onLoad defines the callback to trigger once the texture is ready
  84260. * @param onError defines the callback to trigger in case of error
  84261. */
  84262. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  84263. /**
  84264. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  84265. * @param data contains the texture data
  84266. * @param texture defines the BabylonJS internal texture
  84267. * @param callback defines the method to call once ready to upload
  84268. */
  84269. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  84270. }
  84271. }
  84272. declare module BABYLON {
  84273. /**
  84274. * Creation options of the multi render target texture.
  84275. */
  84276. export interface IMultiRenderTargetOptions {
  84277. /**
  84278. * Define if the texture needs to create mip maps after render.
  84279. */
  84280. generateMipMaps?: boolean;
  84281. /**
  84282. * Define the types of all the draw buffers we want to create
  84283. */
  84284. types?: number[];
  84285. /**
  84286. * Define the sampling modes of all the draw buffers we want to create
  84287. */
  84288. samplingModes?: number[];
  84289. /**
  84290. * Define if a depth buffer is required
  84291. */
  84292. generateDepthBuffer?: boolean;
  84293. /**
  84294. * Define if a stencil buffer is required
  84295. */
  84296. generateStencilBuffer?: boolean;
  84297. /**
  84298. * Define if a depth texture is required instead of a depth buffer
  84299. */
  84300. generateDepthTexture?: boolean;
  84301. /**
  84302. * Define the number of desired draw buffers
  84303. */
  84304. textureCount?: number;
  84305. /**
  84306. * Define if aspect ratio should be adapted to the texture or stay the scene one
  84307. */
  84308. doNotChangeAspectRatio?: boolean;
  84309. /**
  84310. * Define the default type of the buffers we are creating
  84311. */
  84312. defaultType?: number;
  84313. }
  84314. /**
  84315. * A multi render target, like a render target provides the ability to render to a texture.
  84316. * Unlike the render target, it can render to several draw buffers in one draw.
  84317. * This is specially interesting in deferred rendering or for any effects requiring more than
  84318. * just one color from a single pass.
  84319. */
  84320. export class MultiRenderTarget extends RenderTargetTexture {
  84321. private _internalTextures;
  84322. private _textures;
  84323. private _multiRenderTargetOptions;
  84324. /**
  84325. * Get if draw buffers are currently supported by the used hardware and browser.
  84326. */
  84327. readonly isSupported: boolean;
  84328. /**
  84329. * Get the list of textures generated by the multi render target.
  84330. */
  84331. readonly textures: Texture[];
  84332. /**
  84333. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  84334. */
  84335. readonly depthTexture: Texture;
  84336. /**
  84337. * Set the wrapping mode on U of all the textures we are rendering to.
  84338. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  84339. */
  84340. wrapU: number;
  84341. /**
  84342. * Set the wrapping mode on V of all the textures we are rendering to.
  84343. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  84344. */
  84345. wrapV: number;
  84346. /**
  84347. * Instantiate a new multi render target texture.
  84348. * A multi render target, like a render target provides the ability to render to a texture.
  84349. * Unlike the render target, it can render to several draw buffers in one draw.
  84350. * This is specially interesting in deferred rendering or for any effects requiring more than
  84351. * just one color from a single pass.
  84352. * @param name Define the name of the texture
  84353. * @param size Define the size of the buffers to render to
  84354. * @param count Define the number of target we are rendering into
  84355. * @param scene Define the scene the texture belongs to
  84356. * @param options Define the options used to create the multi render target
  84357. */
  84358. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  84359. /** @hidden */
  84360. _rebuild(): void;
  84361. private _createInternalTextures;
  84362. private _createTextures;
  84363. /**
  84364. * Define the number of samples used if MSAA is enabled.
  84365. */
  84366. samples: number;
  84367. /**
  84368. * Resize all the textures in the multi render target.
  84369. * Be carrefull as it will recreate all the data in the new texture.
  84370. * @param size Define the new size
  84371. */
  84372. resize(size: any): void;
  84373. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84374. /**
  84375. * Dispose the render targets and their associated resources
  84376. */
  84377. dispose(): void;
  84378. /**
  84379. * Release all the underlying texture used as draw buffers.
  84380. */
  84381. releaseInternalTextures(): void;
  84382. }
  84383. }
  84384. declare module BABYLON {
  84385. /**
  84386. * Class used to work with sound analyzer using fast fourier transform (FFT)
  84387. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84388. */
  84389. export class Analyser {
  84390. /**
  84391. * Gets or sets the smoothing
  84392. * @ignorenaming
  84393. */
  84394. SMOOTHING: number;
  84395. /**
  84396. * Gets or sets the FFT table size
  84397. * @ignorenaming
  84398. */
  84399. FFT_SIZE: number;
  84400. /**
  84401. * Gets or sets the bar graph amplitude
  84402. * @ignorenaming
  84403. */
  84404. BARGRAPHAMPLITUDE: number;
  84405. /**
  84406. * Gets or sets the position of the debug canvas
  84407. * @ignorenaming
  84408. */
  84409. DEBUGCANVASPOS: {
  84410. x: number;
  84411. y: number;
  84412. };
  84413. /**
  84414. * Gets or sets the debug canvas size
  84415. * @ignorenaming
  84416. */
  84417. DEBUGCANVASSIZE: {
  84418. width: number;
  84419. height: number;
  84420. };
  84421. private _byteFreqs;
  84422. private _byteTime;
  84423. private _floatFreqs;
  84424. private _webAudioAnalyser;
  84425. private _debugCanvas;
  84426. private _debugCanvasContext;
  84427. private _scene;
  84428. private _registerFunc;
  84429. private _audioEngine;
  84430. /**
  84431. * Creates a new analyser
  84432. * @param scene defines hosting scene
  84433. */
  84434. constructor(scene: Scene);
  84435. /**
  84436. * Get the number of data values you will have to play with for the visualization
  84437. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  84438. * @returns a number
  84439. */
  84440. getFrequencyBinCount(): number;
  84441. /**
  84442. * Gets the current frequency data as a byte array
  84443. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  84444. * @returns a Uint8Array
  84445. */
  84446. getByteFrequencyData(): Uint8Array;
  84447. /**
  84448. * Gets the current waveform as a byte array
  84449. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  84450. * @returns a Uint8Array
  84451. */
  84452. getByteTimeDomainData(): Uint8Array;
  84453. /**
  84454. * Gets the current frequency data as a float array
  84455. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  84456. * @returns a Float32Array
  84457. */
  84458. getFloatFrequencyData(): Float32Array;
  84459. /**
  84460. * Renders the debug canvas
  84461. */
  84462. drawDebugCanvas(): void;
  84463. /**
  84464. * Stops rendering the debug canvas and removes it
  84465. */
  84466. stopDebugCanvas(): void;
  84467. /**
  84468. * Connects two audio nodes
  84469. * @param inputAudioNode defines first node to connect
  84470. * @param outputAudioNode defines second node to connect
  84471. */
  84472. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  84473. /**
  84474. * Releases all associated resources
  84475. */
  84476. dispose(): void;
  84477. }
  84478. }
  84479. declare module BABYLON {
  84480. /**
  84481. * This represents an audio engine and it is responsible
  84482. * to play, synchronize and analyse sounds throughout the application.
  84483. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84484. */
  84485. export interface IAudioEngine extends IDisposable {
  84486. /**
  84487. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  84488. */
  84489. readonly canUseWebAudio: boolean;
  84490. /**
  84491. * Gets the current AudioContext if available.
  84492. */
  84493. readonly audioContext: Nullable<AudioContext>;
  84494. /**
  84495. * The master gain node defines the global audio volume of your audio engine.
  84496. */
  84497. readonly masterGain: GainNode;
  84498. /**
  84499. * Gets whether or not mp3 are supported by your browser.
  84500. */
  84501. readonly isMP3supported: boolean;
  84502. /**
  84503. * Gets whether or not ogg are supported by your browser.
  84504. */
  84505. readonly isOGGsupported: boolean;
  84506. /**
  84507. * Defines if Babylon should emit a warning if WebAudio is not supported.
  84508. * @ignoreNaming
  84509. */
  84510. WarnedWebAudioUnsupported: boolean;
  84511. /**
  84512. * Defines if the audio engine relies on a custom unlocked button.
  84513. * In this case, the embedded button will not be displayed.
  84514. */
  84515. useCustomUnlockedButton: boolean;
  84516. /**
  84517. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  84518. */
  84519. readonly unlocked: boolean;
  84520. /**
  84521. * Event raised when audio has been unlocked on the browser.
  84522. */
  84523. onAudioUnlockedObservable: Observable<AudioEngine>;
  84524. /**
  84525. * Event raised when audio has been locked on the browser.
  84526. */
  84527. onAudioLockedObservable: Observable<AudioEngine>;
  84528. /**
  84529. * Flags the audio engine in Locked state.
  84530. * This happens due to new browser policies preventing audio to autoplay.
  84531. */
  84532. lock(): void;
  84533. /**
  84534. * Unlocks the audio engine once a user action has been done on the dom.
  84535. * This is helpful to resume play once browser policies have been satisfied.
  84536. */
  84537. unlock(): void;
  84538. }
  84539. /**
  84540. * This represents the default audio engine used in babylon.
  84541. * It is responsible to play, synchronize and analyse sounds throughout the application.
  84542. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  84543. */
  84544. export class AudioEngine implements IAudioEngine {
  84545. private _audioContext;
  84546. private _audioContextInitialized;
  84547. private _muteButton;
  84548. private _hostElement;
  84549. /**
  84550. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  84551. */
  84552. canUseWebAudio: boolean;
  84553. /**
  84554. * The master gain node defines the global audio volume of your audio engine.
  84555. */
  84556. masterGain: GainNode;
  84557. /**
  84558. * Defines if Babylon should emit a warning if WebAudio is not supported.
  84559. * @ignoreNaming
  84560. */
  84561. WarnedWebAudioUnsupported: boolean;
  84562. /**
  84563. * Gets whether or not mp3 are supported by your browser.
  84564. */
  84565. isMP3supported: boolean;
  84566. /**
  84567. * Gets whether or not ogg are supported by your browser.
  84568. */
  84569. isOGGsupported: boolean;
  84570. /**
  84571. * Gets whether audio has been unlocked on the device.
  84572. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  84573. * a user interaction has happened.
  84574. */
  84575. unlocked: boolean;
  84576. /**
  84577. * Defines if the audio engine relies on a custom unlocked button.
  84578. * In this case, the embedded button will not be displayed.
  84579. */
  84580. useCustomUnlockedButton: boolean;
  84581. /**
  84582. * Event raised when audio has been unlocked on the browser.
  84583. */
  84584. onAudioUnlockedObservable: Observable<AudioEngine>;
  84585. /**
  84586. * Event raised when audio has been locked on the browser.
  84587. */
  84588. onAudioLockedObservable: Observable<AudioEngine>;
  84589. /**
  84590. * Gets the current AudioContext if available.
  84591. */
  84592. readonly audioContext: Nullable<AudioContext>;
  84593. private _connectedAnalyser;
  84594. /**
  84595. * Instantiates a new audio engine.
  84596. *
  84597. * There should be only one per page as some browsers restrict the number
  84598. * of audio contexts you can create.
  84599. * @param hostElement defines the host element where to display the mute icon if necessary
  84600. */
  84601. constructor(hostElement?: Nullable<HTMLElement>);
  84602. /**
  84603. * Flags the audio engine in Locked state.
  84604. * This happens due to new browser policies preventing audio to autoplay.
  84605. */
  84606. lock(): void;
  84607. /**
  84608. * Unlocks the audio engine once a user action has been done on the dom.
  84609. * This is helpful to resume play once browser policies have been satisfied.
  84610. */
  84611. unlock(): void;
  84612. private _resumeAudioContext;
  84613. private _initializeAudioContext;
  84614. private _tryToRun;
  84615. private _triggerRunningState;
  84616. private _triggerSuspendedState;
  84617. private _displayMuteButton;
  84618. private _moveButtonToTopLeft;
  84619. private _onResize;
  84620. private _hideMuteButton;
  84621. /**
  84622. * Destroy and release the resources associated with the audio ccontext.
  84623. */
  84624. dispose(): void;
  84625. /**
  84626. * Gets the global volume sets on the master gain.
  84627. * @returns the global volume if set or -1 otherwise
  84628. */
  84629. getGlobalVolume(): number;
  84630. /**
  84631. * Sets the global volume of your experience (sets on the master gain).
  84632. * @param newVolume Defines the new global volume of the application
  84633. */
  84634. setGlobalVolume(newVolume: number): void;
  84635. /**
  84636. * Connect the audio engine to an audio analyser allowing some amazing
  84637. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  84638. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  84639. * @param analyser The analyser to connect to the engine
  84640. */
  84641. connectToAnalyser(analyser: Analyser): void;
  84642. }
  84643. }
  84644. declare module BABYLON {
  84645. /**
  84646. * Interface used to present a loading screen while loading a scene
  84647. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84648. */
  84649. export interface ILoadingScreen {
  84650. /**
  84651. * Function called to display the loading screen
  84652. */
  84653. displayLoadingUI: () => void;
  84654. /**
  84655. * Function called to hide the loading screen
  84656. */
  84657. hideLoadingUI: () => void;
  84658. /**
  84659. * Gets or sets the color to use for the background
  84660. */
  84661. loadingUIBackgroundColor: string;
  84662. /**
  84663. * Gets or sets the text to display while loading
  84664. */
  84665. loadingUIText: string;
  84666. }
  84667. /**
  84668. * Class used for the default loading screen
  84669. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84670. */
  84671. export class DefaultLoadingScreen implements ILoadingScreen {
  84672. private _renderingCanvas;
  84673. private _loadingText;
  84674. private _loadingDivBackgroundColor;
  84675. private _loadingDiv;
  84676. private _loadingTextDiv;
  84677. /**
  84678. * Creates a new default loading screen
  84679. * @param _renderingCanvas defines the canvas used to render the scene
  84680. * @param _loadingText defines the default text to display
  84681. * @param _loadingDivBackgroundColor defines the default background color
  84682. */
  84683. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  84684. /**
  84685. * Function called to display the loading screen
  84686. */
  84687. displayLoadingUI(): void;
  84688. /**
  84689. * Function called to hide the loading screen
  84690. */
  84691. hideLoadingUI(): void;
  84692. /**
  84693. * Gets or sets the text to display while loading
  84694. */
  84695. loadingUIText: string;
  84696. /**
  84697. * Gets or sets the color to use for the background
  84698. */
  84699. loadingUIBackgroundColor: string;
  84700. private _resizeLoadingUI;
  84701. }
  84702. }
  84703. declare module BABYLON {
  84704. /**
  84705. * Settings for finer control over video usage
  84706. */
  84707. export interface VideoTextureSettings {
  84708. /**
  84709. * Applies `autoplay` to video, if specified
  84710. */
  84711. autoPlay?: boolean;
  84712. /**
  84713. * Applies `loop` to video, if specified
  84714. */
  84715. loop?: boolean;
  84716. /**
  84717. * Automatically updates internal texture from video at every frame in the render loop
  84718. */
  84719. autoUpdateTexture: boolean;
  84720. /**
  84721. * Image src displayed during the video loading or until the user interacts with the video.
  84722. */
  84723. poster?: string;
  84724. }
  84725. /**
  84726. * If you want to display a video in your scene, this is the special texture for that.
  84727. * This special texture works similar to other textures, with the exception of a few parameters.
  84728. * @see https://doc.babylonjs.com/how_to/video_texture
  84729. */
  84730. export class VideoTexture extends Texture {
  84731. /**
  84732. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  84733. */
  84734. readonly autoUpdateTexture: boolean;
  84735. /**
  84736. * The video instance used by the texture internally
  84737. */
  84738. readonly video: HTMLVideoElement;
  84739. private _onUserActionRequestedObservable;
  84740. /**
  84741. * Event triggerd when a dom action is required by the user to play the video.
  84742. * This happens due to recent changes in browser policies preventing video to auto start.
  84743. */
  84744. readonly onUserActionRequestedObservable: Observable<Texture>;
  84745. private _generateMipMaps;
  84746. private _engine;
  84747. private _stillImageCaptured;
  84748. private _displayingPosterTexture;
  84749. private _settings;
  84750. private _createInternalTextureOnEvent;
  84751. /**
  84752. * Creates a video texture.
  84753. * If you want to display a video in your scene, this is the special texture for that.
  84754. * This special texture works similar to other textures, with the exception of a few parameters.
  84755. * @see https://doc.babylonjs.com/how_to/video_texture
  84756. * @param name optional name, will detect from video source, if not defined
  84757. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  84758. * @param scene is obviously the current scene.
  84759. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  84760. * @param invertY is false by default but can be used to invert video on Y axis
  84761. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  84762. * @param settings allows finer control over video usage
  84763. */
  84764. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  84765. private _getName;
  84766. private _getVideo;
  84767. private _createInternalTexture;
  84768. private reset;
  84769. /**
  84770. * @hidden Internal method to initiate `update`.
  84771. */
  84772. _rebuild(): void;
  84773. /**
  84774. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  84775. */
  84776. update(): void;
  84777. /**
  84778. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  84779. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  84780. */
  84781. updateTexture(isVisible: boolean): void;
  84782. protected _updateInternalTexture: () => void;
  84783. /**
  84784. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  84785. * @param url New url.
  84786. */
  84787. updateURL(url: string): void;
  84788. /**
  84789. * Dispose the texture and release its associated resources.
  84790. */
  84791. dispose(): void;
  84792. /**
  84793. * Creates a video texture straight from a stream.
  84794. * @param scene Define the scene the texture should be created in
  84795. * @param stream Define the stream the texture should be created from
  84796. * @returns The created video texture as a promise
  84797. */
  84798. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  84799. /**
  84800. * Creates a video texture straight from your WebCam video feed.
  84801. * @param scene Define the scene the texture should be created in
  84802. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  84803. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  84804. * @returns The created video texture as a promise
  84805. */
  84806. static CreateFromWebCamAsync(scene: Scene, constraints: {
  84807. minWidth: number;
  84808. maxWidth: number;
  84809. minHeight: number;
  84810. maxHeight: number;
  84811. deviceId: string;
  84812. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  84813. /**
  84814. * Creates a video texture straight from your WebCam video feed.
  84815. * @param scene Define the scene the texture should be created in
  84816. * @param onReady Define a callback to triggered once the texture will be ready
  84817. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  84818. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  84819. */
  84820. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  84821. minWidth: number;
  84822. maxWidth: number;
  84823. minHeight: number;
  84824. maxHeight: number;
  84825. deviceId: string;
  84826. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  84827. }
  84828. }
  84829. declare module BABYLON {
  84830. /**
  84831. * Interface for attribute information associated with buffer instanciation
  84832. */
  84833. export class InstancingAttributeInfo {
  84834. /**
  84835. * Index/offset of the attribute in the vertex shader
  84836. */
  84837. index: number;
  84838. /**
  84839. * size of the attribute, 1, 2, 3 or 4
  84840. */
  84841. attributeSize: number;
  84842. /**
  84843. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  84844. * default is FLOAT
  84845. */
  84846. attribyteType: number;
  84847. /**
  84848. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  84849. */
  84850. normalized: boolean;
  84851. /**
  84852. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  84853. */
  84854. offset: number;
  84855. /**
  84856. * Name of the GLSL attribute, for debugging purpose only
  84857. */
  84858. attributeName: string;
  84859. }
  84860. /**
  84861. * Define options used to create a depth texture
  84862. */
  84863. export class DepthTextureCreationOptions {
  84864. /** Specifies whether or not a stencil should be allocated in the texture */
  84865. generateStencil?: boolean;
  84866. /** Specifies whether or not bilinear filtering is enable on the texture */
  84867. bilinearFiltering?: boolean;
  84868. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  84869. comparisonFunction?: number;
  84870. /** Specifies if the created texture is a cube texture */
  84871. isCube?: boolean;
  84872. }
  84873. /**
  84874. * Class used to describe the capabilities of the engine relatively to the current browser
  84875. */
  84876. export class EngineCapabilities {
  84877. /** Maximum textures units per fragment shader */
  84878. maxTexturesImageUnits: number;
  84879. /** Maximum texture units per vertex shader */
  84880. maxVertexTextureImageUnits: number;
  84881. /** Maximum textures units in the entire pipeline */
  84882. maxCombinedTexturesImageUnits: number;
  84883. /** Maximum texture size */
  84884. maxTextureSize: number;
  84885. /** Maximum cube texture size */
  84886. maxCubemapTextureSize: number;
  84887. /** Maximum render texture size */
  84888. maxRenderTextureSize: number;
  84889. /** Maximum number of vertex attributes */
  84890. maxVertexAttribs: number;
  84891. /** Maximum number of varyings */
  84892. maxVaryingVectors: number;
  84893. /** Maximum number of uniforms per vertex shader */
  84894. maxVertexUniformVectors: number;
  84895. /** Maximum number of uniforms per fragment shader */
  84896. maxFragmentUniformVectors: number;
  84897. /** Defines if standard derivates (dx/dy) are supported */
  84898. standardDerivatives: boolean;
  84899. /** Defines if s3tc texture compression is supported */
  84900. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  84901. /** Defines if pvrtc texture compression is supported */
  84902. pvrtc: any;
  84903. /** Defines if etc1 texture compression is supported */
  84904. etc1: any;
  84905. /** Defines if etc2 texture compression is supported */
  84906. etc2: any;
  84907. /** Defines if astc texture compression is supported */
  84908. astc: any;
  84909. /** Defines if float textures are supported */
  84910. textureFloat: boolean;
  84911. /** Defines if vertex array objects are supported */
  84912. vertexArrayObject: boolean;
  84913. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  84914. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  84915. /** Gets the maximum level of anisotropy supported */
  84916. maxAnisotropy: number;
  84917. /** Defines if instancing is supported */
  84918. instancedArrays: boolean;
  84919. /** Defines if 32 bits indices are supported */
  84920. uintIndices: boolean;
  84921. /** Defines if high precision shaders are supported */
  84922. highPrecisionShaderSupported: boolean;
  84923. /** Defines if depth reading in the fragment shader is supported */
  84924. fragmentDepthSupported: boolean;
  84925. /** Defines if float texture linear filtering is supported*/
  84926. textureFloatLinearFiltering: boolean;
  84927. /** Defines if rendering to float textures is supported */
  84928. textureFloatRender: boolean;
  84929. /** Defines if half float textures are supported*/
  84930. textureHalfFloat: boolean;
  84931. /** Defines if half float texture linear filtering is supported*/
  84932. textureHalfFloatLinearFiltering: boolean;
  84933. /** Defines if rendering to half float textures is supported */
  84934. textureHalfFloatRender: boolean;
  84935. /** Defines if textureLOD shader command is supported */
  84936. textureLOD: boolean;
  84937. /** Defines if draw buffers extension is supported */
  84938. drawBuffersExtension: boolean;
  84939. /** Defines if depth textures are supported */
  84940. depthTextureExtension: boolean;
  84941. /** Defines if float color buffer are supported */
  84942. colorBufferFloat: boolean;
  84943. /** Gets disjoint timer query extension (null if not supported) */
  84944. timerQuery: EXT_disjoint_timer_query;
  84945. /** Defines if timestamp can be used with timer query */
  84946. canUseTimestampForTimerQuery: boolean;
  84947. /** Function used to let the system compiles shaders in background */
  84948. parallelShaderCompile: {
  84949. MAX_SHADER_COMPILER_THREADS_KHR: number;
  84950. maxShaderCompilerThreadsKHR: (thread: number) => void;
  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). False 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 version of the framework
  85233. */
  85234. static readonly Version: string;
  85235. /**
  85236. * Returns a string describing the current engine
  85237. */
  85238. readonly description: string;
  85239. /**
  85240. * Gets or sets the epsilon value used by collision engine
  85241. */
  85242. static CollisionsEpsilon: number;
  85243. /**
  85244. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  85245. */
  85246. static ShadersRepository: string;
  85247. /**
  85248. * Method called to create the default loading screen.
  85249. * This can be overriden in your own app.
  85250. * @param canvas The rendering canvas element
  85251. * @returns The loading screen
  85252. */
  85253. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  85254. /**
  85255. * Method called to create the default rescale post process on each engine.
  85256. */
  85257. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  85258. /**
  85259. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  85260. */
  85261. forcePOTTextures: boolean;
  85262. /**
  85263. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  85264. */
  85265. isFullscreen: boolean;
  85266. /**
  85267. * Gets a boolean indicating if the pointer is currently locked
  85268. */
  85269. isPointerLock: boolean;
  85270. /**
  85271. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  85272. */
  85273. cullBackFaces: boolean;
  85274. /**
  85275. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  85276. */
  85277. renderEvenInBackground: boolean;
  85278. /**
  85279. * Gets or sets a boolean indicating that cache can be kept between frames
  85280. */
  85281. preventCacheWipeBetweenFrames: boolean;
  85282. /**
  85283. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  85284. **/
  85285. enableOfflineSupport: boolean;
  85286. /**
  85287. * 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)
  85288. **/
  85289. disableManifestCheck: boolean;
  85290. /**
  85291. * Gets the list of created scenes
  85292. */
  85293. scenes: Scene[];
  85294. /**
  85295. * Event raised when a new scene is created
  85296. */
  85297. onNewSceneAddedObservable: Observable<Scene>;
  85298. /**
  85299. * Gets the list of created postprocesses
  85300. */
  85301. postProcesses: PostProcess[];
  85302. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  85303. validateShaderPrograms: boolean;
  85304. /**
  85305. * Observable event triggered each time the rendering canvas is resized
  85306. */
  85307. onResizeObservable: Observable<Engine>;
  85308. /**
  85309. * Observable event triggered each time the canvas loses focus
  85310. */
  85311. onCanvasBlurObservable: Observable<Engine>;
  85312. /**
  85313. * Observable event triggered each time the canvas gains focus
  85314. */
  85315. onCanvasFocusObservable: Observable<Engine>;
  85316. /**
  85317. * Observable event triggered each time the canvas receives pointerout event
  85318. */
  85319. onCanvasPointerOutObservable: Observable<PointerEvent>;
  85320. /**
  85321. * Observable event triggered before each texture is initialized
  85322. */
  85323. onBeforeTextureInitObservable: Observable<Texture>;
  85324. private _vrDisplay;
  85325. private _vrSupported;
  85326. private _oldSize;
  85327. private _oldHardwareScaleFactor;
  85328. private _vrExclusivePointerMode;
  85329. private _webVRInitPromise;
  85330. /**
  85331. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  85332. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  85333. */
  85334. readonly isInVRExclusivePointerMode: boolean;
  85335. /**
  85336. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  85337. */
  85338. disableUniformBuffers: boolean;
  85339. /** @hidden */
  85340. _uniformBuffers: UniformBuffer[];
  85341. /**
  85342. * Gets a boolean indicating that the engine supports uniform buffers
  85343. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85344. */
  85345. readonly supportsUniformBuffers: boolean;
  85346. /**
  85347. * Observable raised when the engine begins a new frame
  85348. */
  85349. onBeginFrameObservable: Observable<Engine>;
  85350. /**
  85351. * If set, will be used to request the next animation frame for the render loop
  85352. */
  85353. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  85354. /**
  85355. * Observable raised when the engine ends the current frame
  85356. */
  85357. onEndFrameObservable: Observable<Engine>;
  85358. /**
  85359. * Observable raised when the engine is about to compile a shader
  85360. */
  85361. onBeforeShaderCompilationObservable: Observable<Engine>;
  85362. /**
  85363. * Observable raised when the engine has jsut compiled a shader
  85364. */
  85365. onAfterShaderCompilationObservable: Observable<Engine>;
  85366. /** @hidden */
  85367. _gl: WebGLRenderingContext;
  85368. private _renderingCanvas;
  85369. private _windowIsBackground;
  85370. private _webGLVersion;
  85371. protected _highPrecisionShadersAllowed: boolean;
  85372. /** @hidden */
  85373. readonly _shouldUseHighPrecisionShader: boolean;
  85374. /**
  85375. * Gets a boolean indicating that only power of 2 textures are supported
  85376. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  85377. */
  85378. readonly needPOTTextures: boolean;
  85379. /** @hidden */
  85380. _badOS: boolean;
  85381. /** @hidden */
  85382. _badDesktopOS: boolean;
  85383. /**
  85384. * Gets or sets a value indicating if we want to disable texture binding optimization.
  85385. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  85386. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  85387. */
  85388. disableTextureBindingOptimization: boolean;
  85389. /**
  85390. * Gets the audio engine
  85391. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85392. * @ignorenaming
  85393. */
  85394. static audioEngine: IAudioEngine;
  85395. /**
  85396. * Default AudioEngine factory responsible of creating the Audio Engine.
  85397. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  85398. */
  85399. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  85400. /**
  85401. * Default offline support factory responsible of creating a tool used to store data locally.
  85402. * By default, this will create a Database object if the workload has been embedded.
  85403. */
  85404. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  85405. private _onFocus;
  85406. private _onBlur;
  85407. private _onCanvasPointerOut;
  85408. private _onCanvasBlur;
  85409. private _onCanvasFocus;
  85410. private _onFullscreenChange;
  85411. private _onPointerLockChange;
  85412. private _onVRDisplayPointerRestricted;
  85413. private _onVRDisplayPointerUnrestricted;
  85414. private _onVrDisplayConnect;
  85415. private _onVrDisplayDisconnect;
  85416. private _onVrDisplayPresentChange;
  85417. /**
  85418. * Observable signaled when VR display mode changes
  85419. */
  85420. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  85421. /**
  85422. * Observable signaled when VR request present is complete
  85423. */
  85424. onVRRequestPresentComplete: Observable<boolean>;
  85425. /**
  85426. * Observable signaled when VR request present starts
  85427. */
  85428. onVRRequestPresentStart: Observable<Engine>;
  85429. private _hardwareScalingLevel;
  85430. /** @hidden */
  85431. protected _caps: EngineCapabilities;
  85432. private _pointerLockRequested;
  85433. private _isStencilEnable;
  85434. private _colorWrite;
  85435. private _loadingScreen;
  85436. /** @hidden */
  85437. _drawCalls: PerfCounter;
  85438. /** @hidden */
  85439. _textureCollisions: PerfCounter;
  85440. private _glVersion;
  85441. private _glRenderer;
  85442. private _glVendor;
  85443. private _videoTextureSupported;
  85444. private _renderingQueueLaunched;
  85445. private _activeRenderLoops;
  85446. private _deterministicLockstep;
  85447. private _lockstepMaxSteps;
  85448. /**
  85449. * Observable signaled when a context lost event is raised
  85450. */
  85451. onContextLostObservable: Observable<Engine>;
  85452. /**
  85453. * Observable signaled when a context restored event is raised
  85454. */
  85455. onContextRestoredObservable: Observable<Engine>;
  85456. private _onContextLost;
  85457. private _onContextRestored;
  85458. private _contextWasLost;
  85459. private _doNotHandleContextLost;
  85460. /**
  85461. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  85462. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  85463. */
  85464. doNotHandleContextLost: boolean;
  85465. private _performanceMonitor;
  85466. private _fps;
  85467. private _deltaTime;
  85468. /**
  85469. * Turn this value on if you want to pause FPS computation when in background
  85470. */
  85471. disablePerformanceMonitorInBackground: boolean;
  85472. /**
  85473. * Gets the performance monitor attached to this engine
  85474. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  85475. */
  85476. readonly performanceMonitor: PerformanceMonitor;
  85477. /** @hidden */
  85478. protected _depthCullingState: _DepthCullingState;
  85479. /** @hidden */
  85480. protected _stencilState: _StencilState;
  85481. /** @hidden */
  85482. protected _alphaState: _AlphaState;
  85483. /** @hidden */
  85484. protected _alphaMode: number;
  85485. protected _internalTexturesCache: InternalTexture[];
  85486. /** @hidden */
  85487. protected _activeChannel: number;
  85488. private _currentTextureChannel;
  85489. /** @hidden */
  85490. protected _boundTexturesCache: {
  85491. [key: string]: Nullable<InternalTexture>;
  85492. };
  85493. /** @hidden */
  85494. protected _currentEffect: Nullable<Effect>;
  85495. /** @hidden */
  85496. protected _currentProgram: Nullable<WebGLProgram>;
  85497. private _compiledEffects;
  85498. private _vertexAttribArraysEnabled;
  85499. /** @hidden */
  85500. protected _cachedViewport: Nullable<Viewport>;
  85501. private _cachedVertexArrayObject;
  85502. /** @hidden */
  85503. protected _cachedVertexBuffers: any;
  85504. /** @hidden */
  85505. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  85506. /** @hidden */
  85507. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  85508. /** @hidden */
  85509. protected _currentRenderTarget: Nullable<InternalTexture>;
  85510. private _uintIndicesCurrentlySet;
  85511. private _currentBoundBuffer;
  85512. /** @hidden */
  85513. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  85514. private _currentBufferPointers;
  85515. private _currentInstanceLocations;
  85516. private _currentInstanceBuffers;
  85517. private _textureUnits;
  85518. private _firstBoundInternalTextureTracker;
  85519. private _lastBoundInternalTextureTracker;
  85520. private _workingCanvas;
  85521. private _workingContext;
  85522. private _rescalePostProcess;
  85523. private _dummyFramebuffer;
  85524. private _externalData;
  85525. private _bindedRenderFunction;
  85526. private _vaoRecordInProgress;
  85527. private _mustWipeVertexAttributes;
  85528. private _emptyTexture;
  85529. private _emptyCubeTexture;
  85530. private _emptyTexture3D;
  85531. /** @hidden */
  85532. _frameHandler: number;
  85533. private _nextFreeTextureSlots;
  85534. private _maxSimultaneousTextures;
  85535. private _activeRequests;
  85536. private _texturesSupported;
  85537. private _textureFormatInUse;
  85538. /**
  85539. * Gets the list of texture formats supported
  85540. */
  85541. readonly texturesSupported: Array<string>;
  85542. /**
  85543. * Gets the list of texture formats in use
  85544. */
  85545. readonly textureFormatInUse: Nullable<string>;
  85546. /**
  85547. * Gets the current viewport
  85548. */
  85549. readonly currentViewport: Nullable<Viewport>;
  85550. /**
  85551. * Gets the default empty texture
  85552. */
  85553. readonly emptyTexture: InternalTexture;
  85554. /**
  85555. * Gets the default empty 3D texture
  85556. */
  85557. readonly emptyTexture3D: InternalTexture;
  85558. /**
  85559. * Gets the default empty cube texture
  85560. */
  85561. readonly emptyCubeTexture: InternalTexture;
  85562. /**
  85563. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  85564. */
  85565. readonly premultipliedAlpha: boolean;
  85566. /**
  85567. * Creates a new engine
  85568. * @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
  85569. * @param antialias defines enable antialiasing (default: false)
  85570. * @param options defines further options to be sent to the getContext() function
  85571. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  85572. */
  85573. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  85574. private _disableTouchAction;
  85575. private _rebuildInternalTextures;
  85576. private _rebuildEffects;
  85577. /**
  85578. * Gets a boolean indicating if all created effects are ready
  85579. * @returns true if all effects are ready
  85580. */
  85581. areAllEffectsReady(): boolean;
  85582. private _rebuildBuffers;
  85583. private _initGLContext;
  85584. /**
  85585. * Gets version of the current webGL context
  85586. */
  85587. readonly webGLVersion: number;
  85588. /**
  85589. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  85590. */
  85591. readonly isStencilEnable: boolean;
  85592. private _prepareWorkingCanvas;
  85593. /**
  85594. * Reset the texture cache to empty state
  85595. */
  85596. resetTextureCache(): void;
  85597. /**
  85598. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  85599. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  85600. * @returns true if engine is in deterministic lock step mode
  85601. */
  85602. isDeterministicLockStep(): boolean;
  85603. /**
  85604. * Gets the max steps when engine is running in deterministic lock step
  85605. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  85606. * @returns the max steps
  85607. */
  85608. getLockstepMaxSteps(): number;
  85609. /**
  85610. * Gets an object containing information about the current webGL context
  85611. * @returns an object containing the vender, the renderer and the version of the current webGL context
  85612. */
  85613. getGlInfo(): {
  85614. vendor: string;
  85615. renderer: string;
  85616. version: string;
  85617. };
  85618. /**
  85619. * Gets current aspect ratio
  85620. * @param camera defines the camera to use to get the aspect ratio
  85621. * @param useScreen defines if screen size must be used (or the current render target if any)
  85622. * @returns a number defining the aspect ratio
  85623. */
  85624. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  85625. /**
  85626. * Gets current screen aspect ratio
  85627. * @returns a number defining the aspect ratio
  85628. */
  85629. getScreenAspectRatio(): number;
  85630. /**
  85631. * Gets the current render width
  85632. * @param useScreen defines if screen size must be used (or the current render target if any)
  85633. * @returns a number defining the current render width
  85634. */
  85635. getRenderWidth(useScreen?: boolean): number;
  85636. /**
  85637. * Gets the current render height
  85638. * @param useScreen defines if screen size must be used (or the current render target if any)
  85639. * @returns a number defining the current render height
  85640. */
  85641. getRenderHeight(useScreen?: boolean): number;
  85642. /**
  85643. * Gets the HTML canvas attached with the current webGL context
  85644. * @returns a HTML canvas
  85645. */
  85646. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  85647. /**
  85648. * Gets the client rect of the HTML canvas attached with the current webGL context
  85649. * @returns a client rectanglee
  85650. */
  85651. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  85652. /**
  85653. * Defines the hardware scaling level.
  85654. * By default the hardware scaling level is computed from the window device ratio.
  85655. * 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.
  85656. * @param level defines the level to use
  85657. */
  85658. setHardwareScalingLevel(level: number): void;
  85659. /**
  85660. * Gets the current hardware scaling level.
  85661. * By default the hardware scaling level is computed from the window device ratio.
  85662. * 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.
  85663. * @returns a number indicating the current hardware scaling level
  85664. */
  85665. getHardwareScalingLevel(): number;
  85666. /**
  85667. * Gets the list of loaded textures
  85668. * @returns an array containing all loaded textures
  85669. */
  85670. getLoadedTexturesCache(): InternalTexture[];
  85671. /**
  85672. * Gets the object containing all engine capabilities
  85673. * @returns the EngineCapabilities object
  85674. */
  85675. getCaps(): EngineCapabilities;
  85676. /**
  85677. * Gets the current depth function
  85678. * @returns a number defining the depth function
  85679. */
  85680. getDepthFunction(): Nullable<number>;
  85681. /**
  85682. * Sets the current depth function
  85683. * @param depthFunc defines the function to use
  85684. */
  85685. setDepthFunction(depthFunc: number): void;
  85686. /**
  85687. * Sets the current depth function to GREATER
  85688. */
  85689. setDepthFunctionToGreater(): void;
  85690. /**
  85691. * Sets the current depth function to GEQUAL
  85692. */
  85693. setDepthFunctionToGreaterOrEqual(): void;
  85694. /**
  85695. * Sets the current depth function to LESS
  85696. */
  85697. setDepthFunctionToLess(): void;
  85698. /**
  85699. * Sets the current depth function to LEQUAL
  85700. */
  85701. setDepthFunctionToLessOrEqual(): void;
  85702. /**
  85703. * Gets a boolean indicating if stencil buffer is enabled
  85704. * @returns the current stencil buffer state
  85705. */
  85706. getStencilBuffer(): boolean;
  85707. /**
  85708. * Enable or disable the stencil buffer
  85709. * @param enable defines if the stencil buffer must be enabled or disabled
  85710. */
  85711. setStencilBuffer(enable: boolean): void;
  85712. /**
  85713. * Gets the current stencil mask
  85714. * @returns a number defining the new stencil mask to use
  85715. */
  85716. getStencilMask(): number;
  85717. /**
  85718. * Sets the current stencil mask
  85719. * @param mask defines the new stencil mask to use
  85720. */
  85721. setStencilMask(mask: number): void;
  85722. /**
  85723. * Gets the current stencil function
  85724. * @returns a number defining the stencil function to use
  85725. */
  85726. getStencilFunction(): number;
  85727. /**
  85728. * Gets the current stencil reference value
  85729. * @returns a number defining the stencil reference value to use
  85730. */
  85731. getStencilFunctionReference(): number;
  85732. /**
  85733. * Gets the current stencil mask
  85734. * @returns a number defining the stencil mask to use
  85735. */
  85736. getStencilFunctionMask(): number;
  85737. /**
  85738. * Sets the current stencil function
  85739. * @param stencilFunc defines the new stencil function to use
  85740. */
  85741. setStencilFunction(stencilFunc: number): void;
  85742. /**
  85743. * Sets the current stencil reference
  85744. * @param reference defines the new stencil reference to use
  85745. */
  85746. setStencilFunctionReference(reference: number): void;
  85747. /**
  85748. * Sets the current stencil mask
  85749. * @param mask defines the new stencil mask to use
  85750. */
  85751. setStencilFunctionMask(mask: number): void;
  85752. /**
  85753. * Gets the current stencil operation when stencil fails
  85754. * @returns a number defining stencil operation to use when stencil fails
  85755. */
  85756. getStencilOperationFail(): number;
  85757. /**
  85758. * Gets the current stencil operation when depth fails
  85759. * @returns a number defining stencil operation to use when depth fails
  85760. */
  85761. getStencilOperationDepthFail(): number;
  85762. /**
  85763. * Gets the current stencil operation when stencil passes
  85764. * @returns a number defining stencil operation to use when stencil passes
  85765. */
  85766. getStencilOperationPass(): number;
  85767. /**
  85768. * Sets the stencil operation to use when stencil fails
  85769. * @param operation defines the stencil operation to use when stencil fails
  85770. */
  85771. setStencilOperationFail(operation: number): void;
  85772. /**
  85773. * Sets the stencil operation to use when depth fails
  85774. * @param operation defines the stencil operation to use when depth fails
  85775. */
  85776. setStencilOperationDepthFail(operation: number): void;
  85777. /**
  85778. * Sets the stencil operation to use when stencil passes
  85779. * @param operation defines the stencil operation to use when stencil passes
  85780. */
  85781. setStencilOperationPass(operation: number): void;
  85782. /**
  85783. * Sets a boolean indicating if the dithering state is enabled or disabled
  85784. * @param value defines the dithering state
  85785. */
  85786. setDitheringState(value: boolean): void;
  85787. /**
  85788. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  85789. * @param value defines the rasterizer state
  85790. */
  85791. setRasterizerState(value: boolean): void;
  85792. /**
  85793. * stop executing a render loop function and remove it from the execution array
  85794. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  85795. */
  85796. stopRenderLoop(renderFunction?: () => void): void;
  85797. /** @hidden */
  85798. _renderLoop(): void;
  85799. /**
  85800. * Register and execute a render loop. The engine can have more than one render function
  85801. * @param renderFunction defines the function to continuously execute
  85802. */
  85803. runRenderLoop(renderFunction: () => void): void;
  85804. /**
  85805. * Toggle full screen mode
  85806. * @param requestPointerLock defines if a pointer lock should be requested from the user
  85807. */
  85808. switchFullscreen(requestPointerLock: boolean): void;
  85809. /**
  85810. * Enters full screen mode
  85811. * @param requestPointerLock defines if a pointer lock should be requested from the user
  85812. */
  85813. enterFullscreen(requestPointerLock: boolean): void;
  85814. /**
  85815. * Exits full screen mode
  85816. */
  85817. exitFullscreen(): void;
  85818. /**
  85819. * Clear the current render buffer or the current render target (if any is set up)
  85820. * @param color defines the color to use
  85821. * @param backBuffer defines if the back buffer must be cleared
  85822. * @param depth defines if the depth buffer must be cleared
  85823. * @param stencil defines if the stencil buffer must be cleared
  85824. */
  85825. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  85826. /**
  85827. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  85828. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  85829. * @param y defines the y-coordinate of the corner of the clear rectangle
  85830. * @param width defines the width of the clear rectangle
  85831. * @param height defines the height of the clear rectangle
  85832. * @param clearColor defines the clear color
  85833. */
  85834. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  85835. /**
  85836. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  85837. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  85838. * @param y defines the y-coordinate of the corner of the clear rectangle
  85839. * @param width defines the width of the clear rectangle
  85840. * @param height defines the height of the clear rectangle
  85841. */
  85842. enableScissor(x: number, y: number, width: number, height: number): void;
  85843. /**
  85844. * Disable previously set scissor test rectangle
  85845. */
  85846. disableScissor(): void;
  85847. private _viewportCached;
  85848. /** @hidden */
  85849. _viewport(x: number, y: number, width: number, height: number): void;
  85850. /**
  85851. * Set the WebGL's viewport
  85852. * @param viewport defines the viewport element to be used
  85853. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  85854. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  85855. */
  85856. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  85857. /**
  85858. * Directly set the WebGL Viewport
  85859. * @param x defines the x coordinate of the viewport (in screen space)
  85860. * @param y defines the y coordinate of the viewport (in screen space)
  85861. * @param width defines the width of the viewport (in screen space)
  85862. * @param height defines the height of the viewport (in screen space)
  85863. * @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
  85864. */
  85865. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  85866. /**
  85867. * Begin a new frame
  85868. */
  85869. beginFrame(): void;
  85870. /**
  85871. * Enf the current frame
  85872. */
  85873. endFrame(): void;
  85874. /**
  85875. * Resize the view according to the canvas' size
  85876. */
  85877. resize(): void;
  85878. /**
  85879. * Force a specific size of the canvas
  85880. * @param width defines the new canvas' width
  85881. * @param height defines the new canvas' height
  85882. */
  85883. setSize(width: number, height: number): void;
  85884. /**
  85885. * Gets a boolean indicating if a webVR device was detected
  85886. * @returns true if a webVR device was detected
  85887. */
  85888. isVRDevicePresent(): boolean;
  85889. /**
  85890. * Gets the current webVR device
  85891. * @returns the current webVR device (or null)
  85892. */
  85893. getVRDevice(): any;
  85894. /**
  85895. * Initializes a webVR display and starts listening to display change events
  85896. * The onVRDisplayChangedObservable will be notified upon these changes
  85897. * @returns The onVRDisplayChangedObservable
  85898. */
  85899. initWebVR(): Observable<IDisplayChangedEventArgs>;
  85900. /**
  85901. * Initializes a webVR display and starts listening to display change events
  85902. * The onVRDisplayChangedObservable will be notified upon these changes
  85903. * @returns A promise containing a VRDisplay and if vr is supported
  85904. */
  85905. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  85906. /**
  85907. * Call this function to switch to webVR mode
  85908. * Will do nothing if webVR is not supported or if there is no webVR device
  85909. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85910. */
  85911. enableVR(): void;
  85912. /**
  85913. * Call this function to leave webVR mode
  85914. * Will do nothing if webVR is not supported or if there is no webVR device
  85915. * @see http://doc.babylonjs.com/how_to/webvr_camera
  85916. */
  85917. disableVR(): void;
  85918. private _onVRFullScreenTriggered;
  85919. private _getVRDisplaysAsync;
  85920. /**
  85921. * Binds the frame buffer to the specified texture.
  85922. * @param texture The texture to render to or null for the default canvas
  85923. * @param faceIndex The face of the texture to render to in case of cube texture
  85924. * @param requiredWidth The width of the target to render to
  85925. * @param requiredHeight The height of the target to render to
  85926. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  85927. * @param depthStencilTexture The depth stencil texture to use to render
  85928. * @param lodLevel defines le lod level to bind to the frame buffer
  85929. */
  85930. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  85931. private bindUnboundFramebuffer;
  85932. /**
  85933. * Unbind the current render target texture from the webGL context
  85934. * @param texture defines the render target texture to unbind
  85935. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  85936. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  85937. */
  85938. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  85939. /**
  85940. * Unbind a list of render target textures from the webGL context
  85941. * This is used only when drawBuffer extension or webGL2 are active
  85942. * @param textures defines the render target textures to unbind
  85943. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  85944. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  85945. */
  85946. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  85947. /**
  85948. * Force the mipmap generation for the given render target texture
  85949. * @param texture defines the render target texture to use
  85950. */
  85951. generateMipMapsForCubemap(texture: InternalTexture): void;
  85952. /**
  85953. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  85954. */
  85955. flushFramebuffer(): void;
  85956. /**
  85957. * Unbind the current render target and bind the default framebuffer
  85958. */
  85959. restoreDefaultFramebuffer(): void;
  85960. /**
  85961. * Create an uniform buffer
  85962. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85963. * @param elements defines the content of the uniform buffer
  85964. * @returns the webGL uniform buffer
  85965. */
  85966. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  85967. /**
  85968. * Create a dynamic uniform buffer
  85969. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85970. * @param elements defines the content of the uniform buffer
  85971. * @returns the webGL uniform buffer
  85972. */
  85973. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  85974. /**
  85975. * Update an existing uniform buffer
  85976. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85977. * @param uniformBuffer defines the target uniform buffer
  85978. * @param elements defines the content to update
  85979. * @param offset defines the offset in the uniform buffer where update should start
  85980. * @param count defines the size of the data to update
  85981. */
  85982. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  85983. private _resetVertexBufferBinding;
  85984. /**
  85985. * Creates a vertex buffer
  85986. * @param data the data for the vertex buffer
  85987. * @returns the new WebGL static buffer
  85988. */
  85989. createVertexBuffer(data: DataArray): WebGLBuffer;
  85990. /**
  85991. * Creates a dynamic vertex buffer
  85992. * @param data the data for the dynamic vertex buffer
  85993. * @returns the new WebGL dynamic buffer
  85994. */
  85995. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  85996. /**
  85997. * Update a dynamic index buffer
  85998. * @param indexBuffer defines the target index buffer
  85999. * @param indices defines the data to update
  86000. * @param offset defines the offset in the target index buffer where update should start
  86001. */
  86002. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  86003. /**
  86004. * Updates a dynamic vertex buffer.
  86005. * @param vertexBuffer the vertex buffer to update
  86006. * @param data the data used to update the vertex buffer
  86007. * @param byteOffset the byte offset of the data
  86008. * @param byteLength the byte length of the data
  86009. */
  86010. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  86011. private _resetIndexBufferBinding;
  86012. /**
  86013. * Creates a new index buffer
  86014. * @param indices defines the content of the index buffer
  86015. * @param updatable defines if the index buffer must be updatable
  86016. * @returns a new webGL buffer
  86017. */
  86018. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  86019. /**
  86020. * Bind a webGL buffer to the webGL context
  86021. * @param buffer defines the buffer to bind
  86022. */
  86023. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  86024. /**
  86025. * Bind an uniform buffer to the current webGL context
  86026. * @param buffer defines the buffer to bind
  86027. */
  86028. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  86029. /**
  86030. * Bind a buffer to the current webGL context at a given location
  86031. * @param buffer defines the buffer to bind
  86032. * @param location defines the index where to bind the buffer
  86033. */
  86034. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  86035. /**
  86036. * Bind a specific block at a given index in a specific shader program
  86037. * @param shaderProgram defines the shader program
  86038. * @param blockName defines the block name
  86039. * @param index defines the index where to bind the block
  86040. */
  86041. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  86042. private bindIndexBuffer;
  86043. private bindBuffer;
  86044. /**
  86045. * update the bound buffer with the given data
  86046. * @param data defines the data to update
  86047. */
  86048. updateArrayBuffer(data: Float32Array): void;
  86049. private _vertexAttribPointer;
  86050. private _bindIndexBufferWithCache;
  86051. private _bindVertexBuffersAttributes;
  86052. /**
  86053. * Records a vertex array object
  86054. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  86055. * @param vertexBuffers defines the list of vertex buffers to store
  86056. * @param indexBuffer defines the index buffer to store
  86057. * @param effect defines the effect to store
  86058. * @returns the new vertex array object
  86059. */
  86060. recordVertexArrayObject(vertexBuffers: {
  86061. [key: string]: VertexBuffer;
  86062. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  86063. /**
  86064. * Bind a specific vertex array object
  86065. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  86066. * @param vertexArrayObject defines the vertex array object to bind
  86067. * @param indexBuffer defines the index buffer to bind
  86068. */
  86069. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  86070. /**
  86071. * Bind webGl buffers directly to the webGL context
  86072. * @param vertexBuffer defines the vertex buffer to bind
  86073. * @param indexBuffer defines the index buffer to bind
  86074. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  86075. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  86076. * @param effect defines the effect associated with the vertex buffer
  86077. */
  86078. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  86079. private _unbindVertexArrayObject;
  86080. /**
  86081. * Bind a list of vertex buffers to the webGL context
  86082. * @param vertexBuffers defines the list of vertex buffers to bind
  86083. * @param indexBuffer defines the index buffer to bind
  86084. * @param effect defines the effect associated with the vertex buffers
  86085. */
  86086. bindBuffers(vertexBuffers: {
  86087. [key: string]: Nullable<VertexBuffer>;
  86088. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  86089. /**
  86090. * Unbind all instance attributes
  86091. */
  86092. unbindInstanceAttributes(): void;
  86093. /**
  86094. * Release and free the memory of a vertex array object
  86095. * @param vao defines the vertex array object to delete
  86096. */
  86097. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  86098. /** @hidden */
  86099. _releaseBuffer(buffer: WebGLBuffer): boolean;
  86100. /**
  86101. * Creates a webGL buffer to use with instanciation
  86102. * @param capacity defines the size of the buffer
  86103. * @returns the webGL buffer
  86104. */
  86105. createInstancesBuffer(capacity: number): WebGLBuffer;
  86106. /**
  86107. * Delete a webGL buffer used with instanciation
  86108. * @param buffer defines the webGL buffer to delete
  86109. */
  86110. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  86111. /**
  86112. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  86113. * @param instancesBuffer defines the webGL buffer to update and bind
  86114. * @param data defines the data to store in the buffer
  86115. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  86116. */
  86117. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  86118. /**
  86119. * Apply all cached states (depth, culling, stencil and alpha)
  86120. */
  86121. applyStates(): void;
  86122. /**
  86123. * Send a draw order
  86124. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  86125. * @param indexStart defines the starting index
  86126. * @param indexCount defines the number of index to draw
  86127. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86128. */
  86129. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  86130. /**
  86131. * Draw a list of points
  86132. * @param verticesStart defines the index of first vertex to draw
  86133. * @param verticesCount defines the count of vertices to draw
  86134. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86135. */
  86136. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  86137. /**
  86138. * Draw a list of unindexed primitives
  86139. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  86140. * @param verticesStart defines the index of first vertex to draw
  86141. * @param verticesCount defines the count of vertices to draw
  86142. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86143. */
  86144. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  86145. /**
  86146. * Draw a list of indexed primitives
  86147. * @param fillMode defines the primitive to use
  86148. * @param indexStart defines the starting index
  86149. * @param indexCount defines the number of index to draw
  86150. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86151. */
  86152. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  86153. /**
  86154. * Draw a list of unindexed primitives
  86155. * @param fillMode defines the primitive to use
  86156. * @param verticesStart defines the index of first vertex to draw
  86157. * @param verticesCount defines the count of vertices to draw
  86158. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  86159. */
  86160. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  86161. private _drawMode;
  86162. /** @hidden */
  86163. _releaseEffect(effect: Effect): void;
  86164. /** @hidden */
  86165. _deleteProgram(program: WebGLProgram): void;
  86166. /**
  86167. * Create a new effect (used to store vertex/fragment shaders)
  86168. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  86169. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  86170. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  86171. * @param samplers defines an array of string used to represent textures
  86172. * @param defines defines the string containing the defines to use to compile the shaders
  86173. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  86174. * @param onCompiled defines a function to call when the effect creation is successful
  86175. * @param onError defines a function to call when the effect creation has failed
  86176. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  86177. * @returns the new Effect
  86178. */
  86179. 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;
  86180. private _compileShader;
  86181. private _compileRawShader;
  86182. /**
  86183. * Directly creates a webGL program
  86184. * @param vertexCode defines the vertex shader code to use
  86185. * @param fragmentCode defines the fragment shader code to use
  86186. * @param context defines the webGL context to use (if not set, the current one will be used)
  86187. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  86188. * @returns the new webGL program
  86189. */
  86190. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  86191. /**
  86192. * Creates a webGL program
  86193. * @param vertexCode defines the vertex shader code to use
  86194. * @param fragmentCode defines the fragment shader code to use
  86195. * @param defines defines the string containing the defines to use to compile the shaders
  86196. * @param context defines the webGL context to use (if not set, the current one will be used)
  86197. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  86198. * @returns the new webGL program
  86199. */
  86200. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  86201. private _createShaderProgram;
  86202. private _finalizeProgram;
  86203. /** @hidden */
  86204. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  86205. /** @hidden */
  86206. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  86207. /**
  86208. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  86209. * @param shaderProgram defines the webGL program to use
  86210. * @param uniformsNames defines the list of uniform names
  86211. * @returns an array of webGL uniform locations
  86212. */
  86213. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  86214. /**
  86215. * Gets the lsit of active attributes for a given webGL program
  86216. * @param shaderProgram defines the webGL program to use
  86217. * @param attributesNames defines the list of attribute names to get
  86218. * @returns an array of indices indicating the offset of each attribute
  86219. */
  86220. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  86221. /**
  86222. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  86223. * @param effect defines the effect to activate
  86224. */
  86225. enableEffect(effect: Nullable<Effect>): void;
  86226. /**
  86227. * Set the value of an uniform to an array of int32
  86228. * @param uniform defines the webGL uniform location where to store the value
  86229. * @param array defines the array of int32 to store
  86230. */
  86231. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86232. /**
  86233. * Set the value of an uniform to an array of int32 (stored as vec2)
  86234. * @param uniform defines the webGL uniform location where to store the value
  86235. * @param array defines the array of int32 to store
  86236. */
  86237. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86238. /**
  86239. * Set the value of an uniform to an array of int32 (stored as vec3)
  86240. * @param uniform defines the webGL uniform location where to store the value
  86241. * @param array defines the array of int32 to store
  86242. */
  86243. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86244. /**
  86245. * Set the value of an uniform to an array of int32 (stored as vec4)
  86246. * @param uniform defines the webGL uniform location where to store the value
  86247. * @param array defines the array of int32 to store
  86248. */
  86249. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  86250. /**
  86251. * Set the value of an uniform to an array of float32
  86252. * @param uniform defines the webGL uniform location where to store the value
  86253. * @param array defines the array of float32 to store
  86254. */
  86255. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86256. /**
  86257. * Set the value of an uniform to an array of float32 (stored as vec2)
  86258. * @param uniform defines the webGL uniform location where to store the value
  86259. * @param array defines the array of float32 to store
  86260. */
  86261. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86262. /**
  86263. * Set the value of an uniform to an array of float32 (stored as vec3)
  86264. * @param uniform defines the webGL uniform location where to store the value
  86265. * @param array defines the array of float32 to store
  86266. */
  86267. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86268. /**
  86269. * Set the value of an uniform to an array of float32 (stored as vec4)
  86270. * @param uniform defines the webGL uniform location where to store the value
  86271. * @param array defines the array of float32 to store
  86272. */
  86273. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  86274. /**
  86275. * Set the value of an uniform to an array of number
  86276. * @param uniform defines the webGL uniform location where to store the value
  86277. * @param array defines the array of number to store
  86278. */
  86279. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86280. /**
  86281. * Set the value of an uniform to an array of number (stored as vec2)
  86282. * @param uniform defines the webGL uniform location where to store the value
  86283. * @param array defines the array of number to store
  86284. */
  86285. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86286. /**
  86287. * Set the value of an uniform to an array of number (stored as vec3)
  86288. * @param uniform defines the webGL uniform location where to store the value
  86289. * @param array defines the array of number to store
  86290. */
  86291. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86292. /**
  86293. * Set the value of an uniform to an array of number (stored as vec4)
  86294. * @param uniform defines the webGL uniform location where to store the value
  86295. * @param array defines the array of number to store
  86296. */
  86297. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  86298. /**
  86299. * Set the value of an uniform to an array of float32 (stored as matrices)
  86300. * @param uniform defines the webGL uniform location where to store the value
  86301. * @param matrices defines the array of float32 to store
  86302. */
  86303. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  86304. /**
  86305. * Set the value of an uniform to a matrix
  86306. * @param uniform defines the webGL uniform location where to store the value
  86307. * @param matrix defines the matrix to store
  86308. */
  86309. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  86310. /**
  86311. * Set the value of an uniform to a matrix (3x3)
  86312. * @param uniform defines the webGL uniform location where to store the value
  86313. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  86314. */
  86315. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  86316. /**
  86317. * Set the value of an uniform to a matrix (2x2)
  86318. * @param uniform defines the webGL uniform location where to store the value
  86319. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  86320. */
  86321. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  86322. /**
  86323. * Set the value of an uniform to a number (int)
  86324. * @param uniform defines the webGL uniform location where to store the value
  86325. * @param value defines the int number to store
  86326. */
  86327. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  86328. /**
  86329. * Set the value of an uniform to a number (float)
  86330. * @param uniform defines the webGL uniform location where to store the value
  86331. * @param value defines the float number to store
  86332. */
  86333. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  86334. /**
  86335. * Set the value of an uniform to a vec2
  86336. * @param uniform defines the webGL uniform location where to store the value
  86337. * @param x defines the 1st component of the value
  86338. * @param y defines the 2nd component of the value
  86339. */
  86340. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  86341. /**
  86342. * Set the value of an uniform to a vec3
  86343. * @param uniform defines the webGL uniform location where to store the value
  86344. * @param x defines the 1st component of the value
  86345. * @param y defines the 2nd component of the value
  86346. * @param z defines the 3rd component of the value
  86347. */
  86348. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  86349. /**
  86350. * Set the value of an uniform to a boolean
  86351. * @param uniform defines the webGL uniform location where to store the value
  86352. * @param bool defines the boolean to store
  86353. */
  86354. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  86355. /**
  86356. * Set the value of an uniform to a vec4
  86357. * @param uniform defines the webGL uniform location where to store the value
  86358. * @param x defines the 1st component of the value
  86359. * @param y defines the 2nd component of the value
  86360. * @param z defines the 3rd component of the value
  86361. * @param w defines the 4th component of the value
  86362. */
  86363. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  86364. /**
  86365. * Set the value of an uniform to a Color3
  86366. * @param uniform defines the webGL uniform location where to store the value
  86367. * @param color3 defines the color to store
  86368. */
  86369. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  86370. /**
  86371. * Set the value of an uniform to a Color3 and an alpha value
  86372. * @param uniform defines the webGL uniform location where to store the value
  86373. * @param color3 defines the color to store
  86374. * @param alpha defines the alpha component to store
  86375. */
  86376. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  86377. /**
  86378. * Sets a Color4 on a uniform variable
  86379. * @param uniform defines the uniform location
  86380. * @param color4 defines the value to be set
  86381. */
  86382. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  86383. /**
  86384. * Set various states to the webGL context
  86385. * @param culling defines backface culling state
  86386. * @param zOffset defines the value to apply to zOffset (0 by default)
  86387. * @param force defines if states must be applied even if cache is up to date
  86388. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  86389. */
  86390. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  86391. /**
  86392. * Set the z offset to apply to current rendering
  86393. * @param value defines the offset to apply
  86394. */
  86395. setZOffset(value: number): void;
  86396. /**
  86397. * Gets the current value of the zOffset
  86398. * @returns the current zOffset state
  86399. */
  86400. getZOffset(): number;
  86401. /**
  86402. * Enable or disable depth buffering
  86403. * @param enable defines the state to set
  86404. */
  86405. setDepthBuffer(enable: boolean): void;
  86406. /**
  86407. * Gets a boolean indicating if depth writing is enabled
  86408. * @returns the current depth writing state
  86409. */
  86410. getDepthWrite(): boolean;
  86411. /**
  86412. * Enable or disable depth writing
  86413. * @param enable defines the state to set
  86414. */
  86415. setDepthWrite(enable: boolean): void;
  86416. /**
  86417. * Enable or disable color writing
  86418. * @param enable defines the state to set
  86419. */
  86420. setColorWrite(enable: boolean): void;
  86421. /**
  86422. * Gets a boolean indicating if color writing is enabled
  86423. * @returns the current color writing state
  86424. */
  86425. getColorWrite(): boolean;
  86426. /**
  86427. * Sets alpha constants used by some alpha blending modes
  86428. * @param r defines the red component
  86429. * @param g defines the green component
  86430. * @param b defines the blue component
  86431. * @param a defines the alpha component
  86432. */
  86433. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  86434. /**
  86435. * Sets the current alpha mode
  86436. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  86437. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  86438. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  86439. */
  86440. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  86441. /**
  86442. * Gets the current alpha mode
  86443. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  86444. * @returns the current alpha mode
  86445. */
  86446. getAlphaMode(): number;
  86447. /**
  86448. * Clears the list of texture accessible through engine.
  86449. * This can help preventing texture load conflict due to name collision.
  86450. */
  86451. clearInternalTexturesCache(): void;
  86452. /**
  86453. * Force the entire cache to be cleared
  86454. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  86455. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  86456. */
  86457. wipeCaches(bruteForce?: boolean): void;
  86458. /**
  86459. * Set the compressed texture format to use, based on the formats you have, and the formats
  86460. * supported by the hardware / browser.
  86461. *
  86462. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  86463. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  86464. * to API arguments needed to compressed textures. This puts the burden on the container
  86465. * generator to house the arcane code for determining these for current & future formats.
  86466. *
  86467. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  86468. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  86469. *
  86470. * Note: The result of this call is not taken into account when a texture is base64.
  86471. *
  86472. * @param formatsAvailable defines the list of those format families you have created
  86473. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  86474. *
  86475. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  86476. * @returns The extension selected.
  86477. */
  86478. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  86479. private _getSamplingParameters;
  86480. private _partialLoadImg;
  86481. private _cascadeLoadImgs;
  86482. /** @hidden */
  86483. _createTexture(): WebGLTexture;
  86484. /**
  86485. * Usually called from Texture.ts.
  86486. * Passed information to create a WebGLTexture
  86487. * @param urlArg defines a value which contains one of the following:
  86488. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  86489. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  86490. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  86491. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  86492. * @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)
  86493. * @param scene needed for loading to the correct scene
  86494. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  86495. * @param onLoad optional callback to be called upon successful completion
  86496. * @param onError optional callback to be called upon failure
  86497. * @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
  86498. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  86499. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  86500. * @param forcedExtension defines the extension to use to pick the right loader
  86501. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  86502. * @returns a InternalTexture for assignment back into BABYLON.Texture
  86503. */
  86504. 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;
  86505. private _rescaleTexture;
  86506. /**
  86507. * Update a raw texture
  86508. * @param texture defines the texture to update
  86509. * @param data defines the data to store in the texture
  86510. * @param format defines the format of the data
  86511. * @param invertY defines if data must be stored with Y axis inverted
  86512. * @param compression defines the compression used (null by default)
  86513. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86514. */
  86515. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  86516. /**
  86517. * Creates a raw texture
  86518. * @param data defines the data to store in the texture
  86519. * @param width defines the width of the texture
  86520. * @param height defines the height of the texture
  86521. * @param format defines the format of the data
  86522. * @param generateMipMaps defines if the engine should generate the mip levels
  86523. * @param invertY defines if data must be stored with Y axis inverted
  86524. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86525. * @param compression defines the compression used (null by default)
  86526. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86527. * @returns the raw texture inside an InternalTexture
  86528. */
  86529. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  86530. private _unpackFlipYCached;
  86531. /**
  86532. * In case you are sharing the context with other applications, it might
  86533. * be interested to not cache the unpack flip y state to ensure a consistent
  86534. * value would be set.
  86535. */
  86536. enableUnpackFlipYCached: boolean;
  86537. /** @hidden */
  86538. _unpackFlipY(value: boolean): void;
  86539. /** @hidden */
  86540. _getUnpackAlignement(): number;
  86541. /**
  86542. * Creates a dynamic texture
  86543. * @param width defines the width of the texture
  86544. * @param height defines the height of the texture
  86545. * @param generateMipMaps defines if the engine should generate the mip levels
  86546. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  86547. * @returns the dynamic texture inside an InternalTexture
  86548. */
  86549. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  86550. /**
  86551. * Update the sampling mode of a given texture
  86552. * @param samplingMode defines the required sampling mode
  86553. * @param texture defines the texture to update
  86554. */
  86555. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  86556. /**
  86557. * Update the content of a dynamic texture
  86558. * @param texture defines the texture to update
  86559. * @param canvas defines the canvas containing the source
  86560. * @param invertY defines if data must be stored with Y axis inverted
  86561. * @param premulAlpha defines if alpha is stored as premultiplied
  86562. * @param format defines the format of the data
  86563. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  86564. */
  86565. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  86566. /**
  86567. * Update a video texture
  86568. * @param texture defines the texture to update
  86569. * @param video defines the video element to use
  86570. * @param invertY defines if data must be stored with Y axis inverted
  86571. */
  86572. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  86573. /**
  86574. * Updates a depth texture Comparison Mode and Function.
  86575. * If the comparison Function is equal to 0, the mode will be set to none.
  86576. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  86577. * @param texture The texture to set the comparison function for
  86578. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  86579. */
  86580. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  86581. private _setupDepthStencilTexture;
  86582. /**
  86583. * Creates a depth stencil texture.
  86584. * This is only available in WebGL 2 or with the depth texture extension available.
  86585. * @param size The size of face edge in the texture.
  86586. * @param options The options defining the texture.
  86587. * @returns The texture
  86588. */
  86589. createDepthStencilTexture(size: number | {
  86590. width: number;
  86591. height: number;
  86592. }, options: DepthTextureCreationOptions): InternalTexture;
  86593. /**
  86594. * Creates a depth stencil texture.
  86595. * This is only available in WebGL 2 or with the depth texture extension available.
  86596. * @param size The size of face edge in the texture.
  86597. * @param options The options defining the texture.
  86598. * @returns The texture
  86599. */
  86600. private _createDepthStencilTexture;
  86601. /**
  86602. * Creates a depth stencil cube texture.
  86603. * This is only available in WebGL 2.
  86604. * @param size The size of face edge in the cube texture.
  86605. * @param options The options defining the cube texture.
  86606. * @returns The cube texture
  86607. */
  86608. private _createDepthStencilCubeTexture;
  86609. /**
  86610. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  86611. * @param renderTarget The render target to set the frame buffer for
  86612. */
  86613. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  86614. /**
  86615. * Creates a new render target texture
  86616. * @param size defines the size of the texture
  86617. * @param options defines the options used to create the texture
  86618. * @returns a new render target texture stored in an InternalTexture
  86619. */
  86620. createRenderTargetTexture(size: number | {
  86621. width: number;
  86622. height: number;
  86623. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  86624. /**
  86625. * Create a multi render target texture
  86626. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  86627. * @param size defines the size of the texture
  86628. * @param options defines the creation options
  86629. * @returns the cube texture as an InternalTexture
  86630. */
  86631. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  86632. private _setupFramebufferDepthAttachments;
  86633. /**
  86634. * Updates the sample count of a render target texture
  86635. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  86636. * @param texture defines the texture to update
  86637. * @param samples defines the sample count to set
  86638. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  86639. */
  86640. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  86641. /**
  86642. * Update the sample count for a given multiple render target texture
  86643. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  86644. * @param textures defines the textures to update
  86645. * @param samples defines the sample count to set
  86646. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  86647. */
  86648. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  86649. /** @hidden */
  86650. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  86651. /** @hidden */
  86652. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  86653. /** @hidden */
  86654. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  86655. /** @hidden */
  86656. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  86657. /**
  86658. * Creates a new render target cube texture
  86659. * @param size defines the size of the texture
  86660. * @param options defines the options used to create the texture
  86661. * @returns a new render target cube texture stored in an InternalTexture
  86662. */
  86663. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  86664. /**
  86665. * Creates a cube texture
  86666. * @param rootUrl defines the url where the files to load is located
  86667. * @param scene defines the current scene
  86668. * @param files defines the list of files to load (1 per face)
  86669. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86670. * @param onLoad defines an optional callback raised when the texture is loaded
  86671. * @param onError defines an optional callback raised if there is an issue to load the texture
  86672. * @param format defines the format of the data
  86673. * @param forcedExtension defines the extension to use to pick the right loader
  86674. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  86675. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86676. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86677. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  86678. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  86679. * @returns the cube texture as an InternalTexture
  86680. */
  86681. 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;
  86682. /**
  86683. * @hidden
  86684. */
  86685. _setCubeMapTextureParams(loadMipmap: boolean): void;
  86686. /**
  86687. * Update a raw cube texture
  86688. * @param texture defines the texture to udpdate
  86689. * @param data defines the data to store
  86690. * @param format defines the data format
  86691. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  86692. * @param invertY defines if data must be stored with Y axis inverted
  86693. * @param compression defines the compression used (null by default)
  86694. * @param level defines which level of the texture to update
  86695. */
  86696. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  86697. /**
  86698. * Creates a new raw cube texture
  86699. * @param data defines the array of data to use to create each face
  86700. * @param size defines the size of the textures
  86701. * @param format defines the format of the data
  86702. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86703. * @param generateMipMaps defines if the engine should generate the mip levels
  86704. * @param invertY defines if data must be stored with Y axis inverted
  86705. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86706. * @param compression defines the compression used (null by default)
  86707. * @returns the cube texture as an InternalTexture
  86708. */
  86709. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  86710. /**
  86711. * Creates a new raw cube texture from a specified url
  86712. * @param url defines the url where the data is located
  86713. * @param scene defines the current scene
  86714. * @param size defines the size of the textures
  86715. * @param format defines the format of the data
  86716. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  86717. * @param noMipmap defines if the engine should avoid generating the mip levels
  86718. * @param callback defines a callback used to extract texture data from loaded data
  86719. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  86720. * @param onLoad defines a callback called when texture is loaded
  86721. * @param onError defines a callback called if there is an error
  86722. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86723. * @param invertY defines if data must be stored with Y axis inverted
  86724. * @returns the cube texture as an InternalTexture
  86725. */
  86726. 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;
  86727. /**
  86728. * Update a raw 3D texture
  86729. * @param texture defines the texture to update
  86730. * @param data defines the data to store
  86731. * @param format defines the data format
  86732. * @param invertY defines if data must be stored with Y axis inverted
  86733. * @param compression defines the used compression (can be null)
  86734. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  86735. */
  86736. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  86737. /**
  86738. * Creates a new raw 3D texture
  86739. * @param data defines the data used to create the texture
  86740. * @param width defines the width of the texture
  86741. * @param height defines the height of the texture
  86742. * @param depth defines the depth of the texture
  86743. * @param format defines the format of the texture
  86744. * @param generateMipMaps defines if the engine must generate mip levels
  86745. * @param invertY defines if data must be stored with Y axis inverted
  86746. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  86747. * @param compression defines the compressed used (can be null)
  86748. * @param textureType defines the compressed used (can be null)
  86749. * @returns a new raw 3D texture (stored in an InternalTexture)
  86750. */
  86751. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  86752. private _prepareWebGLTextureContinuation;
  86753. private _prepareWebGLTexture;
  86754. private _convertRGBtoRGBATextureData;
  86755. /** @hidden */
  86756. _releaseFramebufferObjects(texture: InternalTexture): void;
  86757. /** @hidden */
  86758. _releaseTexture(texture: InternalTexture): void;
  86759. private setProgram;
  86760. private _boundUniforms;
  86761. /**
  86762. * Binds an effect to the webGL context
  86763. * @param effect defines the effect to bind
  86764. */
  86765. bindSamplers(effect: Effect): void;
  86766. private _moveBoundTextureOnTop;
  86767. private _getCorrectTextureChannel;
  86768. private _linkTrackers;
  86769. private _removeDesignatedSlot;
  86770. private _activateCurrentTexture;
  86771. /** @hidden */
  86772. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  86773. /** @hidden */
  86774. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  86775. /**
  86776. * Sets a texture to the webGL context from a postprocess
  86777. * @param channel defines the channel to use
  86778. * @param postProcess defines the source postprocess
  86779. */
  86780. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  86781. /**
  86782. * Binds the output of the passed in post process to the texture channel specified
  86783. * @param channel The channel the texture should be bound to
  86784. * @param postProcess The post process which's output should be bound
  86785. */
  86786. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  86787. /**
  86788. * Unbind all textures from the webGL context
  86789. */
  86790. unbindAllTextures(): void;
  86791. /**
  86792. * Sets a texture to the according uniform.
  86793. * @param channel The texture channel
  86794. * @param uniform The uniform to set
  86795. * @param texture The texture to apply
  86796. */
  86797. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  86798. /**
  86799. * Sets a depth stencil texture from a render target to the according uniform.
  86800. * @param channel The texture channel
  86801. * @param uniform The uniform to set
  86802. * @param texture The render target texture containing the depth stencil texture to apply
  86803. */
  86804. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  86805. private _bindSamplerUniformToChannel;
  86806. private _getTextureWrapMode;
  86807. private _setTexture;
  86808. /**
  86809. * Sets an array of texture to the webGL context
  86810. * @param channel defines the channel where the texture array must be set
  86811. * @param uniform defines the associated uniform location
  86812. * @param textures defines the array of textures to bind
  86813. */
  86814. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  86815. /** @hidden */
  86816. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  86817. private _setTextureParameterFloat;
  86818. private _setTextureParameterInteger;
  86819. /**
  86820. * Reads pixels from the current frame buffer. Please note that this function can be slow
  86821. * @param x defines the x coordinate of the rectangle where pixels must be read
  86822. * @param y defines the y coordinate of the rectangle where pixels must be read
  86823. * @param width defines the width of the rectangle where pixels must be read
  86824. * @param height defines the height of the rectangle where pixels must be read
  86825. * @returns a Uint8Array containing RGBA colors
  86826. */
  86827. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  86828. /**
  86829. * Add an externaly attached data from its key.
  86830. * This method call will fail and return false, if such key already exists.
  86831. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  86832. * @param key the unique key that identifies the data
  86833. * @param data the data object to associate to the key for this Engine instance
  86834. * @return true if no such key were already present and the data was added successfully, false otherwise
  86835. */
  86836. addExternalData<T>(key: string, data: T): boolean;
  86837. /**
  86838. * Get an externaly attached data from its key
  86839. * @param key the unique key that identifies the data
  86840. * @return the associated data, if present (can be null), or undefined if not present
  86841. */
  86842. getExternalData<T>(key: string): T;
  86843. /**
  86844. * Get an externaly attached data from its key, create it using a factory if it's not already present
  86845. * @param key the unique key that identifies the data
  86846. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  86847. * @return the associated data, can be null if the factory returned null.
  86848. */
  86849. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  86850. /**
  86851. * Remove an externaly attached data from the Engine instance
  86852. * @param key the unique key that identifies the data
  86853. * @return true if the data was successfully removed, false if it doesn't exist
  86854. */
  86855. removeExternalData(key: string): boolean;
  86856. /**
  86857. * Unbind all vertex attributes from the webGL context
  86858. */
  86859. unbindAllAttributes(): void;
  86860. /**
  86861. * 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
  86862. */
  86863. releaseEffects(): void;
  86864. /**
  86865. * Dispose and release all associated resources
  86866. */
  86867. dispose(): void;
  86868. /**
  86869. * Display the loading screen
  86870. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86871. */
  86872. displayLoadingUI(): void;
  86873. /**
  86874. * Hide the loading screen
  86875. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86876. */
  86877. hideLoadingUI(): void;
  86878. /**
  86879. * Gets the current loading screen object
  86880. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86881. */
  86882. /**
  86883. * Sets the current loading screen object
  86884. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86885. */
  86886. loadingScreen: ILoadingScreen;
  86887. /**
  86888. * Sets the current loading screen text
  86889. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86890. */
  86891. loadingUIText: string;
  86892. /**
  86893. * Sets the current loading screen background color
  86894. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86895. */
  86896. loadingUIBackgroundColor: string;
  86897. /**
  86898. * Attach a new callback raised when context lost event is fired
  86899. * @param callback defines the callback to call
  86900. */
  86901. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  86902. /**
  86903. * Attach a new callback raised when context restored event is fired
  86904. * @param callback defines the callback to call
  86905. */
  86906. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  86907. /**
  86908. * Gets the source code of the vertex shader associated with a specific webGL program
  86909. * @param program defines the program to use
  86910. * @returns a string containing the source code of the vertex shader associated with the program
  86911. */
  86912. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  86913. /**
  86914. * Gets the source code of the fragment shader associated with a specific webGL program
  86915. * @param program defines the program to use
  86916. * @returns a string containing the source code of the fragment shader associated with the program
  86917. */
  86918. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  86919. /**
  86920. * Get the current error code of the webGL context
  86921. * @returns the error code
  86922. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  86923. */
  86924. getError(): number;
  86925. /**
  86926. * Gets the current framerate
  86927. * @returns a number representing the framerate
  86928. */
  86929. getFps(): number;
  86930. /**
  86931. * Gets the time spent between current and previous frame
  86932. * @returns a number representing the delta time in ms
  86933. */
  86934. getDeltaTime(): number;
  86935. private _measureFps;
  86936. /** @hidden */
  86937. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  86938. private _canRenderToFloatFramebuffer;
  86939. private _canRenderToHalfFloatFramebuffer;
  86940. private _canRenderToFramebuffer;
  86941. /** @hidden */
  86942. _getWebGLTextureType(type: number): number;
  86943. private _getInternalFormat;
  86944. /** @hidden */
  86945. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  86946. /** @hidden */
  86947. _getRGBAMultiSampleBufferFormat(type: number): number;
  86948. /** @hidden */
  86949. _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;
  86950. /** @hidden */
  86951. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  86952. private _partialLoadFile;
  86953. private _cascadeLoadFiles;
  86954. /**
  86955. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  86956. * @returns true if the engine can be created
  86957. * @ignorenaming
  86958. */
  86959. static isSupported(): boolean;
  86960. }
  86961. }
  86962. declare module BABYLON {
  86963. /**
  86964. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  86965. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  86966. */
  86967. export class EffectFallbacks {
  86968. private _defines;
  86969. private _currentRank;
  86970. private _maxRank;
  86971. private _mesh;
  86972. /**
  86973. * Removes the fallback from the bound mesh.
  86974. */
  86975. unBindMesh(): void;
  86976. /**
  86977. * Adds a fallback on the specified property.
  86978. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86979. * @param define The name of the define in the shader
  86980. */
  86981. addFallback(rank: number, define: string): void;
  86982. /**
  86983. * Sets the mesh to use CPU skinning when needing to fallback.
  86984. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  86985. * @param mesh The mesh to use the fallbacks.
  86986. */
  86987. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  86988. /**
  86989. * Checks to see if more fallbacks are still availible.
  86990. */
  86991. readonly isMoreFallbacks: boolean;
  86992. /**
  86993. * Removes the defines that shoould be removed when falling back.
  86994. * @param currentDefines defines the current define statements for the shader.
  86995. * @param effect defines the current effect we try to compile
  86996. * @returns The resulting defines with defines of the current rank removed.
  86997. */
  86998. reduce(currentDefines: string, effect: Effect): string;
  86999. }
  87000. /**
  87001. * Options to be used when creating an effect.
  87002. */
  87003. export class EffectCreationOptions {
  87004. /**
  87005. * Atrributes that will be used in the shader.
  87006. */
  87007. attributes: string[];
  87008. /**
  87009. * Uniform varible names that will be set in the shader.
  87010. */
  87011. uniformsNames: string[];
  87012. /**
  87013. * Uniform buffer varible names that will be set in the shader.
  87014. */
  87015. uniformBuffersNames: string[];
  87016. /**
  87017. * Sampler texture variable names that will be set in the shader.
  87018. */
  87019. samplers: string[];
  87020. /**
  87021. * Define statements that will be set in the shader.
  87022. */
  87023. defines: any;
  87024. /**
  87025. * Possible fallbacks for this effect to improve performance when needed.
  87026. */
  87027. fallbacks: Nullable<EffectFallbacks>;
  87028. /**
  87029. * Callback that will be called when the shader is compiled.
  87030. */
  87031. onCompiled: Nullable<(effect: Effect) => void>;
  87032. /**
  87033. * Callback that will be called if an error occurs during shader compilation.
  87034. */
  87035. onError: Nullable<(effect: Effect, errors: string) => void>;
  87036. /**
  87037. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  87038. */
  87039. indexParameters: any;
  87040. /**
  87041. * Max number of lights that can be used in the shader.
  87042. */
  87043. maxSimultaneousLights: number;
  87044. /**
  87045. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  87046. */
  87047. transformFeedbackVaryings: Nullable<string[]>;
  87048. }
  87049. /**
  87050. * Effect containing vertex and fragment shader that can be executed on an object.
  87051. */
  87052. export class Effect {
  87053. /**
  87054. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  87055. */
  87056. static ShadersRepository: string;
  87057. /**
  87058. * Name of the effect.
  87059. */
  87060. name: any;
  87061. /**
  87062. * String container all the define statements that should be set on the shader.
  87063. */
  87064. defines: string;
  87065. /**
  87066. * Callback that will be called when the shader is compiled.
  87067. */
  87068. onCompiled: Nullable<(effect: Effect) => void>;
  87069. /**
  87070. * Callback that will be called if an error occurs during shader compilation.
  87071. */
  87072. onError: Nullable<(effect: Effect, errors: string) => void>;
  87073. /**
  87074. * Callback that will be called when effect is bound.
  87075. */
  87076. onBind: Nullable<(effect: Effect) => void>;
  87077. /**
  87078. * Unique ID of the effect.
  87079. */
  87080. uniqueId: number;
  87081. /**
  87082. * Observable that will be called when the shader is compiled.
  87083. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  87084. */
  87085. onCompileObservable: Observable<Effect>;
  87086. /**
  87087. * Observable that will be called if an error occurs during shader compilation.
  87088. */
  87089. onErrorObservable: Observable<Effect>;
  87090. /** @hidden */
  87091. _onBindObservable: Nullable<Observable<Effect>>;
  87092. /**
  87093. * Observable that will be called when effect is bound.
  87094. */
  87095. readonly onBindObservable: Observable<Effect>;
  87096. /** @hidden */
  87097. _bonesComputationForcedToCPU: boolean;
  87098. private static _uniqueIdSeed;
  87099. private _engine;
  87100. private _uniformBuffersNames;
  87101. private _uniformsNames;
  87102. private _samplers;
  87103. private _isReady;
  87104. private _compilationError;
  87105. private _attributesNames;
  87106. private _attributes;
  87107. private _uniforms;
  87108. /**
  87109. * Key for the effect.
  87110. * @hidden
  87111. */
  87112. _key: string;
  87113. private _indexParameters;
  87114. private _fallbacks;
  87115. private _vertexSourceCode;
  87116. private _fragmentSourceCode;
  87117. private _vertexSourceCodeOverride;
  87118. private _fragmentSourceCodeOverride;
  87119. private _transformFeedbackVaryings;
  87120. /**
  87121. * Compiled shader to webGL program.
  87122. * @hidden
  87123. */
  87124. _program: WebGLProgram;
  87125. private _valueCache;
  87126. private static _baseCache;
  87127. /**
  87128. * Instantiates an effect.
  87129. * An effect can be used to create/manage/execute vertex and fragment shaders.
  87130. * @param baseName Name of the effect.
  87131. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  87132. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  87133. * @param samplers List of sampler variables that will be passed to the shader.
  87134. * @param engine Engine to be used to render the effect
  87135. * @param defines Define statements to be added to the shader.
  87136. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  87137. * @param onCompiled Callback that will be called when the shader is compiled.
  87138. * @param onError Callback that will be called if an error occurs during shader compilation.
  87139. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  87140. */
  87141. 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);
  87142. /**
  87143. * Unique key for this effect
  87144. */
  87145. readonly key: string;
  87146. /**
  87147. * If the effect has been compiled and prepared.
  87148. * @returns if the effect is compiled and prepared.
  87149. */
  87150. isReady(): boolean;
  87151. /**
  87152. * The engine the effect was initialized with.
  87153. * @returns the engine.
  87154. */
  87155. getEngine(): Engine;
  87156. /**
  87157. * The compiled webGL program for the effect
  87158. * @returns the webGL program.
  87159. */
  87160. getProgram(): WebGLProgram;
  87161. /**
  87162. * The set of names of attribute variables for the shader.
  87163. * @returns An array of attribute names.
  87164. */
  87165. getAttributesNames(): string[];
  87166. /**
  87167. * Returns the attribute at the given index.
  87168. * @param index The index of the attribute.
  87169. * @returns The location of the attribute.
  87170. */
  87171. getAttributeLocation(index: number): number;
  87172. /**
  87173. * Returns the attribute based on the name of the variable.
  87174. * @param name of the attribute to look up.
  87175. * @returns the attribute location.
  87176. */
  87177. getAttributeLocationByName(name: string): number;
  87178. /**
  87179. * The number of attributes.
  87180. * @returns the numnber of attributes.
  87181. */
  87182. getAttributesCount(): number;
  87183. /**
  87184. * Gets the index of a uniform variable.
  87185. * @param uniformName of the uniform to look up.
  87186. * @returns the index.
  87187. */
  87188. getUniformIndex(uniformName: string): number;
  87189. /**
  87190. * Returns the attribute based on the name of the variable.
  87191. * @param uniformName of the uniform to look up.
  87192. * @returns the location of the uniform.
  87193. */
  87194. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  87195. /**
  87196. * Returns an array of sampler variable names
  87197. * @returns The array of sampler variable neames.
  87198. */
  87199. getSamplers(): string[];
  87200. /**
  87201. * The error from the last compilation.
  87202. * @returns the error string.
  87203. */
  87204. getCompilationError(): string;
  87205. /**
  87206. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  87207. * @param func The callback to be used.
  87208. */
  87209. executeWhenCompiled(func: (effect: Effect) => void): void;
  87210. private _checkIsReady;
  87211. /** @hidden */
  87212. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  87213. /** @hidden */
  87214. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  87215. /** @hidden */
  87216. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  87217. private _processShaderConversion;
  87218. private _processIncludes;
  87219. private _processPrecision;
  87220. /**
  87221. * Recompiles the webGL program
  87222. * @param vertexSourceCode The source code for the vertex shader.
  87223. * @param fragmentSourceCode The source code for the fragment shader.
  87224. * @param onCompiled Callback called when completed.
  87225. * @param onError Callback called on error.
  87226. * @hidden
  87227. */
  87228. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  87229. /**
  87230. * Gets the uniform locations of the the specified variable names
  87231. * @param names THe names of the variables to lookup.
  87232. * @returns Array of locations in the same order as variable names.
  87233. */
  87234. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  87235. /**
  87236. * Prepares the effect
  87237. * @hidden
  87238. */
  87239. _prepareEffect(): void;
  87240. /**
  87241. * Checks if the effect is supported. (Must be called after compilation)
  87242. */
  87243. readonly isSupported: boolean;
  87244. /**
  87245. * Binds a texture to the engine to be used as output of the shader.
  87246. * @param channel Name of the output variable.
  87247. * @param texture Texture to bind.
  87248. * @hidden
  87249. */
  87250. _bindTexture(channel: string, texture: InternalTexture): void;
  87251. /**
  87252. * Sets a texture on the engine to be used in the shader.
  87253. * @param channel Name of the sampler variable.
  87254. * @param texture Texture to set.
  87255. */
  87256. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  87257. /**
  87258. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  87259. * @param channel Name of the sampler variable.
  87260. * @param texture Texture to set.
  87261. */
  87262. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  87263. /**
  87264. * Sets an array of textures on the engine to be used in the shader.
  87265. * @param channel Name of the variable.
  87266. * @param textures Textures to set.
  87267. */
  87268. setTextureArray(channel: string, textures: BaseTexture[]): void;
  87269. /**
  87270. * 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)
  87271. * @param channel Name of the sampler variable.
  87272. * @param postProcess Post process to get the input texture from.
  87273. */
  87274. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  87275. /**
  87276. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  87277. * 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)
  87278. * @param channel Name of the sampler variable.
  87279. * @param postProcess Post process to get the output texture from.
  87280. */
  87281. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  87282. /** @hidden */
  87283. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  87284. /** @hidden */
  87285. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  87286. /** @hidden */
  87287. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  87288. /** @hidden */
  87289. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  87290. /**
  87291. * Binds a buffer to a uniform.
  87292. * @param buffer Buffer to bind.
  87293. * @param name Name of the uniform variable to bind to.
  87294. */
  87295. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  87296. /**
  87297. * Binds block to a uniform.
  87298. * @param blockName Name of the block to bind.
  87299. * @param index Index to bind.
  87300. */
  87301. bindUniformBlock(blockName: string, index: number): void;
  87302. /**
  87303. * Sets an interger value on a uniform variable.
  87304. * @param uniformName Name of the variable.
  87305. * @param value Value to be set.
  87306. * @returns this effect.
  87307. */
  87308. setInt(uniformName: string, value: number): Effect;
  87309. /**
  87310. * Sets an int array on a uniform variable.
  87311. * @param uniformName Name of the variable.
  87312. * @param array array to be set.
  87313. * @returns this effect.
  87314. */
  87315. setIntArray(uniformName: string, array: Int32Array): Effect;
  87316. /**
  87317. * 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)
  87318. * @param uniformName Name of the variable.
  87319. * @param array array to be set.
  87320. * @returns this effect.
  87321. */
  87322. setIntArray2(uniformName: string, array: Int32Array): Effect;
  87323. /**
  87324. * 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)
  87325. * @param uniformName Name of the variable.
  87326. * @param array array to be set.
  87327. * @returns this effect.
  87328. */
  87329. setIntArray3(uniformName: string, array: Int32Array): Effect;
  87330. /**
  87331. * 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)
  87332. * @param uniformName Name of the variable.
  87333. * @param array array to be set.
  87334. * @returns this effect.
  87335. */
  87336. setIntArray4(uniformName: string, array: Int32Array): Effect;
  87337. /**
  87338. * Sets an float array on a uniform variable.
  87339. * @param uniformName Name of the variable.
  87340. * @param array array to be set.
  87341. * @returns this effect.
  87342. */
  87343. setFloatArray(uniformName: string, array: Float32Array): Effect;
  87344. /**
  87345. * 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)
  87346. * @param uniformName Name of the variable.
  87347. * @param array array to be set.
  87348. * @returns this effect.
  87349. */
  87350. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  87351. /**
  87352. * 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)
  87353. * @param uniformName Name of the variable.
  87354. * @param array array to be set.
  87355. * @returns this effect.
  87356. */
  87357. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  87358. /**
  87359. * 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)
  87360. * @param uniformName Name of the variable.
  87361. * @param array array to be set.
  87362. * @returns this effect.
  87363. */
  87364. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  87365. /**
  87366. * Sets an array on a uniform variable.
  87367. * @param uniformName Name of the variable.
  87368. * @param array array to be set.
  87369. * @returns this effect.
  87370. */
  87371. setArray(uniformName: string, array: number[]): Effect;
  87372. /**
  87373. * 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)
  87374. * @param uniformName Name of the variable.
  87375. * @param array array to be set.
  87376. * @returns this effect.
  87377. */
  87378. setArray2(uniformName: string, array: number[]): Effect;
  87379. /**
  87380. * 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)
  87381. * @param uniformName Name of the variable.
  87382. * @param array array to be set.
  87383. * @returns this effect.
  87384. */
  87385. setArray3(uniformName: string, array: number[]): Effect;
  87386. /**
  87387. * 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)
  87388. * @param uniformName Name of the variable.
  87389. * @param array array to be set.
  87390. * @returns this effect.
  87391. */
  87392. setArray4(uniformName: string, array: number[]): Effect;
  87393. /**
  87394. * Sets matrices on a uniform variable.
  87395. * @param uniformName Name of the variable.
  87396. * @param matrices matrices to be set.
  87397. * @returns this effect.
  87398. */
  87399. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  87400. /**
  87401. * Sets matrix on a uniform variable.
  87402. * @param uniformName Name of the variable.
  87403. * @param matrix matrix to be set.
  87404. * @returns this effect.
  87405. */
  87406. setMatrix(uniformName: string, matrix: Matrix): Effect;
  87407. /**
  87408. * 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)
  87409. * @param uniformName Name of the variable.
  87410. * @param matrix matrix to be set.
  87411. * @returns this effect.
  87412. */
  87413. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  87414. /**
  87415. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  87416. * @param uniformName Name of the variable.
  87417. * @param matrix matrix to be set.
  87418. * @returns this effect.
  87419. */
  87420. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  87421. /**
  87422. * Sets a float on a uniform variable.
  87423. * @param uniformName Name of the variable.
  87424. * @param value value to be set.
  87425. * @returns this effect.
  87426. */
  87427. setFloat(uniformName: string, value: number): Effect;
  87428. /**
  87429. * Sets a boolean on a uniform variable.
  87430. * @param uniformName Name of the variable.
  87431. * @param bool value to be set.
  87432. * @returns this effect.
  87433. */
  87434. setBool(uniformName: string, bool: boolean): Effect;
  87435. /**
  87436. * Sets a Vector2 on a uniform variable.
  87437. * @param uniformName Name of the variable.
  87438. * @param vector2 vector2 to be set.
  87439. * @returns this effect.
  87440. */
  87441. setVector2(uniformName: string, vector2: Vector2): Effect;
  87442. /**
  87443. * Sets a float2 on a uniform variable.
  87444. * @param uniformName Name of the variable.
  87445. * @param x First float in float2.
  87446. * @param y Second float in float2.
  87447. * @returns this effect.
  87448. */
  87449. setFloat2(uniformName: string, x: number, y: number): Effect;
  87450. /**
  87451. * Sets a Vector3 on a uniform variable.
  87452. * @param uniformName Name of the variable.
  87453. * @param vector3 Value to be set.
  87454. * @returns this effect.
  87455. */
  87456. setVector3(uniformName: string, vector3: Vector3): Effect;
  87457. /**
  87458. * Sets a float3 on a uniform variable.
  87459. * @param uniformName Name of the variable.
  87460. * @param x First float in float3.
  87461. * @param y Second float in float3.
  87462. * @param z Third float in float3.
  87463. * @returns this effect.
  87464. */
  87465. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  87466. /**
  87467. * Sets a Vector4 on a uniform variable.
  87468. * @param uniformName Name of the variable.
  87469. * @param vector4 Value to be set.
  87470. * @returns this effect.
  87471. */
  87472. setVector4(uniformName: string, vector4: Vector4): Effect;
  87473. /**
  87474. * Sets a float4 on a uniform variable.
  87475. * @param uniformName Name of the variable.
  87476. * @param x First float in float4.
  87477. * @param y Second float in float4.
  87478. * @param z Third float in float4.
  87479. * @param w Fourth float in float4.
  87480. * @returns this effect.
  87481. */
  87482. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  87483. /**
  87484. * Sets a Color3 on a uniform variable.
  87485. * @param uniformName Name of the variable.
  87486. * @param color3 Value to be set.
  87487. * @returns this effect.
  87488. */
  87489. setColor3(uniformName: string, color3: Color3): Effect;
  87490. /**
  87491. * Sets a Color4 on a uniform variable.
  87492. * @param uniformName Name of the variable.
  87493. * @param color3 Value to be set.
  87494. * @param alpha Alpha value to be set.
  87495. * @returns this effect.
  87496. */
  87497. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  87498. /**
  87499. * Sets a Color4 on a uniform variable
  87500. * @param uniformName defines the name of the variable
  87501. * @param color4 defines the value to be set
  87502. * @returns this effect.
  87503. */
  87504. setDirectColor4(uniformName: string, color4: Color4): Effect;
  87505. /**
  87506. * This function will add a new shader to the shader store
  87507. * @param name the name of the shader
  87508. * @param pixelShader optional pixel shader content
  87509. * @param vertexShader optional vertex shader content
  87510. */
  87511. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  87512. /**
  87513. * Store of each shader (The can be looked up using effect.key)
  87514. */
  87515. static ShadersStore: {
  87516. [key: string]: string;
  87517. };
  87518. /**
  87519. * Store of each included file for a shader (The can be looked up using effect.key)
  87520. */
  87521. static IncludesShadersStore: {
  87522. [key: string]: string;
  87523. };
  87524. /**
  87525. * Resets the cache of effects.
  87526. */
  87527. static ResetCache(): void;
  87528. }
  87529. }
  87530. declare module BABYLON {
  87531. /**
  87532. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  87533. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  87534. * 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;
  87535. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  87536. */
  87537. export class ColorCurves {
  87538. private _dirty;
  87539. private _tempColor;
  87540. private _globalCurve;
  87541. private _highlightsCurve;
  87542. private _midtonesCurve;
  87543. private _shadowsCurve;
  87544. private _positiveCurve;
  87545. private _negativeCurve;
  87546. private _globalHue;
  87547. private _globalDensity;
  87548. private _globalSaturation;
  87549. private _globalExposure;
  87550. /**
  87551. * Gets the global Hue value.
  87552. * 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).
  87553. */
  87554. /**
  87555. * Sets 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. globalHue: number;
  87559. /**
  87560. * Gets the global Density value.
  87561. * 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.
  87562. * Values less than zero provide a filter of opposite hue.
  87563. */
  87564. /**
  87565. * Sets the global Density value.
  87566. * 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.
  87567. * Values less than zero provide a filter of opposite hue.
  87568. */
  87569. globalDensity: number;
  87570. /**
  87571. * Gets the global Saturation value.
  87572. * 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.
  87573. */
  87574. /**
  87575. * Sets 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. globalSaturation: number;
  87579. /**
  87580. * Gets the global Exposure value.
  87581. * 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.
  87582. */
  87583. /**
  87584. * Sets 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. globalExposure: number;
  87588. private _highlightsHue;
  87589. private _highlightsDensity;
  87590. private _highlightsSaturation;
  87591. private _highlightsExposure;
  87592. /**
  87593. * Gets the highlights Hue value.
  87594. * 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).
  87595. */
  87596. /**
  87597. * Sets 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. highlightsHue: number;
  87601. /**
  87602. * Gets the highlights Density value.
  87603. * 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.
  87604. * Values less than zero provide a filter of opposite hue.
  87605. */
  87606. /**
  87607. * Sets the highlights Density value.
  87608. * 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.
  87609. * Values less than zero provide a filter of opposite hue.
  87610. */
  87611. highlightsDensity: number;
  87612. /**
  87613. * Gets the highlights Saturation value.
  87614. * 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.
  87615. */
  87616. /**
  87617. * Sets 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. highlightsSaturation: number;
  87621. /**
  87622. * Gets the highlights Exposure value.
  87623. * 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.
  87624. */
  87625. /**
  87626. * Sets 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. highlightsExposure: number;
  87630. private _midtonesHue;
  87631. private _midtonesDensity;
  87632. private _midtonesSaturation;
  87633. private _midtonesExposure;
  87634. /**
  87635. * Gets the midtones Hue value.
  87636. * 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).
  87637. */
  87638. /**
  87639. * Sets 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. midtonesHue: number;
  87643. /**
  87644. * Gets the midtones Density value.
  87645. * 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.
  87646. * Values less than zero provide a filter of opposite hue.
  87647. */
  87648. /**
  87649. * Sets the midtones Density value.
  87650. * 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.
  87651. * Values less than zero provide a filter of opposite hue.
  87652. */
  87653. midtonesDensity: number;
  87654. /**
  87655. * Gets the midtones Saturation value.
  87656. * 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.
  87657. */
  87658. /**
  87659. * Sets 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. midtonesSaturation: number;
  87663. /**
  87664. * Gets the midtones Exposure value.
  87665. * 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.
  87666. */
  87667. /**
  87668. * Sets 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. midtonesExposure: number;
  87672. private _shadowsHue;
  87673. private _shadowsDensity;
  87674. private _shadowsSaturation;
  87675. private _shadowsExposure;
  87676. /**
  87677. * Gets the shadows Hue value.
  87678. * 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).
  87679. */
  87680. /**
  87681. * Sets 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. shadowsHue: number;
  87685. /**
  87686. * Gets the shadows Density value.
  87687. * 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.
  87688. * Values less than zero provide a filter of opposite hue.
  87689. */
  87690. /**
  87691. * Sets the shadows Density value.
  87692. * 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.
  87693. * Values less than zero provide a filter of opposite hue.
  87694. */
  87695. shadowsDensity: number;
  87696. /**
  87697. * Gets the shadows Saturation value.
  87698. * 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.
  87699. */
  87700. /**
  87701. * Sets 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. shadowsSaturation: number;
  87705. /**
  87706. * Gets the shadows Exposure value.
  87707. * 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.
  87708. */
  87709. /**
  87710. * Sets 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. shadowsExposure: number;
  87714. /**
  87715. * Returns the class name
  87716. * @returns The class name
  87717. */
  87718. getClassName(): string;
  87719. /**
  87720. * Binds the color curves to the shader.
  87721. * @param colorCurves The color curve to bind
  87722. * @param effect The effect to bind to
  87723. * @param positiveUniform The positive uniform shader parameter
  87724. * @param neutralUniform The neutral uniform shader parameter
  87725. * @param negativeUniform The negative uniform shader parameter
  87726. */
  87727. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  87728. /**
  87729. * Prepare the list of uniforms associated with the ColorCurves effects.
  87730. * @param uniformsList The list of uniforms used in the effect
  87731. */
  87732. static PrepareUniforms(uniformsList: string[]): void;
  87733. /**
  87734. * Returns color grading data based on a hue, density, saturation and exposure value.
  87735. * @param filterHue The hue of the color filter.
  87736. * @param filterDensity The density of the color filter.
  87737. * @param saturation The saturation.
  87738. * @param exposure The exposure.
  87739. * @param result The result data container.
  87740. */
  87741. private getColorGradingDataToRef;
  87742. /**
  87743. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  87744. * @param value The input slider value in range [-100,100].
  87745. * @returns Adjusted value.
  87746. */
  87747. private static applyColorGradingSliderNonlinear;
  87748. /**
  87749. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  87750. * @param hue The hue (H) input.
  87751. * @param saturation The saturation (S) input.
  87752. * @param brightness The brightness (B) input.
  87753. * @result An RGBA color represented as Vector4.
  87754. */
  87755. private static fromHSBToRef;
  87756. /**
  87757. * Returns a value clamped between min and max
  87758. * @param value The value to clamp
  87759. * @param min The minimum of value
  87760. * @param max The maximum of value
  87761. * @returns The clamped value.
  87762. */
  87763. private static clamp;
  87764. /**
  87765. * Clones the current color curve instance.
  87766. * @return The cloned curves
  87767. */
  87768. clone(): ColorCurves;
  87769. /**
  87770. * Serializes the current color curve instance to a json representation.
  87771. * @return a JSON representation
  87772. */
  87773. serialize(): any;
  87774. /**
  87775. * Parses the color curve from a json representation.
  87776. * @param source the JSON source to parse
  87777. * @return The parsed curves
  87778. */
  87779. static Parse(source: any): ColorCurves;
  87780. }
  87781. }
  87782. declare module BABYLON {
  87783. /**
  87784. * Interface to follow in your material defines to integrate easily the
  87785. * Image proccessing functions.
  87786. * @hidden
  87787. */
  87788. export interface IImageProcessingConfigurationDefines {
  87789. IMAGEPROCESSING: boolean;
  87790. VIGNETTE: boolean;
  87791. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87792. VIGNETTEBLENDMODEOPAQUE: boolean;
  87793. TONEMAPPING: boolean;
  87794. TONEMAPPING_ACES: boolean;
  87795. CONTRAST: boolean;
  87796. EXPOSURE: boolean;
  87797. COLORCURVES: boolean;
  87798. COLORGRADING: boolean;
  87799. COLORGRADING3D: boolean;
  87800. SAMPLER3DGREENDEPTH: boolean;
  87801. SAMPLER3DBGRMAP: boolean;
  87802. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87803. }
  87804. /**
  87805. * @hidden
  87806. */
  87807. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  87808. IMAGEPROCESSING: boolean;
  87809. VIGNETTE: boolean;
  87810. VIGNETTEBLENDMODEMULTIPLY: boolean;
  87811. VIGNETTEBLENDMODEOPAQUE: boolean;
  87812. TONEMAPPING: boolean;
  87813. TONEMAPPING_ACES: boolean;
  87814. CONTRAST: boolean;
  87815. COLORCURVES: boolean;
  87816. COLORGRADING: boolean;
  87817. COLORGRADING3D: boolean;
  87818. SAMPLER3DGREENDEPTH: boolean;
  87819. SAMPLER3DBGRMAP: boolean;
  87820. IMAGEPROCESSINGPOSTPROCESS: boolean;
  87821. EXPOSURE: boolean;
  87822. constructor();
  87823. }
  87824. /**
  87825. * This groups together the common properties used for image processing either in direct forward pass
  87826. * or through post processing effect depending on the use of the image processing pipeline in your scene
  87827. * or not.
  87828. */
  87829. export class ImageProcessingConfiguration {
  87830. /**
  87831. * Default tone mapping applied in BabylonJS.
  87832. */
  87833. static readonly TONEMAPPING_STANDARD: number;
  87834. /**
  87835. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  87836. * to other engines rendering to increase portability.
  87837. */
  87838. static readonly TONEMAPPING_ACES: number;
  87839. /**
  87840. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  87841. */
  87842. colorCurves: Nullable<ColorCurves>;
  87843. private _colorCurvesEnabled;
  87844. /**
  87845. * Gets wether the color curves effect is enabled.
  87846. */
  87847. /**
  87848. * Sets wether the color curves effect is enabled.
  87849. */
  87850. colorCurvesEnabled: boolean;
  87851. private _colorGradingTexture;
  87852. /**
  87853. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87854. */
  87855. /**
  87856. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  87857. */
  87858. colorGradingTexture: Nullable<BaseTexture>;
  87859. private _colorGradingEnabled;
  87860. /**
  87861. * Gets wether the color grading effect is enabled.
  87862. */
  87863. /**
  87864. * Sets wether the color grading effect is enabled.
  87865. */
  87866. colorGradingEnabled: boolean;
  87867. private _colorGradingWithGreenDepth;
  87868. /**
  87869. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  87870. */
  87871. /**
  87872. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  87873. */
  87874. colorGradingWithGreenDepth: boolean;
  87875. private _colorGradingBGR;
  87876. /**
  87877. * Gets wether the color grading texture contains BGR values.
  87878. */
  87879. /**
  87880. * Sets wether the color grading texture contains BGR values.
  87881. */
  87882. colorGradingBGR: boolean;
  87883. /** @hidden */
  87884. _exposure: number;
  87885. /**
  87886. * Gets the Exposure used in the effect.
  87887. */
  87888. /**
  87889. * Sets the Exposure used in the effect.
  87890. */
  87891. exposure: number;
  87892. private _toneMappingEnabled;
  87893. /**
  87894. * Gets wether the tone mapping effect is enabled.
  87895. */
  87896. /**
  87897. * Sets wether the tone mapping effect is enabled.
  87898. */
  87899. toneMappingEnabled: boolean;
  87900. private _toneMappingType;
  87901. /**
  87902. * Gets the type of tone mapping effect.
  87903. */
  87904. /**
  87905. * Sets the type of tone mapping effect used in BabylonJS.
  87906. */
  87907. toneMappingType: number;
  87908. protected _contrast: number;
  87909. /**
  87910. * Gets the contrast used in the effect.
  87911. */
  87912. /**
  87913. * Sets the contrast used in the effect.
  87914. */
  87915. contrast: number;
  87916. /**
  87917. * Vignette stretch size.
  87918. */
  87919. vignetteStretch: number;
  87920. /**
  87921. * Vignette centre X Offset.
  87922. */
  87923. vignetteCentreX: number;
  87924. /**
  87925. * Vignette centre Y Offset.
  87926. */
  87927. vignetteCentreY: number;
  87928. /**
  87929. * Vignette weight or intensity of the vignette effect.
  87930. */
  87931. vignetteWeight: number;
  87932. /**
  87933. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  87934. * if vignetteEnabled is set to true.
  87935. */
  87936. vignetteColor: Color4;
  87937. /**
  87938. * Camera field of view used by the Vignette effect.
  87939. */
  87940. vignetteCameraFov: number;
  87941. private _vignetteBlendMode;
  87942. /**
  87943. * Gets the vignette blend mode allowing different kind of effect.
  87944. */
  87945. /**
  87946. * Sets the vignette blend mode allowing different kind of effect.
  87947. */
  87948. vignetteBlendMode: number;
  87949. private _vignetteEnabled;
  87950. /**
  87951. * Gets wether the vignette effect is enabled.
  87952. */
  87953. /**
  87954. * Sets wether the vignette effect is enabled.
  87955. */
  87956. vignetteEnabled: boolean;
  87957. private _applyByPostProcess;
  87958. /**
  87959. * Gets wether the image processing is applied through a post process or not.
  87960. */
  87961. /**
  87962. * Sets wether the image processing is applied through a post process or not.
  87963. */
  87964. applyByPostProcess: boolean;
  87965. private _isEnabled;
  87966. /**
  87967. * Gets wether the image processing is enabled or not.
  87968. */
  87969. /**
  87970. * Sets wether the image processing is enabled or not.
  87971. */
  87972. isEnabled: boolean;
  87973. /**
  87974. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  87975. */
  87976. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  87977. /**
  87978. * Method called each time the image processing information changes requires to recompile the effect.
  87979. */
  87980. protected _updateParameters(): void;
  87981. /**
  87982. * Gets the current class name.
  87983. * @return "ImageProcessingConfiguration"
  87984. */
  87985. getClassName(): string;
  87986. /**
  87987. * Prepare the list of uniforms associated with the Image Processing effects.
  87988. * @param uniforms The list of uniforms used in the effect
  87989. * @param defines the list of defines currently in use
  87990. */
  87991. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  87992. /**
  87993. * Prepare the list of samplers associated with the Image Processing effects.
  87994. * @param samplersList The list of uniforms used in the effect
  87995. * @param defines the list of defines currently in use
  87996. */
  87997. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  87998. /**
  87999. * Prepare the list of defines associated to the shader.
  88000. * @param defines the list of defines to complete
  88001. * @param forPostProcess Define if we are currently in post process mode or not
  88002. */
  88003. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  88004. /**
  88005. * Returns true if all the image processing information are ready.
  88006. * @returns True if ready, otherwise, false
  88007. */
  88008. isReady(): boolean;
  88009. /**
  88010. * Binds the image processing to the shader.
  88011. * @param effect The effect to bind to
  88012. * @param aspectRatio Define the current aspect ratio of the effect
  88013. */
  88014. bind(effect: Effect, aspectRatio?: number): void;
  88015. /**
  88016. * Clones the current image processing instance.
  88017. * @return The cloned image processing
  88018. */
  88019. clone(): ImageProcessingConfiguration;
  88020. /**
  88021. * Serializes the current image processing instance to a json representation.
  88022. * @return a JSON representation
  88023. */
  88024. serialize(): any;
  88025. /**
  88026. * Parses the image processing from a json representation.
  88027. * @param source the JSON source to parse
  88028. * @return The parsed image processing
  88029. */
  88030. static Parse(source: any): ImageProcessingConfiguration;
  88031. private static _VIGNETTEMODE_MULTIPLY;
  88032. private static _VIGNETTEMODE_OPAQUE;
  88033. /**
  88034. * Used to apply the vignette as a mix with the pixel color.
  88035. */
  88036. static readonly VIGNETTEMODE_MULTIPLY: number;
  88037. /**
  88038. * Used to apply the vignette as a replacement of the pixel color.
  88039. */
  88040. static readonly VIGNETTEMODE_OPAQUE: number;
  88041. }
  88042. }
  88043. declare module BABYLON {
  88044. /**
  88045. * This represents all the required information to add a fresnel effect on a material:
  88046. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  88047. */
  88048. export class FresnelParameters {
  88049. private _isEnabled;
  88050. /**
  88051. * Define if the fresnel effect is enable or not.
  88052. */
  88053. isEnabled: boolean;
  88054. /**
  88055. * Define the color used on edges (grazing angle)
  88056. */
  88057. leftColor: Color3;
  88058. /**
  88059. * Define the color used on center
  88060. */
  88061. rightColor: Color3;
  88062. /**
  88063. * Define bias applied to computed fresnel term
  88064. */
  88065. bias: number;
  88066. /**
  88067. * Defined the power exponent applied to fresnel term
  88068. */
  88069. power: number;
  88070. /**
  88071. * Clones the current fresnel and its valuues
  88072. * @returns a clone fresnel configuration
  88073. */
  88074. clone(): FresnelParameters;
  88075. /**
  88076. * Serializes the current fresnel parameters to a JSON representation.
  88077. * @return the JSON serialization
  88078. */
  88079. serialize(): any;
  88080. /**
  88081. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  88082. * @param parsedFresnelParameters Define the JSON representation
  88083. * @returns the parsed parameters
  88084. */
  88085. static Parse(parsedFresnelParameters: any): FresnelParameters;
  88086. }
  88087. }
  88088. declare module BABYLON {
  88089. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  88090. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88091. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88092. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88093. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88094. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88095. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88096. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88097. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88098. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88099. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88100. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88101. /**
  88102. * Decorator used to define property that can be serialized as reference to a camera
  88103. * @param sourceName defines the name of the property to decorate
  88104. */
  88105. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  88106. /**
  88107. * Class used to help serialization objects
  88108. */
  88109. export class SerializationHelper {
  88110. /** hidden */
  88111. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  88112. /** hidden */
  88113. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  88114. /** hidden */
  88115. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  88116. /** hidden */
  88117. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  88118. /**
  88119. * Appends the serialized animations from the source animations
  88120. * @param source Source containing the animations
  88121. * @param destination Target to store the animations
  88122. */
  88123. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  88124. /**
  88125. * Static function used to serialized a specific entity
  88126. * @param entity defines the entity to serialize
  88127. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  88128. * @returns a JSON compatible object representing the serialization of the entity
  88129. */
  88130. static Serialize<T>(entity: T, serializationObject?: any): any;
  88131. /**
  88132. * Creates a new entity from a serialization data object
  88133. * @param creationFunction defines a function used to instanciated the new entity
  88134. * @param source defines the source serialization data
  88135. * @param scene defines the hosting scene
  88136. * @param rootUrl defines the root url for resources
  88137. * @returns a new entity
  88138. */
  88139. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  88140. /**
  88141. * Clones an object
  88142. * @param creationFunction defines the function used to instanciate the new object
  88143. * @param source defines the source object
  88144. * @returns the cloned object
  88145. */
  88146. static Clone<T>(creationFunction: () => T, source: T): T;
  88147. /**
  88148. * Instanciates a new object based on a source one (some data will be shared between both object)
  88149. * @param creationFunction defines the function used to instanciate the new object
  88150. * @param source defines the source object
  88151. * @returns the new object
  88152. */
  88153. static Instanciate<T>(creationFunction: () => T, source: T): T;
  88154. }
  88155. }
  88156. declare module BABYLON {
  88157. /**
  88158. * This is the base class of all the camera used in the application.
  88159. * @see http://doc.babylonjs.com/features/cameras
  88160. */
  88161. export class Camera extends Node {
  88162. /** @hidden */
  88163. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  88164. /**
  88165. * This is the default projection mode used by the cameras.
  88166. * It helps recreating a feeling of perspective and better appreciate depth.
  88167. * This is the best way to simulate real life cameras.
  88168. */
  88169. static readonly PERSPECTIVE_CAMERA: number;
  88170. /**
  88171. * This helps creating camera with an orthographic mode.
  88172. * 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.
  88173. */
  88174. static readonly ORTHOGRAPHIC_CAMERA: number;
  88175. /**
  88176. * This is the default FOV mode for perspective cameras.
  88177. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  88178. */
  88179. static readonly FOVMODE_VERTICAL_FIXED: number;
  88180. /**
  88181. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  88182. */
  88183. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  88184. /**
  88185. * This specifies ther is no need for a camera rig.
  88186. * Basically only one eye is rendered corresponding to the camera.
  88187. */
  88188. static readonly RIG_MODE_NONE: number;
  88189. /**
  88190. * Simulates a camera Rig with one blue eye and one red eye.
  88191. * This can be use with 3d blue and red glasses.
  88192. */
  88193. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  88194. /**
  88195. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  88196. */
  88197. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  88198. /**
  88199. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  88200. */
  88201. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  88202. /**
  88203. * Defines that both eyes of the camera will be rendered over under each other.
  88204. */
  88205. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  88206. /**
  88207. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  88208. */
  88209. static readonly RIG_MODE_VR: number;
  88210. /**
  88211. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  88212. */
  88213. static readonly RIG_MODE_WEBVR: number;
  88214. /**
  88215. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  88216. */
  88217. static readonly RIG_MODE_CUSTOM: number;
  88218. /**
  88219. * Defines if by default attaching controls should prevent the default javascript event to continue.
  88220. */
  88221. static ForceAttachControlToAlwaysPreventDefault: boolean;
  88222. /**
  88223. * @hidden
  88224. * Might be removed once multiview will be a thing
  88225. */
  88226. static UseAlternateWebVRRendering: boolean;
  88227. /**
  88228. * Define the input manager associated with the camera.
  88229. */
  88230. inputs: CameraInputsManager<Camera>;
  88231. /** @hidden */
  88232. _position: Vector3;
  88233. /**
  88234. * Define the current local position of the camera in the scene
  88235. */
  88236. position: Vector3;
  88237. /**
  88238. * The vector the camera should consider as up.
  88239. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  88240. */
  88241. upVector: Vector3;
  88242. /**
  88243. * Define the current limit on the left side for an orthographic camera
  88244. * In scene unit
  88245. */
  88246. orthoLeft: Nullable<number>;
  88247. /**
  88248. * Define the current limit on the right side for an orthographic camera
  88249. * In scene unit
  88250. */
  88251. orthoRight: Nullable<number>;
  88252. /**
  88253. * Define the current limit on the bottom side for an orthographic camera
  88254. * In scene unit
  88255. */
  88256. orthoBottom: Nullable<number>;
  88257. /**
  88258. * Define the current limit on the top side for an orthographic camera
  88259. * In scene unit
  88260. */
  88261. orthoTop: Nullable<number>;
  88262. /**
  88263. * Field Of View is set in Radians. (default is 0.8)
  88264. */
  88265. fov: number;
  88266. /**
  88267. * Define the minimum distance the camera can see from.
  88268. * This is important to note that the depth buffer are not infinite and the closer it starts
  88269. * the more your scene might encounter depth fighting issue.
  88270. */
  88271. minZ: number;
  88272. /**
  88273. * Define the maximum distance the camera can see to.
  88274. * This is important to note that the depth buffer are not infinite and the further it end
  88275. * the more your scene might encounter depth fighting issue.
  88276. */
  88277. maxZ: number;
  88278. /**
  88279. * Define the default inertia of the camera.
  88280. * This helps giving a smooth feeling to the camera movement.
  88281. */
  88282. inertia: number;
  88283. /**
  88284. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  88285. */
  88286. mode: number;
  88287. /**
  88288. * Define wether the camera is intermediate.
  88289. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  88290. */
  88291. isIntermediate: boolean;
  88292. /**
  88293. * Define the viewport of the camera.
  88294. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  88295. */
  88296. viewport: Viewport;
  88297. /**
  88298. * Restricts the camera to viewing objects with the same layerMask.
  88299. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  88300. */
  88301. layerMask: number;
  88302. /**
  88303. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  88304. */
  88305. fovMode: number;
  88306. /**
  88307. * Rig mode of the camera.
  88308. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  88309. * This is normally controlled byt the camera themselves as internal use.
  88310. */
  88311. cameraRigMode: number;
  88312. /**
  88313. * Defines the distance between both "eyes" in case of a RIG
  88314. */
  88315. interaxialDistance: number;
  88316. /**
  88317. * Defines if stereoscopic rendering is done side by side or over under.
  88318. */
  88319. isStereoscopicSideBySide: boolean;
  88320. /**
  88321. * 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
  88322. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  88323. * else in the scene.
  88324. */
  88325. customRenderTargets: RenderTargetTexture[];
  88326. /**
  88327. * When set, the camera will render to this render target instead of the default canvas
  88328. */
  88329. outputRenderTarget: Nullable<RenderTargetTexture>;
  88330. /**
  88331. * Observable triggered when the camera view matrix has changed.
  88332. */
  88333. onViewMatrixChangedObservable: Observable<Camera>;
  88334. /**
  88335. * Observable triggered when the camera Projection matrix has changed.
  88336. */
  88337. onProjectionMatrixChangedObservable: Observable<Camera>;
  88338. /**
  88339. * Observable triggered when the inputs have been processed.
  88340. */
  88341. onAfterCheckInputsObservable: Observable<Camera>;
  88342. /**
  88343. * Observable triggered when reset has been called and applied to the camera.
  88344. */
  88345. onRestoreStateObservable: Observable<Camera>;
  88346. /** @hidden */
  88347. _cameraRigParams: any;
  88348. /** @hidden */
  88349. _rigCameras: Camera[];
  88350. /** @hidden */
  88351. _rigPostProcess: Nullable<PostProcess>;
  88352. protected _webvrViewMatrix: Matrix;
  88353. /** @hidden */
  88354. _skipRendering: boolean;
  88355. /** @hidden */
  88356. _alternateCamera: Camera;
  88357. /** @hidden */
  88358. _projectionMatrix: Matrix;
  88359. /** @hidden */
  88360. _postProcesses: Nullable<PostProcess>[];
  88361. /** @hidden */
  88362. _activeMeshes: SmartArray<AbstractMesh>;
  88363. protected _globalPosition: Vector3;
  88364. /** hidden */
  88365. _computedViewMatrix: Matrix;
  88366. private _doNotComputeProjectionMatrix;
  88367. private _transformMatrix;
  88368. private _frustumPlanes;
  88369. private _refreshFrustumPlanes;
  88370. private _storedFov;
  88371. private _stateStored;
  88372. /**
  88373. * Instantiates a new camera object.
  88374. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  88375. * @see http://doc.babylonjs.com/features/cameras
  88376. * @param name Defines the name of the camera in the scene
  88377. * @param position Defines the position of the camera
  88378. * @param scene Defines the scene the camera belongs too
  88379. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  88380. */
  88381. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  88382. /**
  88383. * Store current camera state (fov, position, etc..)
  88384. * @returns the camera
  88385. */
  88386. storeState(): Camera;
  88387. /**
  88388. * Restores the camera state values if it has been stored. You must call storeState() first
  88389. */
  88390. protected _restoreStateValues(): boolean;
  88391. /**
  88392. * Restored camera state. You must call storeState() first.
  88393. * @returns true if restored and false otherwise
  88394. */
  88395. restoreState(): boolean;
  88396. /**
  88397. * Gets the class name of the camera.
  88398. * @returns the class name
  88399. */
  88400. getClassName(): string;
  88401. /** @hidden */
  88402. readonly _isCamera: boolean;
  88403. /**
  88404. * Gets a string representation of the camera useful for debug purpose.
  88405. * @param fullDetails Defines that a more verboe level of logging is required
  88406. * @returns the string representation
  88407. */
  88408. toString(fullDetails?: boolean): string;
  88409. /**
  88410. * Gets the current world space position of the camera.
  88411. */
  88412. readonly globalPosition: Vector3;
  88413. /**
  88414. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  88415. * @returns the active meshe list
  88416. */
  88417. getActiveMeshes(): SmartArray<AbstractMesh>;
  88418. /**
  88419. * Check wether a mesh is part of the current active mesh list of the camera
  88420. * @param mesh Defines the mesh to check
  88421. * @returns true if active, false otherwise
  88422. */
  88423. isActiveMesh(mesh: Mesh): boolean;
  88424. /**
  88425. * Is this camera ready to be used/rendered
  88426. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  88427. * @return true if the camera is ready
  88428. */
  88429. isReady(completeCheck?: boolean): boolean;
  88430. /** @hidden */
  88431. _initCache(): void;
  88432. /** @hidden */
  88433. _updateCache(ignoreParentClass?: boolean): void;
  88434. /** @hidden */
  88435. _isSynchronized(): boolean;
  88436. /** @hidden */
  88437. _isSynchronizedViewMatrix(): boolean;
  88438. /** @hidden */
  88439. _isSynchronizedProjectionMatrix(): boolean;
  88440. /**
  88441. * Attach the input controls to a specific dom element to get the input from.
  88442. * @param element Defines the element the controls should be listened from
  88443. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  88444. */
  88445. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  88446. /**
  88447. * Detach the current controls from the specified dom element.
  88448. * @param element Defines the element to stop listening the inputs from
  88449. */
  88450. detachControl(element: HTMLElement): void;
  88451. /**
  88452. * Update the camera state according to the different inputs gathered during the frame.
  88453. */
  88454. update(): void;
  88455. /** @hidden */
  88456. _checkInputs(): void;
  88457. /** @hidden */
  88458. readonly rigCameras: Camera[];
  88459. /**
  88460. * Gets the post process used by the rig cameras
  88461. */
  88462. readonly rigPostProcess: Nullable<PostProcess>;
  88463. /**
  88464. * Internal, gets the first post proces.
  88465. * @returns the first post process to be run on this camera.
  88466. */
  88467. _getFirstPostProcess(): Nullable<PostProcess>;
  88468. private _cascadePostProcessesToRigCams;
  88469. /**
  88470. * Attach a post process to the camera.
  88471. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  88472. * @param postProcess The post process to attach to the camera
  88473. * @param insertAt The position of the post process in case several of them are in use in the scene
  88474. * @returns the position the post process has been inserted at
  88475. */
  88476. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  88477. /**
  88478. * Detach a post process to the camera.
  88479. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  88480. * @param postProcess The post process to detach from the camera
  88481. */
  88482. detachPostProcess(postProcess: PostProcess): void;
  88483. /**
  88484. * Gets the current world matrix of the camera
  88485. */
  88486. getWorldMatrix(): Matrix;
  88487. /** @hidden */
  88488. _getViewMatrix(): Matrix;
  88489. /**
  88490. * Gets the current view matrix of the camera.
  88491. * @param force forces the camera to recompute the matrix without looking at the cached state
  88492. * @returns the view matrix
  88493. */
  88494. getViewMatrix(force?: boolean): Matrix;
  88495. /**
  88496. * Freeze the projection matrix.
  88497. * It will prevent the cache check of the camera projection compute and can speed up perf
  88498. * if no parameter of the camera are meant to change
  88499. * @param projection Defines manually a projection if necessary
  88500. */
  88501. freezeProjectionMatrix(projection?: Matrix): void;
  88502. /**
  88503. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  88504. */
  88505. unfreezeProjectionMatrix(): void;
  88506. /**
  88507. * Gets the current projection matrix of the camera.
  88508. * @param force forces the camera to recompute the matrix without looking at the cached state
  88509. * @returns the projection matrix
  88510. */
  88511. getProjectionMatrix(force?: boolean): Matrix;
  88512. /**
  88513. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  88514. * @returns a Matrix
  88515. */
  88516. getTransformationMatrix(): Matrix;
  88517. private _updateFrustumPlanes;
  88518. /**
  88519. * Checks if a cullable object (mesh...) is in the camera frustum
  88520. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  88521. * @param target The object to check
  88522. * @returns true if the object is in frustum otherwise false
  88523. */
  88524. isInFrustum(target: ICullable): boolean;
  88525. /**
  88526. * Checks if a cullable object (mesh...) is in the camera frustum
  88527. * Unlike isInFrustum this cheks the full bounding box
  88528. * @param target The object to check
  88529. * @returns true if the object is in frustum otherwise false
  88530. */
  88531. isCompletelyInFrustum(target: ICullable): boolean;
  88532. /**
  88533. * Gets a ray in the forward direction from the camera.
  88534. * @param length Defines the length of the ray to create
  88535. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  88536. * @param origin Defines the start point of the ray which defaults to the camera position
  88537. * @returns the forward ray
  88538. */
  88539. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  88540. /**
  88541. * Releases resources associated with this node.
  88542. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88543. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88544. */
  88545. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88546. /** @hidden */
  88547. _isLeftCamera: boolean;
  88548. /**
  88549. * Gets the left camera of a rig setup in case of Rigged Camera
  88550. */
  88551. readonly isLeftCamera: boolean;
  88552. /** @hidden */
  88553. _isRightCamera: boolean;
  88554. /**
  88555. * Gets the right camera of a rig setup in case of Rigged Camera
  88556. */
  88557. readonly isRightCamera: boolean;
  88558. /**
  88559. * Gets the left camera of a rig setup in case of Rigged Camera
  88560. */
  88561. readonly leftCamera: Nullable<FreeCamera>;
  88562. /**
  88563. * Gets the right camera of a rig setup in case of Rigged Camera
  88564. */
  88565. readonly rightCamera: Nullable<FreeCamera>;
  88566. /**
  88567. * Gets the left camera target of a rig setup in case of Rigged Camera
  88568. * @returns the target position
  88569. */
  88570. getLeftTarget(): Nullable<Vector3>;
  88571. /**
  88572. * Gets the right camera target of a rig setup in case of Rigged Camera
  88573. * @returns the target position
  88574. */
  88575. getRightTarget(): Nullable<Vector3>;
  88576. /**
  88577. * @hidden
  88578. */
  88579. setCameraRigMode(mode: number, rigParams: any): void;
  88580. /** @hidden */
  88581. static _setStereoscopicRigMode(camera: Camera): void;
  88582. /** @hidden */
  88583. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  88584. /** @hidden */
  88585. static _setVRRigMode(camera: Camera, rigParams: any): void;
  88586. /** @hidden */
  88587. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  88588. /** @hidden */
  88589. _getVRProjectionMatrix(): Matrix;
  88590. protected _updateCameraRotationMatrix(): void;
  88591. protected _updateWebVRCameraRotationMatrix(): void;
  88592. /**
  88593. * This function MUST be overwritten by the different WebVR cameras available.
  88594. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  88595. * @hidden
  88596. */
  88597. _getWebVRProjectionMatrix(): Matrix;
  88598. /**
  88599. * This function MUST be overwritten by the different WebVR cameras available.
  88600. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  88601. * @hidden
  88602. */
  88603. _getWebVRViewMatrix(): Matrix;
  88604. /** @hidden */
  88605. setCameraRigParameter(name: string, value: any): void;
  88606. /**
  88607. * needs to be overridden by children so sub has required properties to be copied
  88608. * @hidden
  88609. */
  88610. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  88611. /**
  88612. * May need to be overridden by children
  88613. * @hidden
  88614. */
  88615. _updateRigCameras(): void;
  88616. /** @hidden */
  88617. _setupInputs(): void;
  88618. /**
  88619. * Serialiaze the camera setup to a json represention
  88620. * @returns the JSON representation
  88621. */
  88622. serialize(): any;
  88623. /**
  88624. * Clones the current camera.
  88625. * @param name The cloned camera name
  88626. * @returns the cloned camera
  88627. */
  88628. clone(name: string): Camera;
  88629. /**
  88630. * Gets the direction of the camera relative to a given local axis.
  88631. * @param localAxis Defines the reference axis to provide a relative direction.
  88632. * @return the direction
  88633. */
  88634. getDirection(localAxis: Vector3): Vector3;
  88635. /**
  88636. * Gets the direction of the camera relative to a given local axis into a passed vector.
  88637. * @param localAxis Defines the reference axis to provide a relative direction.
  88638. * @param result Defines the vector to store the result in
  88639. */
  88640. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  88641. /**
  88642. * Gets a camera constructor for a given camera type
  88643. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  88644. * @param name The name of the camera the result will be able to instantiate
  88645. * @param scene The scene the result will construct the camera in
  88646. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  88647. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  88648. * @returns a factory method to construc the camera
  88649. */
  88650. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  88651. /**
  88652. * Compute the world matrix of the camera.
  88653. * @returns the camera workd matrix
  88654. */
  88655. computeWorldMatrix(): Matrix;
  88656. /**
  88657. * Parse a JSON and creates the camera from the parsed information
  88658. * @param parsedCamera The JSON to parse
  88659. * @param scene The scene to instantiate the camera in
  88660. * @returns the newly constructed camera
  88661. */
  88662. static Parse(parsedCamera: any, scene: Scene): Camera;
  88663. }
  88664. }
  88665. declare module BABYLON {
  88666. /**
  88667. * Interface for any object that can request an animation frame
  88668. */
  88669. export interface ICustomAnimationFrameRequester {
  88670. /**
  88671. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  88672. */
  88673. renderFunction?: Function;
  88674. /**
  88675. * Called to request the next frame to render to
  88676. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  88677. */
  88678. requestAnimationFrame: Function;
  88679. /**
  88680. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  88681. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  88682. */
  88683. requestID?: number;
  88684. }
  88685. /**
  88686. * Interface containing an array of animations
  88687. */
  88688. export interface IAnimatable {
  88689. /**
  88690. * Array of animations
  88691. */
  88692. animations: Array<Animation>;
  88693. }
  88694. /** Interface used by value gradients (color, factor, ...) */
  88695. export interface IValueGradient {
  88696. /**
  88697. * Gets or sets the gradient value (between 0 and 1)
  88698. */
  88699. gradient: number;
  88700. }
  88701. /** Class used to store color4 gradient */
  88702. export class ColorGradient implements IValueGradient {
  88703. /**
  88704. * Gets or sets the gradient value (between 0 and 1)
  88705. */
  88706. gradient: number;
  88707. /**
  88708. * Gets or sets first associated color
  88709. */
  88710. color1: Color4;
  88711. /**
  88712. * Gets or sets second associated color
  88713. */
  88714. color2?: Color4;
  88715. /**
  88716. * Will get a color picked randomly between color1 and color2.
  88717. * If color2 is undefined then color1 will be used
  88718. * @param result defines the target Color4 to store the result in
  88719. */
  88720. getColorToRef(result: Color4): void;
  88721. }
  88722. /** Class used to store color 3 gradient */
  88723. export class Color3Gradient implements IValueGradient {
  88724. /**
  88725. * Gets or sets the gradient value (between 0 and 1)
  88726. */
  88727. gradient: number;
  88728. /**
  88729. * Gets or sets the associated color
  88730. */
  88731. color: Color3;
  88732. }
  88733. /** Class used to store factor gradient */
  88734. export class FactorGradient implements IValueGradient {
  88735. /**
  88736. * Gets or sets the gradient value (between 0 and 1)
  88737. */
  88738. gradient: number;
  88739. /**
  88740. * Gets or sets first associated factor
  88741. */
  88742. factor1: number;
  88743. /**
  88744. * Gets or sets second associated factor
  88745. */
  88746. factor2?: number;
  88747. /**
  88748. * Will get a number picked randomly between factor1 and factor2.
  88749. * If factor2 is undefined then factor1 will be used
  88750. * @returns the picked number
  88751. */
  88752. getFactor(): number;
  88753. }
  88754. /**
  88755. * @ignore
  88756. * Application error to support additional information when loading a file
  88757. */
  88758. export class LoadFileError extends Error {
  88759. /** defines the optional web request */
  88760. request?: WebRequest | undefined;
  88761. private static _setPrototypeOf;
  88762. /**
  88763. * Creates a new LoadFileError
  88764. * @param message defines the message of the error
  88765. * @param request defines the optional web request
  88766. */
  88767. constructor(message: string,
  88768. /** defines the optional web request */
  88769. request?: WebRequest | undefined);
  88770. }
  88771. /**
  88772. * Class used to define a retry strategy when error happens while loading assets
  88773. */
  88774. export class RetryStrategy {
  88775. /**
  88776. * Function used to defines an exponential back off strategy
  88777. * @param maxRetries defines the maximum number of retries (3 by default)
  88778. * @param baseInterval defines the interval between retries
  88779. * @returns the strategy function to use
  88780. */
  88781. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  88782. }
  88783. /**
  88784. * File request interface
  88785. */
  88786. export interface IFileRequest {
  88787. /**
  88788. * Raised when the request is complete (success or error).
  88789. */
  88790. onCompleteObservable: Observable<IFileRequest>;
  88791. /**
  88792. * Aborts the request for a file.
  88793. */
  88794. abort: () => void;
  88795. }
  88796. /**
  88797. * Class containing a set of static utilities functions
  88798. */
  88799. export class Tools {
  88800. /**
  88801. * Gets or sets the base URL to use to load assets
  88802. */
  88803. static BaseUrl: string;
  88804. /**
  88805. * Enable/Disable Custom HTTP Request Headers globally.
  88806. * default = false
  88807. * @see CustomRequestHeaders
  88808. */
  88809. static UseCustomRequestHeaders: boolean;
  88810. /**
  88811. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  88812. * i.e. when loading files, where the server/service expects an Authorization header
  88813. */
  88814. static CustomRequestHeaders: {
  88815. [key: string]: string;
  88816. };
  88817. /**
  88818. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  88819. */
  88820. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  88821. /**
  88822. * Default behaviour for cors in the application.
  88823. * It can be a string if the expected behavior is identical in the entire app.
  88824. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  88825. */
  88826. static CorsBehavior: string | ((url: string | string[]) => string);
  88827. /**
  88828. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  88829. * @ignorenaming
  88830. */
  88831. static UseFallbackTexture: boolean;
  88832. /**
  88833. * Use this object to register external classes like custom textures or material
  88834. * to allow the laoders to instantiate them
  88835. */
  88836. static RegisteredExternalClasses: {
  88837. [key: string]: Object;
  88838. };
  88839. /**
  88840. * Texture content used if a texture cannot loaded
  88841. * @ignorenaming
  88842. */
  88843. static fallbackTexture: string;
  88844. /**
  88845. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  88846. * @param u defines the coordinate on X axis
  88847. * @param v defines the coordinate on Y axis
  88848. * @param width defines the width of the source data
  88849. * @param height defines the height of the source data
  88850. * @param pixels defines the source byte array
  88851. * @param color defines the output color
  88852. */
  88853. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  88854. /**
  88855. * Interpolates between a and b via alpha
  88856. * @param a The lower value (returned when alpha = 0)
  88857. * @param b The upper value (returned when alpha = 1)
  88858. * @param alpha The interpolation-factor
  88859. * @return The mixed value
  88860. */
  88861. static Mix(a: number, b: number, alpha: number): number;
  88862. /**
  88863. * Tries to instantiate a new object from a given class name
  88864. * @param className defines the class name to instantiate
  88865. * @returns the new object or null if the system was not able to do the instantiation
  88866. */
  88867. static Instantiate(className: string): any;
  88868. /**
  88869. * Provides a slice function that will work even on IE
  88870. * @param data defines the array to slice
  88871. * @param start defines the start of the data (optional)
  88872. * @param end defines the end of the data (optional)
  88873. * @returns the new sliced array
  88874. */
  88875. static Slice<T>(data: T, start?: number, end?: number): T;
  88876. /**
  88877. * Polyfill for setImmediate
  88878. * @param action defines the action to execute after the current execution block
  88879. */
  88880. static SetImmediate(action: () => void): void;
  88881. /**
  88882. * Function indicating if a number is an exponent of 2
  88883. * @param value defines the value to test
  88884. * @returns true if the value is an exponent of 2
  88885. */
  88886. static IsExponentOfTwo(value: number): boolean;
  88887. private static _tmpFloatArray;
  88888. /**
  88889. * Returns the nearest 32-bit single precision float representation of a Number
  88890. * @param value A Number. If the parameter is of a different type, it will get converted
  88891. * to a number or to NaN if it cannot be converted
  88892. * @returns number
  88893. */
  88894. static FloatRound(value: number): number;
  88895. /**
  88896. * Find the next highest power of two.
  88897. * @param x Number to start search from.
  88898. * @return Next highest power of two.
  88899. */
  88900. static CeilingPOT(x: number): number;
  88901. /**
  88902. * Find the next lowest power of two.
  88903. * @param x Number to start search from.
  88904. * @return Next lowest power of two.
  88905. */
  88906. static FloorPOT(x: number): number;
  88907. /**
  88908. * Find the nearest power of two.
  88909. * @param x Number to start search from.
  88910. * @return Next nearest power of two.
  88911. */
  88912. static NearestPOT(x: number): number;
  88913. /**
  88914. * Get the closest exponent of two
  88915. * @param value defines the value to approximate
  88916. * @param max defines the maximum value to return
  88917. * @param mode defines how to define the closest value
  88918. * @returns closest exponent of two of the given value
  88919. */
  88920. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  88921. /**
  88922. * Extracts the filename from a path
  88923. * @param path defines the path to use
  88924. * @returns the filename
  88925. */
  88926. static GetFilename(path: string): string;
  88927. /**
  88928. * Extracts the "folder" part of a path (everything before the filename).
  88929. * @param uri The URI to extract the info from
  88930. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  88931. * @returns The "folder" part of the path
  88932. */
  88933. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  88934. /**
  88935. * Extracts text content from a DOM element hierarchy
  88936. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  88937. */
  88938. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  88939. /**
  88940. * Convert an angle in radians to degrees
  88941. * @param angle defines the angle to convert
  88942. * @returns the angle in degrees
  88943. */
  88944. static ToDegrees(angle: number): number;
  88945. /**
  88946. * Convert an angle in degrees to radians
  88947. * @param angle defines the angle to convert
  88948. * @returns the angle in radians
  88949. */
  88950. static ToRadians(angle: number): number;
  88951. /**
  88952. * Encode a buffer to a base64 string
  88953. * @param buffer defines the buffer to encode
  88954. * @returns the encoded string
  88955. */
  88956. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  88957. /**
  88958. * Extracts minimum and maximum values from a list of indexed positions
  88959. * @param positions defines the positions to use
  88960. * @param indices defines the indices to the positions
  88961. * @param indexStart defines the start index
  88962. * @param indexCount defines the end index
  88963. * @param bias defines bias value to add to the result
  88964. * @return minimum and maximum values
  88965. */
  88966. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  88967. minimum: Vector3;
  88968. maximum: Vector3;
  88969. };
  88970. /**
  88971. * Extracts minimum and maximum values from a list of positions
  88972. * @param positions defines the positions to use
  88973. * @param start defines the start index in the positions array
  88974. * @param count defines the number of positions to handle
  88975. * @param bias defines bias value to add to the result
  88976. * @param stride defines the stride size to use (distance between two positions in the positions array)
  88977. * @return minimum and maximum values
  88978. */
  88979. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  88980. minimum: Vector3;
  88981. maximum: Vector3;
  88982. };
  88983. /**
  88984. * Returns an array if obj is not an array
  88985. * @param obj defines the object to evaluate as an array
  88986. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  88987. * @returns either obj directly if obj is an array or a new array containing obj
  88988. */
  88989. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  88990. /**
  88991. * Gets the pointer prefix to use
  88992. * @returns "pointer" if touch is enabled. Else returns "mouse"
  88993. */
  88994. static GetPointerPrefix(): string;
  88995. /**
  88996. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  88997. * @param func - the function to be called
  88998. * @param requester - the object that will request the next frame. Falls back to window.
  88999. * @returns frame number
  89000. */
  89001. static QueueNewFrame(func: () => void, requester?: any): number;
  89002. /**
  89003. * Ask the browser to promote the current element to fullscreen rendering mode
  89004. * @param element defines the DOM element to promote
  89005. */
  89006. static RequestFullscreen(element: HTMLElement): void;
  89007. /**
  89008. * Asks the browser to exit fullscreen mode
  89009. */
  89010. static ExitFullscreen(): void;
  89011. /**
  89012. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  89013. * @param url define the url we are trying
  89014. * @param element define the dom element where to configure the cors policy
  89015. */
  89016. static SetCorsBehavior(url: string | string[], element: {
  89017. crossOrigin: string | null;
  89018. }): void;
  89019. /**
  89020. * Removes unwanted characters from an url
  89021. * @param url defines the url to clean
  89022. * @returns the cleaned url
  89023. */
  89024. static CleanUrl(url: string): string;
  89025. /**
  89026. * Gets or sets a function used to pre-process url before using them to load assets
  89027. */
  89028. static PreprocessUrl: (url: string) => string;
  89029. /**
  89030. * Loads an image as an HTMLImageElement.
  89031. * @param input url string, ArrayBuffer, or Blob to load
  89032. * @param onLoad callback called when the image successfully loads
  89033. * @param onError callback called when the image fails to load
  89034. * @param offlineProvider offline provider for caching
  89035. * @returns the HTMLImageElement of the loaded image
  89036. */
  89037. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  89038. /**
  89039. * Loads a file
  89040. * @param url url string, ArrayBuffer, or Blob to load
  89041. * @param onSuccess callback called when the file successfully loads
  89042. * @param onProgress callback called while file is loading (if the server supports this mode)
  89043. * @param offlineProvider defines the offline provider for caching
  89044. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  89045. * @param onError callback called when the file fails to load
  89046. * @returns a file request object
  89047. */
  89048. 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;
  89049. /**
  89050. * Load a script (identified by an url). When the url returns, the
  89051. * content of this file is added into a new script element, attached to the DOM (body element)
  89052. * @param scriptUrl defines the url of the script to laod
  89053. * @param onSuccess defines the callback called when the script is loaded
  89054. * @param onError defines the callback to call if an error occurs
  89055. */
  89056. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  89057. /**
  89058. * Loads a file from a blob
  89059. * @param fileToLoad defines the blob to use
  89060. * @param callback defines the callback to call when data is loaded
  89061. * @param progressCallback defines the callback to call during loading process
  89062. * @returns a file request object
  89063. */
  89064. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  89065. /**
  89066. * Loads a file
  89067. * @param fileToLoad defines the file to load
  89068. * @param callback defines the callback to call when data is loaded
  89069. * @param progressCallBack defines the callback to call during loading process
  89070. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  89071. * @returns a file request object
  89072. */
  89073. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  89074. /**
  89075. * Creates a data url from a given string content
  89076. * @param content defines the content to convert
  89077. * @returns the new data url link
  89078. */
  89079. static FileAsURL(content: string): string;
  89080. /**
  89081. * Format the given number to a specific decimal format
  89082. * @param value defines the number to format
  89083. * @param decimals defines the number of decimals to use
  89084. * @returns the formatted string
  89085. */
  89086. static Format(value: number, decimals?: number): string;
  89087. /**
  89088. * Checks if a given vector is inside a specific range
  89089. * @param v defines the vector to test
  89090. * @param min defines the minimum range
  89091. * @param max defines the maximum range
  89092. */
  89093. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  89094. /**
  89095. * Tries to copy an object by duplicating every property
  89096. * @param source defines the source object
  89097. * @param destination defines the target object
  89098. * @param doNotCopyList defines a list of properties to avoid
  89099. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  89100. */
  89101. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  89102. /**
  89103. * Gets a boolean indicating if the given object has no own property
  89104. * @param obj defines the object to test
  89105. * @returns true if object has no own property
  89106. */
  89107. static IsEmpty(obj: any): boolean;
  89108. /**
  89109. * Function used to register events at window level
  89110. * @param events defines the events to register
  89111. */
  89112. static RegisterTopRootEvents(events: {
  89113. name: string;
  89114. handler: Nullable<(e: FocusEvent) => any>;
  89115. }[]): void;
  89116. /**
  89117. * Function used to unregister events from window level
  89118. * @param events defines the events to unregister
  89119. */
  89120. static UnregisterTopRootEvents(events: {
  89121. name: string;
  89122. handler: Nullable<(e: FocusEvent) => any>;
  89123. }[]): void;
  89124. /**
  89125. * @ignore
  89126. */
  89127. static _ScreenshotCanvas: HTMLCanvasElement;
  89128. /**
  89129. * Dumps the current bound framebuffer
  89130. * @param width defines the rendering width
  89131. * @param height defines the rendering height
  89132. * @param engine defines the hosting engine
  89133. * @param successCallback defines the callback triggered once the data are available
  89134. * @param mimeType defines the mime type of the result
  89135. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  89136. */
  89137. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  89138. /**
  89139. * Converts the canvas data to blob.
  89140. * This acts as a polyfill for browsers not supporting the to blob function.
  89141. * @param canvas Defines the canvas to extract the data from
  89142. * @param successCallback Defines the callback triggered once the data are available
  89143. * @param mimeType Defines the mime type of the result
  89144. */
  89145. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  89146. /**
  89147. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  89148. * @param successCallback defines the callback triggered once the data are available
  89149. * @param mimeType defines the mime type of the result
  89150. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  89151. */
  89152. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  89153. /**
  89154. * Downloads a blob in the browser
  89155. * @param blob defines the blob to download
  89156. * @param fileName defines the name of the downloaded file
  89157. */
  89158. static Download(blob: Blob, fileName: string): void;
  89159. /**
  89160. * Captures a screenshot of the current rendering
  89161. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  89162. * @param engine defines the rendering engine
  89163. * @param camera defines the source camera
  89164. * @param size This parameter can be set to a single number or to an object with the
  89165. * following (optional) properties: precision, width, height. If a single number is passed,
  89166. * it will be used for both width and height. If an object is passed, the screenshot size
  89167. * will be derived from the parameters. The precision property is a multiplier allowing
  89168. * rendering at a higher or lower resolution
  89169. * @param successCallback defines the callback receives a single parameter which contains the
  89170. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  89171. * src parameter of an <img> to display it
  89172. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  89173. * Check your browser for supported MIME types
  89174. */
  89175. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  89176. /**
  89177. * Generates an image screenshot from the specified camera.
  89178. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  89179. * @param engine The engine to use for rendering
  89180. * @param camera The camera to use for rendering
  89181. * @param size This parameter can be set to a single number or to an object with the
  89182. * following (optional) properties: precision, width, height. If a single number is passed,
  89183. * it will be used for both width and height. If an object is passed, the screenshot size
  89184. * will be derived from the parameters. The precision property is a multiplier allowing
  89185. * rendering at a higher or lower resolution
  89186. * @param successCallback The callback receives a single parameter which contains the
  89187. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  89188. * src parameter of an <img> to display it
  89189. * @param mimeType The MIME type of the screenshot image (default: image/png).
  89190. * Check your browser for supported MIME types
  89191. * @param samples Texture samples (default: 1)
  89192. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  89193. * @param fileName A name for for the downloaded file.
  89194. */
  89195. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  89196. /**
  89197. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  89198. * Be aware Math.random() could cause collisions, but:
  89199. * "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"
  89200. * @returns a pseudo random id
  89201. */
  89202. static RandomId(): string;
  89203. /**
  89204. * Test if the given uri is a base64 string
  89205. * @param uri The uri to test
  89206. * @return True if the uri is a base64 string or false otherwise
  89207. */
  89208. static IsBase64(uri: string): boolean;
  89209. /**
  89210. * Decode the given base64 uri.
  89211. * @param uri The uri to decode
  89212. * @return The decoded base64 data.
  89213. */
  89214. static DecodeBase64(uri: string): ArrayBuffer;
  89215. /**
  89216. * No log
  89217. */
  89218. static readonly NoneLogLevel: number;
  89219. /**
  89220. * Only message logs
  89221. */
  89222. static readonly MessageLogLevel: number;
  89223. /**
  89224. * Only warning logs
  89225. */
  89226. static readonly WarningLogLevel: number;
  89227. /**
  89228. * Only error logs
  89229. */
  89230. static readonly ErrorLogLevel: number;
  89231. /**
  89232. * All logs
  89233. */
  89234. static readonly AllLogLevel: number;
  89235. /**
  89236. * Gets a value indicating the number of loading errors
  89237. * @ignorenaming
  89238. */
  89239. static readonly errorsCount: number;
  89240. /**
  89241. * Callback called when a new log is added
  89242. */
  89243. static OnNewCacheEntry: (entry: string) => void;
  89244. /**
  89245. * Log a message to the console
  89246. * @param message defines the message to log
  89247. */
  89248. static Log(message: string): void;
  89249. /**
  89250. * Write a warning message to the console
  89251. * @param message defines the message to log
  89252. */
  89253. static Warn(message: string): void;
  89254. /**
  89255. * Write an error message to the console
  89256. * @param message defines the message to log
  89257. */
  89258. static Error(message: string): void;
  89259. /**
  89260. * Gets current log cache (list of logs)
  89261. */
  89262. static readonly LogCache: string;
  89263. /**
  89264. * Clears the log cache
  89265. */
  89266. static ClearLogCache(): void;
  89267. /**
  89268. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  89269. */
  89270. static LogLevels: number;
  89271. /**
  89272. * Checks if the loaded document was accessed via `file:`-Protocol.
  89273. * @returns boolean
  89274. */
  89275. static IsFileURL(): boolean;
  89276. /**
  89277. * Checks if the window object exists
  89278. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  89279. */
  89280. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  89281. /**
  89282. * No performance log
  89283. */
  89284. static readonly PerformanceNoneLogLevel: number;
  89285. /**
  89286. * Use user marks to log performance
  89287. */
  89288. static readonly PerformanceUserMarkLogLevel: number;
  89289. /**
  89290. * Log performance to the console
  89291. */
  89292. static readonly PerformanceConsoleLogLevel: number;
  89293. private static _performance;
  89294. /**
  89295. * Sets the current performance log level
  89296. */
  89297. static PerformanceLogLevel: number;
  89298. private static _StartPerformanceCounterDisabled;
  89299. private static _EndPerformanceCounterDisabled;
  89300. private static _StartUserMark;
  89301. private static _EndUserMark;
  89302. private static _StartPerformanceConsole;
  89303. private static _EndPerformanceConsole;
  89304. /**
  89305. * Starts a performance counter
  89306. */
  89307. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  89308. /**
  89309. * Ends a specific performance coutner
  89310. */
  89311. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  89312. /**
  89313. * Gets either window.performance.now() if supported or Date.now() else
  89314. */
  89315. static readonly Now: number;
  89316. /**
  89317. * This method will return the name of the class used to create the instance of the given object.
  89318. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  89319. * @param object the object to get the class name from
  89320. * @param isType defines if the object is actually a type
  89321. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  89322. */
  89323. static GetClassName(object: any, isType?: boolean): string;
  89324. /**
  89325. * Gets the first element of an array satisfying a given predicate
  89326. * @param array defines the array to browse
  89327. * @param predicate defines the predicate to use
  89328. * @returns null if not found or the element
  89329. */
  89330. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  89331. /**
  89332. * This method will return the name of the full name of the class, including its owning module (if any).
  89333. * 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).
  89334. * @param object the object to get the class name from
  89335. * @param isType defines if the object is actually a type
  89336. * @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.
  89337. * @ignorenaming
  89338. */
  89339. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  89340. /**
  89341. * Returns a promise that resolves after the given amount of time.
  89342. * @param delay Number of milliseconds to delay
  89343. * @returns Promise that resolves after the given amount of time
  89344. */
  89345. static DelayAsync(delay: number): Promise<void>;
  89346. /**
  89347. * Gets the current gradient from an array of IValueGradient
  89348. * @param ratio defines the current ratio to get
  89349. * @param gradients defines the array of IValueGradient
  89350. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  89351. */
  89352. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  89353. }
  89354. /**
  89355. * This class is used to track a performance counter which is number based.
  89356. * The user has access to many properties which give statistics of different nature.
  89357. *
  89358. * The implementer can track two kinds of Performance Counter: time and count.
  89359. * 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.
  89360. * 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.
  89361. */
  89362. export class PerfCounter {
  89363. /**
  89364. * Gets or sets a global boolean to turn on and off all the counters
  89365. */
  89366. static Enabled: boolean;
  89367. /**
  89368. * Returns the smallest value ever
  89369. */
  89370. readonly min: number;
  89371. /**
  89372. * Returns the biggest value ever
  89373. */
  89374. readonly max: number;
  89375. /**
  89376. * Returns the average value since the performance counter is running
  89377. */
  89378. readonly average: number;
  89379. /**
  89380. * Returns the average value of the last second the counter was monitored
  89381. */
  89382. readonly lastSecAverage: number;
  89383. /**
  89384. * Returns the current value
  89385. */
  89386. readonly current: number;
  89387. /**
  89388. * Gets the accumulated total
  89389. */
  89390. readonly total: number;
  89391. /**
  89392. * Gets the total value count
  89393. */
  89394. readonly count: number;
  89395. /**
  89396. * Creates a new counter
  89397. */
  89398. constructor();
  89399. /**
  89400. * Call this method to start monitoring a new frame.
  89401. * 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.
  89402. */
  89403. fetchNewFrame(): void;
  89404. /**
  89405. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  89406. * @param newCount the count value to add to the monitored count
  89407. * @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.
  89408. */
  89409. addCount(newCount: number, fetchResult: boolean): void;
  89410. /**
  89411. * Start monitoring this performance counter
  89412. */
  89413. beginMonitoring(): void;
  89414. /**
  89415. * Compute the time lapsed since the previous beginMonitoring() call.
  89416. * @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
  89417. */
  89418. endMonitoring(newFrame?: boolean): void;
  89419. private _fetchResult;
  89420. private _startMonitoringTime;
  89421. private _min;
  89422. private _max;
  89423. private _average;
  89424. private _current;
  89425. private _totalValueCount;
  89426. private _totalAccumulated;
  89427. private _lastSecAverage;
  89428. private _lastSecAccumulated;
  89429. private _lastSecTime;
  89430. private _lastSecValueCount;
  89431. }
  89432. /**
  89433. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  89434. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  89435. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  89436. * @param name The name of the class, case should be preserved
  89437. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  89438. */
  89439. export function className(name: string, module?: string): (target: Object) => void;
  89440. /**
  89441. * An implementation of a loop for asynchronous functions.
  89442. */
  89443. export class AsyncLoop {
  89444. /**
  89445. * Defines the number of iterations for the loop
  89446. */
  89447. iterations: number;
  89448. /**
  89449. * Defines the current index of the loop.
  89450. */
  89451. index: number;
  89452. private _done;
  89453. private _fn;
  89454. private _successCallback;
  89455. /**
  89456. * Constructor.
  89457. * @param iterations the number of iterations.
  89458. * @param func the function to run each iteration
  89459. * @param successCallback the callback that will be called upon succesful execution
  89460. * @param offset starting offset.
  89461. */
  89462. constructor(
  89463. /**
  89464. * Defines the number of iterations for the loop
  89465. */
  89466. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  89467. /**
  89468. * Execute the next iteration. Must be called after the last iteration was finished.
  89469. */
  89470. executeNext(): void;
  89471. /**
  89472. * Break the loop and run the success callback.
  89473. */
  89474. breakLoop(): void;
  89475. /**
  89476. * Create and run an async loop.
  89477. * @param iterations the number of iterations.
  89478. * @param fn the function to run each iteration
  89479. * @param successCallback the callback that will be called upon succesful execution
  89480. * @param offset starting offset.
  89481. * @returns the created async loop object
  89482. */
  89483. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  89484. /**
  89485. * A for-loop that will run a given number of iterations synchronous and the rest async.
  89486. * @param iterations total number of iterations
  89487. * @param syncedIterations number of synchronous iterations in each async iteration.
  89488. * @param fn the function to call each iteration.
  89489. * @param callback a success call back that will be called when iterating stops.
  89490. * @param breakFunction a break condition (optional)
  89491. * @param timeout timeout settings for the setTimeout function. default - 0.
  89492. * @returns the created async loop object
  89493. */
  89494. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  89495. }
  89496. }
  89497. declare module BABYLON {
  89498. /** @hidden */
  89499. export interface ICollisionCoordinator {
  89500. createCollider(): Collider;
  89501. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  89502. init(scene: Scene): void;
  89503. }
  89504. /** @hidden */
  89505. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  89506. private _scene;
  89507. private _scaledPosition;
  89508. private _scaledVelocity;
  89509. private _finalPosition;
  89510. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  89511. createCollider(): Collider;
  89512. init(scene: Scene): void;
  89513. private _collideWithWorld;
  89514. }
  89515. }
  89516. declare module BABYLON {
  89517. /**
  89518. * This class defines the direct association between an animation and a target
  89519. */
  89520. export class TargetedAnimation {
  89521. /**
  89522. * Animation to perform
  89523. */
  89524. animation: Animation;
  89525. /**
  89526. * Target to animate
  89527. */
  89528. target: any;
  89529. }
  89530. /**
  89531. * Use this class to create coordinated animations on multiple targets
  89532. */
  89533. export class AnimationGroup implements IDisposable {
  89534. /** The name of the animation group */
  89535. name: string;
  89536. private _scene;
  89537. private _targetedAnimations;
  89538. private _animatables;
  89539. private _from;
  89540. private _to;
  89541. private _isStarted;
  89542. private _isPaused;
  89543. private _speedRatio;
  89544. /**
  89545. * Gets or sets the unique id of the node
  89546. */
  89547. uniqueId: number;
  89548. /**
  89549. * This observable will notify when one animation have ended
  89550. */
  89551. onAnimationEndObservable: Observable<TargetedAnimation>;
  89552. /**
  89553. * Observer raised when one animation loops
  89554. */
  89555. onAnimationLoopObservable: Observable<TargetedAnimation>;
  89556. /**
  89557. * This observable will notify when all animations have ended.
  89558. */
  89559. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  89560. /**
  89561. * This observable will notify when all animations have paused.
  89562. */
  89563. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  89564. /**
  89565. * This observable will notify when all animations are playing.
  89566. */
  89567. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  89568. /**
  89569. * Gets the first frame
  89570. */
  89571. readonly from: number;
  89572. /**
  89573. * Gets the last frame
  89574. */
  89575. readonly to: number;
  89576. /**
  89577. * Define if the animations are started
  89578. */
  89579. readonly isStarted: boolean;
  89580. /**
  89581. * Gets a value indicating that the current group is playing
  89582. */
  89583. readonly isPlaying: boolean;
  89584. /**
  89585. * Gets or sets the speed ratio to use for all animations
  89586. */
  89587. /**
  89588. * Gets or sets the speed ratio to use for all animations
  89589. */
  89590. speedRatio: number;
  89591. /**
  89592. * Gets the targeted animations for this animation group
  89593. */
  89594. readonly targetedAnimations: Array<TargetedAnimation>;
  89595. /**
  89596. * returning the list of animatables controlled by this animation group.
  89597. */
  89598. readonly animatables: Array<Animatable>;
  89599. /**
  89600. * Instantiates a new Animation Group.
  89601. * This helps managing several animations at once.
  89602. * @see http://doc.babylonjs.com/how_to/group
  89603. * @param name Defines the name of the group
  89604. * @param scene Defines the scene the group belongs to
  89605. */
  89606. constructor(
  89607. /** The name of the animation group */
  89608. name: string, scene?: Nullable<Scene>);
  89609. /**
  89610. * Add an animation (with its target) in the group
  89611. * @param animation defines the animation we want to add
  89612. * @param target defines the target of the animation
  89613. * @returns the TargetedAnimation object
  89614. */
  89615. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  89616. /**
  89617. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  89618. * It can add constant keys at begin or end
  89619. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  89620. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  89621. * @returns the animation group
  89622. */
  89623. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  89624. /**
  89625. * Start all animations on given targets
  89626. * @param loop defines if animations must loop
  89627. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  89628. * @param from defines the from key (optional)
  89629. * @param to defines the to key (optional)
  89630. * @returns the current animation group
  89631. */
  89632. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  89633. /**
  89634. * Pause all animations
  89635. * @returns the animation group
  89636. */
  89637. pause(): AnimationGroup;
  89638. /**
  89639. * Play all animations to initial state
  89640. * This function will start() the animations if they were not started or will restart() them if they were paused
  89641. * @param loop defines if animations must loop
  89642. * @returns the animation group
  89643. */
  89644. play(loop?: boolean): AnimationGroup;
  89645. /**
  89646. * Reset all animations to initial state
  89647. * @returns the animation group
  89648. */
  89649. reset(): AnimationGroup;
  89650. /**
  89651. * Restart animations from key 0
  89652. * @returns the animation group
  89653. */
  89654. restart(): AnimationGroup;
  89655. /**
  89656. * Stop all animations
  89657. * @returns the animation group
  89658. */
  89659. stop(): AnimationGroup;
  89660. /**
  89661. * Set animation weight for all animatables
  89662. * @param weight defines the weight to use
  89663. * @return the animationGroup
  89664. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  89665. */
  89666. setWeightForAllAnimatables(weight: number): AnimationGroup;
  89667. /**
  89668. * Synchronize and normalize all animatables with a source animatable
  89669. * @param root defines the root animatable to synchronize with
  89670. * @return the animationGroup
  89671. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  89672. */
  89673. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  89674. /**
  89675. * Goes to a specific frame in this animation group
  89676. * @param frame the frame number to go to
  89677. * @return the animationGroup
  89678. */
  89679. goToFrame(frame: number): AnimationGroup;
  89680. /**
  89681. * Dispose all associated resources
  89682. */
  89683. dispose(): void;
  89684. private _checkAnimationGroupEnded;
  89685. /**
  89686. * Clone the current animation group and returns a copy
  89687. * @param newName defines the name of the new group
  89688. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  89689. * @returns the new aniamtion group
  89690. */
  89691. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  89692. /**
  89693. * Returns a new AnimationGroup object parsed from the source provided.
  89694. * @param parsedAnimationGroup defines the source
  89695. * @param scene defines the scene that will receive the animationGroup
  89696. * @returns a new AnimationGroup
  89697. */
  89698. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  89699. /**
  89700. * Returns the string "AnimationGroup"
  89701. * @returns "AnimationGroup"
  89702. */
  89703. getClassName(): string;
  89704. /**
  89705. * Creates a detailled string about the object
  89706. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  89707. * @returns a string representing the object
  89708. */
  89709. toString(fullDetails?: boolean): string;
  89710. }
  89711. }
  89712. declare module BABYLON {
  89713. /**
  89714. * Define an interface for all classes that will hold resources
  89715. */
  89716. export interface IDisposable {
  89717. /**
  89718. * Releases all held resources
  89719. */
  89720. dispose(): void;
  89721. }
  89722. /** Interface defining initialization parameters for Scene class */
  89723. export interface SceneOptions {
  89724. /**
  89725. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  89726. * It will improve performance when the number of geometries becomes important.
  89727. */
  89728. useGeometryUniqueIdsMap?: boolean;
  89729. /**
  89730. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  89731. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  89732. */
  89733. useMaterialMeshMap?: boolean;
  89734. /**
  89735. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  89736. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  89737. */
  89738. useClonedMeshhMap?: boolean;
  89739. }
  89740. /**
  89741. * Represents a scene to be rendered by the engine.
  89742. * @see http://doc.babylonjs.com/features/scene
  89743. */
  89744. export class Scene extends AbstractScene implements IAnimatable {
  89745. private static _uniqueIdCounter;
  89746. /** The fog is deactivated */
  89747. static readonly FOGMODE_NONE: number;
  89748. /** The fog density is following an exponential function */
  89749. static readonly FOGMODE_EXP: number;
  89750. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  89751. static readonly FOGMODE_EXP2: number;
  89752. /** The fog density is following a linear function. */
  89753. static readonly FOGMODE_LINEAR: number;
  89754. /**
  89755. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  89756. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89757. */
  89758. static MinDeltaTime: number;
  89759. /**
  89760. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  89761. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89762. */
  89763. static MaxDeltaTime: number;
  89764. /**
  89765. * Factory used to create the default material.
  89766. * @param name The name of the material to create
  89767. * @param scene The scene to create the material for
  89768. * @returns The default material
  89769. */
  89770. static DefaultMaterialFactory(scene: Scene): Material;
  89771. /**
  89772. * Factory used to create the a collision coordinator.
  89773. * @returns The collision coordinator
  89774. */
  89775. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  89776. /** @hidden */
  89777. readonly _isScene: boolean;
  89778. /**
  89779. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  89780. */
  89781. autoClear: boolean;
  89782. /**
  89783. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  89784. */
  89785. autoClearDepthAndStencil: boolean;
  89786. /**
  89787. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  89788. */
  89789. clearColor: Color4;
  89790. /**
  89791. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  89792. */
  89793. ambientColor: Color3;
  89794. /** @hidden */
  89795. _environmentBRDFTexture: BaseTexture;
  89796. /** @hidden */
  89797. protected _environmentTexture: Nullable<BaseTexture>;
  89798. /**
  89799. * Texture used in all pbr material as the reflection texture.
  89800. * As in the majority of the scene they are the same (exception for multi room and so on),
  89801. * this is easier to reference from here than from all the materials.
  89802. */
  89803. /**
  89804. * Texture used in all pbr material as the reflection texture.
  89805. * As in the majority of the scene they are the same (exception for multi room and so on),
  89806. * this is easier to set here than in all the materials.
  89807. */
  89808. environmentTexture: Nullable<BaseTexture>;
  89809. /** @hidden */
  89810. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  89811. /**
  89812. * Default image processing configuration used either in the rendering
  89813. * Forward main pass or through the imageProcessingPostProcess if present.
  89814. * As in the majority of the scene they are the same (exception for multi camera),
  89815. * this is easier to reference from here than from all the materials and post process.
  89816. *
  89817. * No setter as we it is a shared configuration, you can set the values instead.
  89818. */
  89819. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  89820. private _forceWireframe;
  89821. /**
  89822. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  89823. */
  89824. forceWireframe: boolean;
  89825. private _forcePointsCloud;
  89826. /**
  89827. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  89828. */
  89829. forcePointsCloud: boolean;
  89830. /**
  89831. * Gets or sets the active clipplane 1
  89832. */
  89833. clipPlane: Nullable<Plane>;
  89834. /**
  89835. * Gets or sets the active clipplane 2
  89836. */
  89837. clipPlane2: Nullable<Plane>;
  89838. /**
  89839. * Gets or sets the active clipplane 3
  89840. */
  89841. clipPlane3: Nullable<Plane>;
  89842. /**
  89843. * Gets or sets the active clipplane 4
  89844. */
  89845. clipPlane4: Nullable<Plane>;
  89846. /**
  89847. * Gets or sets a boolean indicating if animations are enabled
  89848. */
  89849. animationsEnabled: boolean;
  89850. private _animationPropertiesOverride;
  89851. /**
  89852. * Gets or sets the animation properties override
  89853. */
  89854. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  89855. /**
  89856. * Gets or sets a boolean indicating if a constant deltatime has to be used
  89857. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  89858. */
  89859. useConstantAnimationDeltaTime: boolean;
  89860. /**
  89861. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  89862. * Please note that it requires to run a ray cast through the scene on every frame
  89863. */
  89864. constantlyUpdateMeshUnderPointer: boolean;
  89865. /**
  89866. * Defines the HTML cursor to use when hovering over interactive elements
  89867. */
  89868. hoverCursor: string;
  89869. /**
  89870. * Defines the HTML default cursor to use (empty by default)
  89871. */
  89872. defaultCursor: string;
  89873. /**
  89874. * This is used to call preventDefault() on pointer down
  89875. * in order to block unwanted artifacts like system double clicks
  89876. */
  89877. preventDefaultOnPointerDown: boolean;
  89878. /**
  89879. * This is used to call preventDefault() on pointer up
  89880. * in order to block unwanted artifacts like system double clicks
  89881. */
  89882. preventDefaultOnPointerUp: boolean;
  89883. /**
  89884. * Gets or sets user defined metadata
  89885. */
  89886. metadata: any;
  89887. /**
  89888. * For internal use only. Please do not use.
  89889. */
  89890. reservedDataStore: any;
  89891. /**
  89892. * Gets the name of the plugin used to load this scene (null by default)
  89893. */
  89894. loadingPluginName: string;
  89895. /**
  89896. * Use this array to add regular expressions used to disable offline support for specific urls
  89897. */
  89898. disableOfflineSupportExceptionRules: RegExp[];
  89899. /**
  89900. * An event triggered when the scene is disposed.
  89901. */
  89902. onDisposeObservable: Observable<Scene>;
  89903. private _onDisposeObserver;
  89904. /** Sets a function to be executed when this scene is disposed. */
  89905. onDispose: () => void;
  89906. /**
  89907. * An event triggered before rendering the scene (right after animations and physics)
  89908. */
  89909. onBeforeRenderObservable: Observable<Scene>;
  89910. private _onBeforeRenderObserver;
  89911. /** Sets a function to be executed before rendering this scene */
  89912. beforeRender: Nullable<() => void>;
  89913. /**
  89914. * An event triggered after rendering the scene
  89915. */
  89916. onAfterRenderObservable: Observable<Scene>;
  89917. private _onAfterRenderObserver;
  89918. /** Sets a function to be executed after rendering this scene */
  89919. afterRender: Nullable<() => void>;
  89920. /**
  89921. * An event triggered before animating the scene
  89922. */
  89923. onBeforeAnimationsObservable: Observable<Scene>;
  89924. /**
  89925. * An event triggered after animations processing
  89926. */
  89927. onAfterAnimationsObservable: Observable<Scene>;
  89928. /**
  89929. * An event triggered before draw calls are ready to be sent
  89930. */
  89931. onBeforeDrawPhaseObservable: Observable<Scene>;
  89932. /**
  89933. * An event triggered after draw calls have been sent
  89934. */
  89935. onAfterDrawPhaseObservable: Observable<Scene>;
  89936. /**
  89937. * An event triggered when the scene is ready
  89938. */
  89939. onReadyObservable: Observable<Scene>;
  89940. /**
  89941. * An event triggered before rendering a camera
  89942. */
  89943. onBeforeCameraRenderObservable: Observable<Camera>;
  89944. private _onBeforeCameraRenderObserver;
  89945. /** Sets a function to be executed before rendering a camera*/
  89946. beforeCameraRender: () => void;
  89947. /**
  89948. * An event triggered after rendering a camera
  89949. */
  89950. onAfterCameraRenderObservable: Observable<Camera>;
  89951. private _onAfterCameraRenderObserver;
  89952. /** Sets a function to be executed after rendering a camera*/
  89953. afterCameraRender: () => void;
  89954. /**
  89955. * An event triggered when active meshes evaluation is about to start
  89956. */
  89957. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  89958. /**
  89959. * An event triggered when active meshes evaluation is done
  89960. */
  89961. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  89962. /**
  89963. * An event triggered when particles rendering is about to start
  89964. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  89965. */
  89966. onBeforeParticlesRenderingObservable: Observable<Scene>;
  89967. /**
  89968. * An event triggered when particles rendering is done
  89969. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  89970. */
  89971. onAfterParticlesRenderingObservable: Observable<Scene>;
  89972. /**
  89973. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  89974. */
  89975. onDataLoadedObservable: Observable<Scene>;
  89976. /**
  89977. * An event triggered when a camera is created
  89978. */
  89979. onNewCameraAddedObservable: Observable<Camera>;
  89980. /**
  89981. * An event triggered when a camera is removed
  89982. */
  89983. onCameraRemovedObservable: Observable<Camera>;
  89984. /**
  89985. * An event triggered when a light is created
  89986. */
  89987. onNewLightAddedObservable: Observable<Light>;
  89988. /**
  89989. * An event triggered when a light is removed
  89990. */
  89991. onLightRemovedObservable: Observable<Light>;
  89992. /**
  89993. * An event triggered when a geometry is created
  89994. */
  89995. onNewGeometryAddedObservable: Observable<Geometry>;
  89996. /**
  89997. * An event triggered when a geometry is removed
  89998. */
  89999. onGeometryRemovedObservable: Observable<Geometry>;
  90000. /**
  90001. * An event triggered when a transform node is created
  90002. */
  90003. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  90004. /**
  90005. * An event triggered when a transform node is removed
  90006. */
  90007. onTransformNodeRemovedObservable: Observable<TransformNode>;
  90008. /**
  90009. * An event triggered when a mesh is created
  90010. */
  90011. onNewMeshAddedObservable: Observable<AbstractMesh>;
  90012. /**
  90013. * An event triggered when a mesh is removed
  90014. */
  90015. onMeshRemovedObservable: Observable<AbstractMesh>;
  90016. /**
  90017. * An event triggered when a skeleton is created
  90018. */
  90019. onNewSkeletonAddedObservable: Observable<Skeleton>;
  90020. /**
  90021. * An event triggered when a skeleton is removed
  90022. */
  90023. onSkeletonRemovedObservable: Observable<Skeleton>;
  90024. /**
  90025. * An event triggered when a material is created
  90026. */
  90027. onNewMaterialAddedObservable: Observable<Material>;
  90028. /**
  90029. * An event triggered when a material is removed
  90030. */
  90031. onMaterialRemovedObservable: Observable<Material>;
  90032. /**
  90033. * An event triggered when a texture is created
  90034. */
  90035. onNewTextureAddedObservable: Observable<BaseTexture>;
  90036. /**
  90037. * An event triggered when a texture is removed
  90038. */
  90039. onTextureRemovedObservable: Observable<BaseTexture>;
  90040. /**
  90041. * An event triggered when render targets are about to be rendered
  90042. * Can happen multiple times per frame.
  90043. */
  90044. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  90045. /**
  90046. * An event triggered when render targets were rendered.
  90047. * Can happen multiple times per frame.
  90048. */
  90049. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  90050. /**
  90051. * An event triggered before calculating deterministic simulation step
  90052. */
  90053. onBeforeStepObservable: Observable<Scene>;
  90054. /**
  90055. * An event triggered after calculating deterministic simulation step
  90056. */
  90057. onAfterStepObservable: Observable<Scene>;
  90058. /**
  90059. * An event triggered when the activeCamera property is updated
  90060. */
  90061. onActiveCameraChanged: Observable<Scene>;
  90062. /**
  90063. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  90064. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  90065. * 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)
  90066. */
  90067. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  90068. /**
  90069. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  90070. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  90071. * 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)
  90072. */
  90073. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  90074. /**
  90075. * This Observable will when a mesh has been imported into the scene.
  90076. */
  90077. onMeshImportedObservable: Observable<AbstractMesh>;
  90078. /**
  90079. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  90080. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  90081. */
  90082. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  90083. /** @hidden */
  90084. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  90085. /**
  90086. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  90087. */
  90088. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  90089. /**
  90090. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  90091. */
  90092. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  90093. /**
  90094. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  90095. */
  90096. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  90097. private _onPointerMove;
  90098. private _onPointerDown;
  90099. private _onPointerUp;
  90100. /** Callback called when a pointer move is detected */
  90101. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  90102. /** Callback called when a pointer down is detected */
  90103. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  90104. /** Callback called when a pointer up is detected */
  90105. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  90106. /** Callback called when a pointer pick is detected */
  90107. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  90108. /**
  90109. * 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).
  90110. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  90111. */
  90112. onPrePointerObservable: Observable<PointerInfoPre>;
  90113. /**
  90114. * Observable event triggered each time an input event is received from the rendering canvas
  90115. */
  90116. onPointerObservable: Observable<PointerInfo>;
  90117. /**
  90118. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  90119. */
  90120. readonly unTranslatedPointer: Vector2;
  90121. /** The distance in pixel that you have to move to prevent some events */
  90122. static DragMovementThreshold: number;
  90123. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  90124. static LongPressDelay: number;
  90125. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  90126. static DoubleClickDelay: number;
  90127. /** If you need to check double click without raising a single click at first click, enable this flag */
  90128. static ExclusiveDoubleClickMode: boolean;
  90129. private _initClickEvent;
  90130. private _initActionManager;
  90131. private _delayedSimpleClick;
  90132. private _delayedSimpleClickTimeout;
  90133. private _previousDelayedSimpleClickTimeout;
  90134. private _meshPickProceed;
  90135. private _previousButtonPressed;
  90136. private _currentPickResult;
  90137. private _previousPickResult;
  90138. private _totalPointersPressed;
  90139. private _doubleClickOccured;
  90140. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  90141. cameraToUseForPointers: Nullable<Camera>;
  90142. private _pointerX;
  90143. private _pointerY;
  90144. private _unTranslatedPointerX;
  90145. private _unTranslatedPointerY;
  90146. private _startingPointerPosition;
  90147. private _previousStartingPointerPosition;
  90148. private _startingPointerTime;
  90149. private _previousStartingPointerTime;
  90150. private _pointerCaptures;
  90151. private _timeAccumulator;
  90152. private _currentStepId;
  90153. private _currentInternalStep;
  90154. /** @hidden */
  90155. _mirroredCameraPosition: Nullable<Vector3>;
  90156. /**
  90157. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  90158. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  90159. */
  90160. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  90161. /**
  90162. * Observable event triggered each time an keyboard event is received from the hosting window
  90163. */
  90164. onKeyboardObservable: Observable<KeyboardInfo>;
  90165. private _onKeyDown;
  90166. private _onKeyUp;
  90167. private _onCanvasFocusObserver;
  90168. private _onCanvasBlurObserver;
  90169. private _useRightHandedSystem;
  90170. /**
  90171. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  90172. */
  90173. useRightHandedSystem: boolean;
  90174. /**
  90175. * Sets the step Id used by deterministic lock step
  90176. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90177. * @param newStepId defines the step Id
  90178. */
  90179. setStepId(newStepId: number): void;
  90180. /**
  90181. * Gets the step Id used by deterministic lock step
  90182. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90183. * @returns the step Id
  90184. */
  90185. getStepId(): number;
  90186. /**
  90187. * Gets the internal step used by deterministic lock step
  90188. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90189. * @returns the internal step
  90190. */
  90191. getInternalStep(): number;
  90192. private _fogEnabled;
  90193. /**
  90194. * Gets or sets a boolean indicating if fog is enabled on this scene
  90195. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90196. * (Default is true)
  90197. */
  90198. fogEnabled: boolean;
  90199. private _fogMode;
  90200. /**
  90201. * Gets or sets the fog mode to use
  90202. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90203. * | mode | value |
  90204. * | --- | --- |
  90205. * | FOGMODE_NONE | 0 |
  90206. * | FOGMODE_EXP | 1 |
  90207. * | FOGMODE_EXP2 | 2 |
  90208. * | FOGMODE_LINEAR | 3 |
  90209. */
  90210. fogMode: number;
  90211. /**
  90212. * Gets or sets the fog color to use
  90213. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90214. * (Default is Color3(0.2, 0.2, 0.3))
  90215. */
  90216. fogColor: Color3;
  90217. /**
  90218. * Gets or sets the fog density to use
  90219. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90220. * (Default is 0.1)
  90221. */
  90222. fogDensity: number;
  90223. /**
  90224. * Gets or sets the fog start distance to use
  90225. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90226. * (Default is 0)
  90227. */
  90228. fogStart: number;
  90229. /**
  90230. * Gets or sets the fog end distance to use
  90231. * @see http://doc.babylonjs.com/babylon101/environment#fog
  90232. * (Default is 1000)
  90233. */
  90234. fogEnd: number;
  90235. private _shadowsEnabled;
  90236. /**
  90237. * Gets or sets a boolean indicating if shadows are enabled on this scene
  90238. */
  90239. shadowsEnabled: boolean;
  90240. private _lightsEnabled;
  90241. /**
  90242. * Gets or sets a boolean indicating if lights are enabled on this scene
  90243. */
  90244. lightsEnabled: boolean;
  90245. /** All of the active cameras added to this scene. */
  90246. activeCameras: Camera[];
  90247. private _activeCamera;
  90248. /** Gets or sets the current active camera */
  90249. activeCamera: Nullable<Camera>;
  90250. private _defaultMaterial;
  90251. /** The default material used on meshes when no material is affected */
  90252. /** The default material used on meshes when no material is affected */
  90253. defaultMaterial: Material;
  90254. private _texturesEnabled;
  90255. /**
  90256. * Gets or sets a boolean indicating if textures are enabled on this scene
  90257. */
  90258. texturesEnabled: boolean;
  90259. /**
  90260. * Gets or sets a boolean indicating if particles are enabled on this scene
  90261. */
  90262. particlesEnabled: boolean;
  90263. /**
  90264. * Gets or sets a boolean indicating if sprites are enabled on this scene
  90265. */
  90266. spritesEnabled: boolean;
  90267. private _skeletonsEnabled;
  90268. /**
  90269. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  90270. */
  90271. skeletonsEnabled: boolean;
  90272. /**
  90273. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  90274. */
  90275. lensFlaresEnabled: boolean;
  90276. /**
  90277. * Gets or sets a boolean indicating if collisions are enabled on this scene
  90278. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90279. */
  90280. collisionsEnabled: boolean;
  90281. private _collisionCoordinator;
  90282. /** @hidden */
  90283. readonly collisionCoordinator: ICollisionCoordinator;
  90284. /**
  90285. * Defines the gravity applied to this scene (used only for collisions)
  90286. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  90287. */
  90288. gravity: Vector3;
  90289. /**
  90290. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  90291. */
  90292. postProcessesEnabled: boolean;
  90293. /**
  90294. * The list of postprocesses added to the scene
  90295. */
  90296. postProcesses: PostProcess[];
  90297. /**
  90298. * Gets the current postprocess manager
  90299. */
  90300. postProcessManager: PostProcessManager;
  90301. /**
  90302. * Gets or sets a boolean indicating if render targets are enabled on this scene
  90303. */
  90304. renderTargetsEnabled: boolean;
  90305. /**
  90306. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  90307. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  90308. */
  90309. dumpNextRenderTargets: boolean;
  90310. /**
  90311. * The list of user defined render targets added to the scene
  90312. */
  90313. customRenderTargets: RenderTargetTexture[];
  90314. /**
  90315. * Defines if texture loading must be delayed
  90316. * If true, textures will only be loaded when they need to be rendered
  90317. */
  90318. useDelayedTextureLoading: boolean;
  90319. /**
  90320. * Gets the list of meshes imported to the scene through SceneLoader
  90321. */
  90322. importedMeshesFiles: String[];
  90323. /**
  90324. * Gets or sets a boolean indicating if probes are enabled on this scene
  90325. */
  90326. probesEnabled: boolean;
  90327. /**
  90328. * Gets or sets the current offline provider to use to store scene data
  90329. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  90330. */
  90331. offlineProvider: IOfflineProvider;
  90332. /**
  90333. * Gets or sets the action manager associated with the scene
  90334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90335. */
  90336. actionManager: AbstractActionManager;
  90337. private _meshesForIntersections;
  90338. /**
  90339. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  90340. */
  90341. proceduralTexturesEnabled: boolean;
  90342. private _engine;
  90343. private _totalVertices;
  90344. /** @hidden */
  90345. _activeIndices: PerfCounter;
  90346. /** @hidden */
  90347. _activeParticles: PerfCounter;
  90348. /** @hidden */
  90349. _activeBones: PerfCounter;
  90350. private _animationRatio;
  90351. /** @hidden */
  90352. _animationTimeLast: number;
  90353. /** @hidden */
  90354. _animationTime: number;
  90355. /**
  90356. * Gets or sets a general scale for animation speed
  90357. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  90358. */
  90359. animationTimeScale: number;
  90360. /** @hidden */
  90361. _cachedMaterial: Nullable<Material>;
  90362. /** @hidden */
  90363. _cachedEffect: Nullable<Effect>;
  90364. /** @hidden */
  90365. _cachedVisibility: Nullable<number>;
  90366. private _renderId;
  90367. private _frameId;
  90368. private _executeWhenReadyTimeoutId;
  90369. private _intermediateRendering;
  90370. private _viewUpdateFlag;
  90371. private _projectionUpdateFlag;
  90372. private _alternateViewUpdateFlag;
  90373. private _alternateProjectionUpdateFlag;
  90374. /** @hidden */
  90375. _toBeDisposed: Nullable<IDisposable>[];
  90376. private _activeRequests;
  90377. /** @hidden */
  90378. _pendingData: any[];
  90379. private _isDisposed;
  90380. /**
  90381. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  90382. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  90383. */
  90384. dispatchAllSubMeshesOfActiveMeshes: boolean;
  90385. private _activeMeshes;
  90386. private _processedMaterials;
  90387. private _renderTargets;
  90388. /** @hidden */
  90389. _activeParticleSystems: SmartArray<IParticleSystem>;
  90390. private _activeSkeletons;
  90391. private _softwareSkinnedMeshes;
  90392. private _renderingManager;
  90393. /** @hidden */
  90394. _activeAnimatables: Animatable[];
  90395. private _transformMatrix;
  90396. private _sceneUbo;
  90397. private _alternateSceneUbo;
  90398. private _viewMatrix;
  90399. private _projectionMatrix;
  90400. private _alternateViewMatrix;
  90401. private _alternateProjectionMatrix;
  90402. private _alternateTransformMatrix;
  90403. private _useAlternateCameraConfiguration;
  90404. private _alternateRendering;
  90405. private _wheelEventName;
  90406. /** @hidden */
  90407. _forcedViewPosition: Nullable<Vector3>;
  90408. /** @hidden */
  90409. readonly _isAlternateRenderingEnabled: boolean;
  90410. private _frustumPlanes;
  90411. /**
  90412. * Gets the list of frustum planes (built from the active camera)
  90413. */
  90414. readonly frustumPlanes: Plane[];
  90415. /**
  90416. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  90417. * This is useful if there are more lights that the maximum simulteanous authorized
  90418. */
  90419. requireLightSorting: boolean;
  90420. /** @hidden */
  90421. readonly useMaterialMeshMap: boolean;
  90422. /** @hidden */
  90423. readonly useClonedMeshhMap: boolean;
  90424. private _pointerOverMesh;
  90425. private _pickedDownMesh;
  90426. private _pickedUpMesh;
  90427. private _externalData;
  90428. private _uid;
  90429. /**
  90430. * @hidden
  90431. * Backing store of defined scene components.
  90432. */
  90433. _components: ISceneComponent[];
  90434. /**
  90435. * @hidden
  90436. * Backing store of defined scene components.
  90437. */
  90438. _serializableComponents: ISceneSerializableComponent[];
  90439. /**
  90440. * List of components to register on the next registration step.
  90441. */
  90442. private _transientComponents;
  90443. /**
  90444. * Registers the transient components if needed.
  90445. */
  90446. private _registerTransientComponents;
  90447. /**
  90448. * @hidden
  90449. * Add a component to the scene.
  90450. * Note that the ccomponent could be registered on th next frame if this is called after
  90451. * the register component stage.
  90452. * @param component Defines the component to add to the scene
  90453. */
  90454. _addComponent(component: ISceneComponent): void;
  90455. /**
  90456. * @hidden
  90457. * Gets a component from the scene.
  90458. * @param name defines the name of the component to retrieve
  90459. * @returns the component or null if not present
  90460. */
  90461. _getComponent(name: string): Nullable<ISceneComponent>;
  90462. /**
  90463. * @hidden
  90464. * Defines the actions happening before camera updates.
  90465. */
  90466. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  90467. /**
  90468. * @hidden
  90469. * Defines the actions happening before clear the canvas.
  90470. */
  90471. _beforeClearStage: Stage<SimpleStageAction>;
  90472. /**
  90473. * @hidden
  90474. * Defines the actions when collecting render targets for the frame.
  90475. */
  90476. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  90477. /**
  90478. * @hidden
  90479. * Defines the actions happening for one camera in the frame.
  90480. */
  90481. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  90482. /**
  90483. * @hidden
  90484. * Defines the actions happening during the per mesh ready checks.
  90485. */
  90486. _isReadyForMeshStage: Stage<MeshStageAction>;
  90487. /**
  90488. * @hidden
  90489. * Defines the actions happening before evaluate active mesh checks.
  90490. */
  90491. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  90492. /**
  90493. * @hidden
  90494. * Defines the actions happening during the evaluate sub mesh checks.
  90495. */
  90496. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  90497. /**
  90498. * @hidden
  90499. * Defines the actions happening during the active mesh stage.
  90500. */
  90501. _activeMeshStage: Stage<ActiveMeshStageAction>;
  90502. /**
  90503. * @hidden
  90504. * Defines the actions happening during the per camera render target step.
  90505. */
  90506. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  90507. /**
  90508. * @hidden
  90509. * Defines the actions happening just before the active camera is drawing.
  90510. */
  90511. _beforeCameraDrawStage: Stage<CameraStageAction>;
  90512. /**
  90513. * @hidden
  90514. * Defines the actions happening just before a render target is drawing.
  90515. */
  90516. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  90517. /**
  90518. * @hidden
  90519. * Defines the actions happening just before a rendering group is drawing.
  90520. */
  90521. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  90522. /**
  90523. * @hidden
  90524. * Defines the actions happening just before a mesh is drawing.
  90525. */
  90526. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  90527. /**
  90528. * @hidden
  90529. * Defines the actions happening just after a mesh has been drawn.
  90530. */
  90531. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  90532. /**
  90533. * @hidden
  90534. * Defines the actions happening just after a rendering group has been drawn.
  90535. */
  90536. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  90537. /**
  90538. * @hidden
  90539. * Defines the actions happening just after the active camera has been drawn.
  90540. */
  90541. _afterCameraDrawStage: Stage<CameraStageAction>;
  90542. /**
  90543. * @hidden
  90544. * Defines the actions happening just after a render target has been drawn.
  90545. */
  90546. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  90547. /**
  90548. * @hidden
  90549. * Defines the actions happening just after rendering all cameras and computing intersections.
  90550. */
  90551. _afterRenderStage: Stage<SimpleStageAction>;
  90552. /**
  90553. * @hidden
  90554. * Defines the actions happening when a pointer move event happens.
  90555. */
  90556. _pointerMoveStage: Stage<PointerMoveStageAction>;
  90557. /**
  90558. * @hidden
  90559. * Defines the actions happening when a pointer down event happens.
  90560. */
  90561. _pointerDownStage: Stage<PointerUpDownStageAction>;
  90562. /**
  90563. * @hidden
  90564. * Defines the actions happening when a pointer up event happens.
  90565. */
  90566. _pointerUpStage: Stage<PointerUpDownStageAction>;
  90567. /**
  90568. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  90569. */
  90570. private geometriesByUniqueId;
  90571. /**
  90572. * Creates a new Scene
  90573. * @param engine defines the engine to use to render this scene
  90574. * @param options defines the scene options
  90575. */
  90576. constructor(engine: Engine, options?: SceneOptions);
  90577. private _defaultMeshCandidates;
  90578. /**
  90579. * @hidden
  90580. */
  90581. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  90582. private _defaultSubMeshCandidates;
  90583. /**
  90584. * @hidden
  90585. */
  90586. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  90587. /**
  90588. * Sets the default candidate providers for the scene.
  90589. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  90590. * and getCollidingSubMeshCandidates to their default function
  90591. */
  90592. setDefaultCandidateProviders(): void;
  90593. /**
  90594. * Gets the mesh that is currently under the pointer
  90595. */
  90596. readonly meshUnderPointer: Nullable<AbstractMesh>;
  90597. /**
  90598. * Gets or sets the current on-screen X position of the pointer
  90599. */
  90600. pointerX: number;
  90601. /**
  90602. * Gets or sets the current on-screen Y position of the pointer
  90603. */
  90604. pointerY: number;
  90605. /**
  90606. * Gets the cached material (ie. the latest rendered one)
  90607. * @returns the cached material
  90608. */
  90609. getCachedMaterial(): Nullable<Material>;
  90610. /**
  90611. * Gets the cached effect (ie. the latest rendered one)
  90612. * @returns the cached effect
  90613. */
  90614. getCachedEffect(): Nullable<Effect>;
  90615. /**
  90616. * Gets the cached visibility state (ie. the latest rendered one)
  90617. * @returns the cached visibility state
  90618. */
  90619. getCachedVisibility(): Nullable<number>;
  90620. /**
  90621. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  90622. * @param material defines the current material
  90623. * @param effect defines the current effect
  90624. * @param visibility defines the current visibility state
  90625. * @returns true if one parameter is not cached
  90626. */
  90627. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  90628. /**
  90629. * Gets the engine associated with the scene
  90630. * @returns an Engine
  90631. */
  90632. getEngine(): Engine;
  90633. /**
  90634. * Gets the total number of vertices rendered per frame
  90635. * @returns the total number of vertices rendered per frame
  90636. */
  90637. getTotalVertices(): number;
  90638. /**
  90639. * Gets the performance counter for total vertices
  90640. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  90641. */
  90642. readonly totalVerticesPerfCounter: PerfCounter;
  90643. /**
  90644. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  90645. * @returns the total number of active indices rendered per frame
  90646. */
  90647. getActiveIndices(): number;
  90648. /**
  90649. * Gets the performance counter for active indices
  90650. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  90651. */
  90652. readonly totalActiveIndicesPerfCounter: PerfCounter;
  90653. /**
  90654. * Gets the total number of active particles rendered per frame
  90655. * @returns the total number of active particles rendered per frame
  90656. */
  90657. getActiveParticles(): number;
  90658. /**
  90659. * Gets the performance counter for active particles
  90660. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  90661. */
  90662. readonly activeParticlesPerfCounter: PerfCounter;
  90663. /**
  90664. * Gets the total number of active bones rendered per frame
  90665. * @returns the total number of active bones rendered per frame
  90666. */
  90667. getActiveBones(): number;
  90668. /**
  90669. * Gets the performance counter for active bones
  90670. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  90671. */
  90672. readonly activeBonesPerfCounter: PerfCounter;
  90673. /**
  90674. * Gets the array of active meshes
  90675. * @returns an array of AbstractMesh
  90676. */
  90677. getActiveMeshes(): SmartArray<AbstractMesh>;
  90678. /**
  90679. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  90680. * @returns a number
  90681. */
  90682. getAnimationRatio(): number;
  90683. /**
  90684. * Gets an unique Id for the current render phase
  90685. * @returns a number
  90686. */
  90687. getRenderId(): number;
  90688. /**
  90689. * Gets an unique Id for the current frame
  90690. * @returns a number
  90691. */
  90692. getFrameId(): number;
  90693. /** Call this function if you want to manually increment the render Id*/
  90694. incrementRenderId(): void;
  90695. private _updatePointerPosition;
  90696. private _createUbo;
  90697. private _createAlternateUbo;
  90698. private _setRayOnPointerInfo;
  90699. /**
  90700. * Use this method to simulate a pointer move on a mesh
  90701. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  90702. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  90703. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  90704. * @returns the current scene
  90705. */
  90706. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  90707. private _processPointerMove;
  90708. private _checkPrePointerObservable;
  90709. /**
  90710. * Use this method to simulate a pointer down on a mesh
  90711. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  90712. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  90713. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  90714. * @returns the current scene
  90715. */
  90716. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  90717. private _processPointerDown;
  90718. /**
  90719. * Use this method to simulate a pointer up on a mesh
  90720. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  90721. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  90722. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  90723. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  90724. * @returns the current scene
  90725. */
  90726. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  90727. private _processPointerUp;
  90728. /**
  90729. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  90730. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  90731. * @returns true if the pointer was captured
  90732. */
  90733. isPointerCaptured(pointerId?: number): boolean;
  90734. /** @hidden */
  90735. _isPointerSwiping(): boolean;
  90736. /**
  90737. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  90738. * @param attachUp defines if you want to attach events to pointerup
  90739. * @param attachDown defines if you want to attach events to pointerdown
  90740. * @param attachMove defines if you want to attach events to pointermove
  90741. */
  90742. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  90743. /** Detaches all event handlers*/
  90744. detachControl(): void;
  90745. /**
  90746. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  90747. * Delay loaded resources are not taking in account
  90748. * @return true if all required resources are ready
  90749. */
  90750. isReady(): boolean;
  90751. /** Resets all cached information relative to material (including effect and visibility) */
  90752. resetCachedMaterial(): void;
  90753. /**
  90754. * Registers a function to be called before every frame render
  90755. * @param func defines the function to register
  90756. */
  90757. registerBeforeRender(func: () => void): void;
  90758. /**
  90759. * Unregisters a function called before every frame render
  90760. * @param func defines the function to unregister
  90761. */
  90762. unregisterBeforeRender(func: () => void): void;
  90763. /**
  90764. * Registers a function to be called after every frame render
  90765. * @param func defines the function to register
  90766. */
  90767. registerAfterRender(func: () => void): void;
  90768. /**
  90769. * Unregisters a function called after every frame render
  90770. * @param func defines the function to unregister
  90771. */
  90772. unregisterAfterRender(func: () => void): void;
  90773. private _executeOnceBeforeRender;
  90774. /**
  90775. * The provided function will run before render once and will be disposed afterwards.
  90776. * A timeout delay can be provided so that the function will be executed in N ms.
  90777. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  90778. * @param func The function to be executed.
  90779. * @param timeout optional delay in ms
  90780. */
  90781. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  90782. /** @hidden */
  90783. _addPendingData(data: any): void;
  90784. /** @hidden */
  90785. _removePendingData(data: any): void;
  90786. /**
  90787. * Returns the number of items waiting to be loaded
  90788. * @returns the number of items waiting to be loaded
  90789. */
  90790. getWaitingItemsCount(): number;
  90791. /**
  90792. * Returns a boolean indicating if the scene is still loading data
  90793. */
  90794. readonly isLoading: boolean;
  90795. /**
  90796. * Registers a function to be executed when the scene is ready
  90797. * @param {Function} func - the function to be executed
  90798. */
  90799. executeWhenReady(func: () => void): void;
  90800. /**
  90801. * Returns a promise that resolves when the scene is ready
  90802. * @returns A promise that resolves when the scene is ready
  90803. */
  90804. whenReadyAsync(): Promise<void>;
  90805. /** @hidden */
  90806. _checkIsReady(): void;
  90807. /**
  90808. * Gets all animatable attached to the scene
  90809. */
  90810. readonly animatables: Animatable[];
  90811. /**
  90812. * Resets the last animation time frame.
  90813. * Useful to override when animations start running when loading a scene for the first time.
  90814. */
  90815. resetLastAnimationTimeFrame(): void;
  90816. /** @hidden */
  90817. _switchToAlternateCameraConfiguration(active: boolean): void;
  90818. /**
  90819. * Gets the current view matrix
  90820. * @returns a Matrix
  90821. */
  90822. getViewMatrix(): Matrix;
  90823. /**
  90824. * Gets the current projection matrix
  90825. * @returns a Matrix
  90826. */
  90827. getProjectionMatrix(): Matrix;
  90828. /**
  90829. * Gets the current transform matrix
  90830. * @returns a Matrix made of View * Projection
  90831. */
  90832. getTransformMatrix(): Matrix;
  90833. /**
  90834. * Sets the current transform matrix
  90835. * @param view defines the View matrix to use
  90836. * @param projection defines the Projection matrix to use
  90837. */
  90838. setTransformMatrix(view: Matrix, projection: Matrix): void;
  90839. /** @hidden */
  90840. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  90841. /**
  90842. * Gets the uniform buffer used to store scene data
  90843. * @returns a UniformBuffer
  90844. */
  90845. getSceneUniformBuffer(): UniformBuffer;
  90846. /**
  90847. * Gets an unique (relatively to the current scene) Id
  90848. * @returns an unique number for the scene
  90849. */
  90850. getUniqueId(): number;
  90851. /**
  90852. * Add a mesh to the list of scene's meshes
  90853. * @param newMesh defines the mesh to add
  90854. * @param recursive if all child meshes should also be added to the scene
  90855. */
  90856. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  90857. /**
  90858. * Remove a mesh for the list of scene's meshes
  90859. * @param toRemove defines the mesh to remove
  90860. * @param recursive if all child meshes should also be removed from the scene
  90861. * @returns the index where the mesh was in the mesh list
  90862. */
  90863. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  90864. /**
  90865. * Add a transform node to the list of scene's transform nodes
  90866. * @param newTransformNode defines the transform node to add
  90867. */
  90868. addTransformNode(newTransformNode: TransformNode): void;
  90869. /**
  90870. * Remove a transform node for the list of scene's transform nodes
  90871. * @param toRemove defines the transform node to remove
  90872. * @returns the index where the transform node was in the transform node list
  90873. */
  90874. removeTransformNode(toRemove: TransformNode): number;
  90875. /**
  90876. * Remove a skeleton for the list of scene's skeletons
  90877. * @param toRemove defines the skeleton to remove
  90878. * @returns the index where the skeleton was in the skeleton list
  90879. */
  90880. removeSkeleton(toRemove: Skeleton): number;
  90881. /**
  90882. * Remove a morph target for the list of scene's morph targets
  90883. * @param toRemove defines the morph target to remove
  90884. * @returns the index where the morph target was in the morph target list
  90885. */
  90886. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  90887. /**
  90888. * Remove a light for the list of scene's lights
  90889. * @param toRemove defines the light to remove
  90890. * @returns the index where the light was in the light list
  90891. */
  90892. removeLight(toRemove: Light): number;
  90893. /**
  90894. * Remove a camera for the list of scene's cameras
  90895. * @param toRemove defines the camera to remove
  90896. * @returns the index where the camera was in the camera list
  90897. */
  90898. removeCamera(toRemove: Camera): number;
  90899. /**
  90900. * Remove a particle system for the list of scene's particle systems
  90901. * @param toRemove defines the particle system to remove
  90902. * @returns the index where the particle system was in the particle system list
  90903. */
  90904. removeParticleSystem(toRemove: IParticleSystem): number;
  90905. /**
  90906. * Remove a animation for the list of scene's animations
  90907. * @param toRemove defines the animation to remove
  90908. * @returns the index where the animation was in the animation list
  90909. */
  90910. removeAnimation(toRemove: Animation): number;
  90911. /**
  90912. * Removes the given animation group from this scene.
  90913. * @param toRemove The animation group to remove
  90914. * @returns The index of the removed animation group
  90915. */
  90916. removeAnimationGroup(toRemove: AnimationGroup): number;
  90917. /**
  90918. * Removes the given multi-material from this scene.
  90919. * @param toRemove The multi-material to remove
  90920. * @returns The index of the removed multi-material
  90921. */
  90922. removeMultiMaterial(toRemove: MultiMaterial): number;
  90923. /**
  90924. * Removes the given material from this scene.
  90925. * @param toRemove The material to remove
  90926. * @returns The index of the removed material
  90927. */
  90928. removeMaterial(toRemove: Material): number;
  90929. /**
  90930. * Removes the given action manager from this scene.
  90931. * @param toRemove The action manager to remove
  90932. * @returns The index of the removed action manager
  90933. */
  90934. removeActionManager(toRemove: AbstractActionManager): number;
  90935. /**
  90936. * Removes the given texture from this scene.
  90937. * @param toRemove The texture to remove
  90938. * @returns The index of the removed texture
  90939. */
  90940. removeTexture(toRemove: BaseTexture): number;
  90941. /**
  90942. * Adds the given light to this scene
  90943. * @param newLight The light to add
  90944. */
  90945. addLight(newLight: Light): void;
  90946. /**
  90947. * Sorts the list list based on light priorities
  90948. */
  90949. sortLightsByPriority(): void;
  90950. /**
  90951. * Adds the given camera to this scene
  90952. * @param newCamera The camera to add
  90953. */
  90954. addCamera(newCamera: Camera): void;
  90955. /**
  90956. * Adds the given skeleton to this scene
  90957. * @param newSkeleton The skeleton to add
  90958. */
  90959. addSkeleton(newSkeleton: Skeleton): void;
  90960. /**
  90961. * Adds the given particle system to this scene
  90962. * @param newParticleSystem The particle system to add
  90963. */
  90964. addParticleSystem(newParticleSystem: IParticleSystem): void;
  90965. /**
  90966. * Adds the given animation to this scene
  90967. * @param newAnimation The animation to add
  90968. */
  90969. addAnimation(newAnimation: Animation): void;
  90970. /**
  90971. * Adds the given animation group to this scene.
  90972. * @param newAnimationGroup The animation group to add
  90973. */
  90974. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  90975. /**
  90976. * Adds the given multi-material to this scene
  90977. * @param newMultiMaterial The multi-material to add
  90978. */
  90979. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  90980. /**
  90981. * Adds the given material to this scene
  90982. * @param newMaterial The material to add
  90983. */
  90984. addMaterial(newMaterial: Material): void;
  90985. /**
  90986. * Adds the given morph target to this scene
  90987. * @param newMorphTargetManager The morph target to add
  90988. */
  90989. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  90990. /**
  90991. * Adds the given geometry to this scene
  90992. * @param newGeometry The geometry to add
  90993. */
  90994. addGeometry(newGeometry: Geometry): void;
  90995. /**
  90996. * Adds the given action manager to this scene
  90997. * @param newActionManager The action manager to add
  90998. */
  90999. addActionManager(newActionManager: AbstractActionManager): void;
  91000. /**
  91001. * Adds the given texture to this scene.
  91002. * @param newTexture The texture to add
  91003. */
  91004. addTexture(newTexture: BaseTexture): void;
  91005. /**
  91006. * Switch active camera
  91007. * @param newCamera defines the new active camera
  91008. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  91009. */
  91010. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  91011. /**
  91012. * sets the active camera of the scene using its ID
  91013. * @param id defines the camera's ID
  91014. * @return the new active camera or null if none found.
  91015. */
  91016. setActiveCameraByID(id: string): Nullable<Camera>;
  91017. /**
  91018. * sets the active camera of the scene using its name
  91019. * @param name defines the camera's name
  91020. * @returns the new active camera or null if none found.
  91021. */
  91022. setActiveCameraByName(name: string): Nullable<Camera>;
  91023. /**
  91024. * get an animation group using its name
  91025. * @param name defines the material's name
  91026. * @return the animation group or null if none found.
  91027. */
  91028. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  91029. /**
  91030. * get a material using its id
  91031. * @param id defines the material's ID
  91032. * @return the material or null if none found.
  91033. */
  91034. getMaterialByID(id: string): Nullable<Material>;
  91035. /**
  91036. * Gets a material using its name
  91037. * @param name defines the material's name
  91038. * @return the material or null if none found.
  91039. */
  91040. getMaterialByName(name: string): Nullable<Material>;
  91041. /**
  91042. * Gets a camera using its id
  91043. * @param id defines the id to look for
  91044. * @returns the camera or null if not found
  91045. */
  91046. getCameraByID(id: string): Nullable<Camera>;
  91047. /**
  91048. * Gets a camera using its unique id
  91049. * @param uniqueId defines the unique id to look for
  91050. * @returns the camera or null if not found
  91051. */
  91052. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  91053. /**
  91054. * Gets a camera using its name
  91055. * @param name defines the camera's name
  91056. * @return the camera or null if none found.
  91057. */
  91058. getCameraByName(name: string): Nullable<Camera>;
  91059. /**
  91060. * Gets a bone using its id
  91061. * @param id defines the bone's id
  91062. * @return the bone or null if not found
  91063. */
  91064. getBoneByID(id: string): Nullable<Bone>;
  91065. /**
  91066. * Gets a bone using its id
  91067. * @param name defines the bone's name
  91068. * @return the bone or null if not found
  91069. */
  91070. getBoneByName(name: string): Nullable<Bone>;
  91071. /**
  91072. * Gets a light node using its name
  91073. * @param name defines the the light's name
  91074. * @return the light or null if none found.
  91075. */
  91076. getLightByName(name: string): Nullable<Light>;
  91077. /**
  91078. * Gets a light node using its id
  91079. * @param id defines the light's id
  91080. * @return the light or null if none found.
  91081. */
  91082. getLightByID(id: string): Nullable<Light>;
  91083. /**
  91084. * Gets a light node using its scene-generated unique ID
  91085. * @param uniqueId defines the light's unique id
  91086. * @return the light or null if none found.
  91087. */
  91088. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  91089. /**
  91090. * Gets a particle system by id
  91091. * @param id defines the particle system id
  91092. * @return the corresponding system or null if none found
  91093. */
  91094. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  91095. /**
  91096. * Gets a geometry using its ID
  91097. * @param id defines the geometry's id
  91098. * @return the geometry or null if none found.
  91099. */
  91100. getGeometryByID(id: string): Nullable<Geometry>;
  91101. private _getGeometryByUniqueID;
  91102. /**
  91103. * Add a new geometry to this scene
  91104. * @param geometry defines the geometry to be added to the scene.
  91105. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  91106. * @return a boolean defining if the geometry was added or not
  91107. */
  91108. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  91109. /**
  91110. * Removes an existing geometry
  91111. * @param geometry defines the geometry to be removed from the scene
  91112. * @return a boolean defining if the geometry was removed or not
  91113. */
  91114. removeGeometry(geometry: Geometry): boolean;
  91115. /**
  91116. * Gets the list of geometries attached to the scene
  91117. * @returns an array of Geometry
  91118. */
  91119. getGeometries(): Geometry[];
  91120. /**
  91121. * Gets the first added mesh found of a given ID
  91122. * @param id defines the id to search for
  91123. * @return the mesh found or null if not found at all
  91124. */
  91125. getMeshByID(id: string): Nullable<AbstractMesh>;
  91126. /**
  91127. * Gets a list of meshes using their id
  91128. * @param id defines the id to search for
  91129. * @returns a list of meshes
  91130. */
  91131. getMeshesByID(id: string): Array<AbstractMesh>;
  91132. /**
  91133. * Gets the first added transform node found of a given ID
  91134. * @param id defines the id to search for
  91135. * @return the found transform node or null if not found at all.
  91136. */
  91137. getTransformNodeByID(id: string): Nullable<TransformNode>;
  91138. /**
  91139. * Gets a list of transform nodes using their id
  91140. * @param id defines the id to search for
  91141. * @returns a list of transform nodes
  91142. */
  91143. getTransformNodesByID(id: string): Array<TransformNode>;
  91144. /**
  91145. * Gets a mesh with its auto-generated unique id
  91146. * @param uniqueId defines the unique id to search for
  91147. * @return the found mesh or null if not found at all.
  91148. */
  91149. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  91150. /**
  91151. * Gets a the last added mesh using a given id
  91152. * @param id defines the id to search for
  91153. * @return the found mesh or null if not found at all.
  91154. */
  91155. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  91156. /**
  91157. * Gets a the last added node (Mesh, Camera, Light) using a given id
  91158. * @param id defines the id to search for
  91159. * @return the found node or null if not found at all
  91160. */
  91161. getLastEntryByID(id: string): Nullable<Node>;
  91162. /**
  91163. * Gets a node (Mesh, Camera, Light) using a given id
  91164. * @param id defines the id to search for
  91165. * @return the found node or null if not found at all
  91166. */
  91167. getNodeByID(id: string): Nullable<Node>;
  91168. /**
  91169. * Gets a node (Mesh, Camera, Light) using a given name
  91170. * @param name defines the name to search for
  91171. * @return the found node or null if not found at all.
  91172. */
  91173. getNodeByName(name: string): Nullable<Node>;
  91174. /**
  91175. * Gets a mesh using a given name
  91176. * @param name defines the name to search for
  91177. * @return the found mesh or null if not found at all.
  91178. */
  91179. getMeshByName(name: string): Nullable<AbstractMesh>;
  91180. /**
  91181. * Gets a transform node using a given name
  91182. * @param name defines the name to search for
  91183. * @return the found transform node or null if not found at all.
  91184. */
  91185. getTransformNodeByName(name: string): Nullable<TransformNode>;
  91186. /**
  91187. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  91188. * @param id defines the id to search for
  91189. * @return the found skeleton or null if not found at all.
  91190. */
  91191. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  91192. /**
  91193. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  91194. * @param id defines the id to search for
  91195. * @return the found skeleton or null if not found at all.
  91196. */
  91197. getSkeletonById(id: string): Nullable<Skeleton>;
  91198. /**
  91199. * Gets a skeleton using a given name
  91200. * @param name defines the name to search for
  91201. * @return the found skeleton or null if not found at all.
  91202. */
  91203. getSkeletonByName(name: string): Nullable<Skeleton>;
  91204. /**
  91205. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  91206. * @param id defines the id to search for
  91207. * @return the found morph target manager or null if not found at all.
  91208. */
  91209. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  91210. /**
  91211. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  91212. * @param id defines the id to search for
  91213. * @return the found morph target or null if not found at all.
  91214. */
  91215. getMorphTargetById(id: string): Nullable<MorphTarget>;
  91216. /**
  91217. * Gets a boolean indicating if the given mesh is active
  91218. * @param mesh defines the mesh to look for
  91219. * @returns true if the mesh is in the active list
  91220. */
  91221. isActiveMesh(mesh: AbstractMesh): boolean;
  91222. /**
  91223. * Return a unique id as a string which can serve as an identifier for the scene
  91224. */
  91225. readonly uid: string;
  91226. /**
  91227. * Add an externaly attached data from its key.
  91228. * This method call will fail and return false, if such key already exists.
  91229. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  91230. * @param key the unique key that identifies the data
  91231. * @param data the data object to associate to the key for this Engine instance
  91232. * @return true if no such key were already present and the data was added successfully, false otherwise
  91233. */
  91234. addExternalData<T>(key: string, data: T): boolean;
  91235. /**
  91236. * Get an externaly attached data from its key
  91237. * @param key the unique key that identifies the data
  91238. * @return the associated data, if present (can be null), or undefined if not present
  91239. */
  91240. getExternalData<T>(key: string): Nullable<T>;
  91241. /**
  91242. * Get an externaly attached data from its key, create it using a factory if it's not already present
  91243. * @param key the unique key that identifies the data
  91244. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  91245. * @return the associated data, can be null if the factory returned null.
  91246. */
  91247. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  91248. /**
  91249. * Remove an externaly attached data from the Engine instance
  91250. * @param key the unique key that identifies the data
  91251. * @return true if the data was successfully removed, false if it doesn't exist
  91252. */
  91253. removeExternalData(key: string): boolean;
  91254. private _evaluateSubMesh;
  91255. /**
  91256. * Clear the processed materials smart array preventing retention point in material dispose.
  91257. */
  91258. freeProcessedMaterials(): void;
  91259. private _preventFreeActiveMeshesAndRenderingGroups;
  91260. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  91261. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  91262. * when disposing several meshes in a row or a hierarchy of meshes.
  91263. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  91264. */
  91265. blockfreeActiveMeshesAndRenderingGroups: boolean;
  91266. /**
  91267. * Clear the active meshes smart array preventing retention point in mesh dispose.
  91268. */
  91269. freeActiveMeshes(): void;
  91270. /**
  91271. * Clear the info related to rendering groups preventing retention points during dispose.
  91272. */
  91273. freeRenderingGroups(): void;
  91274. /** @hidden */
  91275. _isInIntermediateRendering(): boolean;
  91276. /**
  91277. * Lambda returning the list of potentially active meshes.
  91278. */
  91279. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  91280. /**
  91281. * Lambda returning the list of potentially active sub meshes.
  91282. */
  91283. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  91284. /**
  91285. * Lambda returning the list of potentially intersecting sub meshes.
  91286. */
  91287. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  91288. /**
  91289. * Lambda returning the list of potentially colliding sub meshes.
  91290. */
  91291. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  91292. private _activeMeshesFrozen;
  91293. /**
  91294. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  91295. * @returns the current scene
  91296. */
  91297. freezeActiveMeshes(): Scene;
  91298. /**
  91299. * Use this function to restart evaluating active meshes on every frame
  91300. * @returns the current scene
  91301. */
  91302. unfreezeActiveMeshes(): Scene;
  91303. private _evaluateActiveMeshes;
  91304. private _activeMesh;
  91305. /**
  91306. * Update the transform matrix to update from the current active camera
  91307. * @param force defines a boolean used to force the update even if cache is up to date
  91308. */
  91309. updateTransformMatrix(force?: boolean): void;
  91310. /**
  91311. * 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)
  91312. * @param alternateCamera defines the camera to use
  91313. */
  91314. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  91315. /** @hidden */
  91316. _allowPostProcessClearColor: boolean;
  91317. private _renderForCamera;
  91318. private _processSubCameras;
  91319. private _checkIntersections;
  91320. /** @hidden */
  91321. _advancePhysicsEngineStep(step: number): void;
  91322. /**
  91323. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  91324. */
  91325. getDeterministicFrameTime: () => number;
  91326. /** @hidden */
  91327. _animate(): void;
  91328. /**
  91329. * Render the scene
  91330. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  91331. */
  91332. render(updateCameras?: boolean): void;
  91333. /**
  91334. * Freeze all materials
  91335. * A frozen material will not be updatable but should be faster to render
  91336. */
  91337. freezeMaterials(): void;
  91338. /**
  91339. * Unfreeze all materials
  91340. * A frozen material will not be updatable but should be faster to render
  91341. */
  91342. unfreezeMaterials(): void;
  91343. /**
  91344. * Releases all held ressources
  91345. */
  91346. dispose(): void;
  91347. /**
  91348. * Gets if the scene is already disposed
  91349. */
  91350. readonly isDisposed: boolean;
  91351. /**
  91352. * Call this function to reduce memory footprint of the scene.
  91353. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  91354. */
  91355. clearCachedVertexData(): void;
  91356. /**
  91357. * This function will remove the local cached buffer data from texture.
  91358. * It will save memory but will prevent the texture from being rebuilt
  91359. */
  91360. cleanCachedTextureBuffer(): void;
  91361. /**
  91362. * Get the world extend vectors with an optional filter
  91363. *
  91364. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  91365. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  91366. */
  91367. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  91368. min: Vector3;
  91369. max: Vector3;
  91370. };
  91371. /**
  91372. * Creates a ray that can be used to pick in the scene
  91373. * @param x defines the x coordinate of the origin (on-screen)
  91374. * @param y defines the y coordinate of the origin (on-screen)
  91375. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  91376. * @param camera defines the camera to use for the picking
  91377. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  91378. * @returns a Ray
  91379. */
  91380. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  91381. /**
  91382. * Creates a ray that can be used to pick in the scene
  91383. * @param x defines the x coordinate of the origin (on-screen)
  91384. * @param y defines the y coordinate of the origin (on-screen)
  91385. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  91386. * @param result defines the ray where to store the picking ray
  91387. * @param camera defines the camera to use for the picking
  91388. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  91389. * @returns the current scene
  91390. */
  91391. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  91392. /**
  91393. * Creates a ray that can be used to pick in the scene
  91394. * @param x defines the x coordinate of the origin (on-screen)
  91395. * @param y defines the y coordinate of the origin (on-screen)
  91396. * @param camera defines the camera to use for the picking
  91397. * @returns a Ray
  91398. */
  91399. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  91400. /**
  91401. * Creates a ray that can be used to pick in the scene
  91402. * @param x defines the x coordinate of the origin (on-screen)
  91403. * @param y defines the y coordinate of the origin (on-screen)
  91404. * @param result defines the ray where to store the picking ray
  91405. * @param camera defines the camera to use for the picking
  91406. * @returns the current scene
  91407. */
  91408. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  91409. /** Launch a ray to try to pick a mesh in the scene
  91410. * @param x position on screen
  91411. * @param y position on screen
  91412. * @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
  91413. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  91414. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91415. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91416. * @returns a PickingInfo
  91417. */
  91418. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  91419. /** Use the given ray to pick a mesh in the scene
  91420. * @param ray The ray to use to pick meshes
  91421. * @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
  91422. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  91423. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91424. * @returns a PickingInfo
  91425. */
  91426. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91427. /**
  91428. * Launch a ray to try to pick a mesh in the scene
  91429. * @param x X position on screen
  91430. * @param y Y position on screen
  91431. * @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
  91432. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91433. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91434. * @returns an array of PickingInfo
  91435. */
  91436. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91437. /**
  91438. * Launch a ray to try to pick a mesh in the scene
  91439. * @param ray Ray to use
  91440. * @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
  91441. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  91442. * @returns an array of PickingInfo
  91443. */
  91444. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91445. /**
  91446. * Force the value of meshUnderPointer
  91447. * @param mesh defines the mesh to use
  91448. */
  91449. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  91450. /**
  91451. * Gets the mesh under the pointer
  91452. * @returns a Mesh or null if no mesh is under the pointer
  91453. */
  91454. getPointerOverMesh(): Nullable<AbstractMesh>;
  91455. /** @hidden */
  91456. _rebuildGeometries(): void;
  91457. /** @hidden */
  91458. _rebuildTextures(): void;
  91459. private _getByTags;
  91460. /**
  91461. * Get a list of meshes by tags
  91462. * @param tagsQuery defines the tags query to use
  91463. * @param forEach defines a predicate used to filter results
  91464. * @returns an array of Mesh
  91465. */
  91466. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  91467. /**
  91468. * Get a list of cameras by tags
  91469. * @param tagsQuery defines the tags query to use
  91470. * @param forEach defines a predicate used to filter results
  91471. * @returns an array of Camera
  91472. */
  91473. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  91474. /**
  91475. * Get a list of lights by tags
  91476. * @param tagsQuery defines the tags query to use
  91477. * @param forEach defines a predicate used to filter results
  91478. * @returns an array of Light
  91479. */
  91480. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  91481. /**
  91482. * Get a list of materials by tags
  91483. * @param tagsQuery defines the tags query to use
  91484. * @param forEach defines a predicate used to filter results
  91485. * @returns an array of Material
  91486. */
  91487. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  91488. /**
  91489. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  91490. * This allowed control for front to back rendering or reversly depending of the special needs.
  91491. *
  91492. * @param renderingGroupId The rendering group id corresponding to its index
  91493. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  91494. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  91495. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  91496. */
  91497. 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;
  91498. /**
  91499. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  91500. *
  91501. * @param renderingGroupId The rendering group id corresponding to its index
  91502. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  91503. * @param depth Automatically clears depth between groups if true and autoClear is true.
  91504. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  91505. */
  91506. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  91507. /**
  91508. * Gets the current auto clear configuration for one rendering group of the rendering
  91509. * manager.
  91510. * @param index the rendering group index to get the information for
  91511. * @returns The auto clear setup for the requested rendering group
  91512. */
  91513. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  91514. private _blockMaterialDirtyMechanism;
  91515. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  91516. blockMaterialDirtyMechanism: boolean;
  91517. /**
  91518. * Will flag all materials as dirty to trigger new shader compilation
  91519. * @param flag defines the flag used to specify which material part must be marked as dirty
  91520. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  91521. */
  91522. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  91523. /** @hidden */
  91524. _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;
  91525. /** @hidden */
  91526. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  91527. }
  91528. }
  91529. declare module BABYLON {
  91530. /**
  91531. * Set of assets to keep when moving a scene into an asset container.
  91532. */
  91533. export class KeepAssets extends AbstractScene {
  91534. }
  91535. /**
  91536. * Container with a set of assets that can be added or removed from a scene.
  91537. */
  91538. export class AssetContainer extends AbstractScene {
  91539. /**
  91540. * The scene the AssetContainer belongs to.
  91541. */
  91542. scene: Scene;
  91543. /**
  91544. * Instantiates an AssetContainer.
  91545. * @param scene The scene the AssetContainer belongs to.
  91546. */
  91547. constructor(scene: Scene);
  91548. /**
  91549. * Adds all the assets from the container to the scene.
  91550. */
  91551. addAllToScene(): void;
  91552. /**
  91553. * Removes all the assets in the container from the scene
  91554. */
  91555. removeAllFromScene(): void;
  91556. /**
  91557. * Disposes all the assets in the container
  91558. */
  91559. dispose(): void;
  91560. private _moveAssets;
  91561. /**
  91562. * Removes all the assets contained in the scene and adds them to the container.
  91563. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  91564. */
  91565. moveAllFromScene(keepAssets?: KeepAssets): void;
  91566. /**
  91567. * 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.
  91568. * @returns the root mesh
  91569. */
  91570. createRootMesh(): Mesh;
  91571. }
  91572. }
  91573. declare module BABYLON {
  91574. /**
  91575. * Defines how the parser contract is defined.
  91576. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  91577. */
  91578. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  91579. /**
  91580. * Defines how the individual parser contract is defined.
  91581. * These parser can parse an individual asset
  91582. */
  91583. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  91584. /**
  91585. * Base class of the scene acting as a container for the different elements composing a scene.
  91586. * This class is dynamically extended by the different components of the scene increasing
  91587. * flexibility and reducing coupling
  91588. */
  91589. export abstract class AbstractScene {
  91590. /**
  91591. * Stores the list of available parsers in the application.
  91592. */
  91593. private static _BabylonFileParsers;
  91594. /**
  91595. * Stores the list of available individual parsers in the application.
  91596. */
  91597. private static _IndividualBabylonFileParsers;
  91598. /**
  91599. * Adds a parser in the list of available ones
  91600. * @param name Defines the name of the parser
  91601. * @param parser Defines the parser to add
  91602. */
  91603. static AddParser(name: string, parser: BabylonFileParser): void;
  91604. /**
  91605. * Gets a general parser from the list of avaialble ones
  91606. * @param name Defines the name of the parser
  91607. * @returns the requested parser or null
  91608. */
  91609. static GetParser(name: string): Nullable<BabylonFileParser>;
  91610. /**
  91611. * Adds n individual parser in the list of available ones
  91612. * @param name Defines the name of the parser
  91613. * @param parser Defines the parser to add
  91614. */
  91615. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  91616. /**
  91617. * Gets an individual parser from the list of avaialble ones
  91618. * @param name Defines the name of the parser
  91619. * @returns the requested parser or null
  91620. */
  91621. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  91622. /**
  91623. * Parser json data and populate both a scene and its associated container object
  91624. * @param jsonData Defines the data to parse
  91625. * @param scene Defines the scene to parse the data for
  91626. * @param container Defines the container attached to the parsing sequence
  91627. * @param rootUrl Defines the root url of the data
  91628. */
  91629. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  91630. /**
  91631. * Gets the list of root nodes (ie. nodes with no parent)
  91632. */
  91633. rootNodes: Node[];
  91634. /** All of the cameras added to this scene
  91635. * @see http://doc.babylonjs.com/babylon101/cameras
  91636. */
  91637. cameras: Camera[];
  91638. /**
  91639. * All of the lights added to this scene
  91640. * @see http://doc.babylonjs.com/babylon101/lights
  91641. */
  91642. lights: Light[];
  91643. /**
  91644. * All of the (abstract) meshes added to this scene
  91645. */
  91646. meshes: AbstractMesh[];
  91647. /**
  91648. * The list of skeletons added to the scene
  91649. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  91650. */
  91651. skeletons: Skeleton[];
  91652. /**
  91653. * All of the particle systems added to this scene
  91654. * @see http://doc.babylonjs.com/babylon101/particles
  91655. */
  91656. particleSystems: IParticleSystem[];
  91657. /**
  91658. * Gets a list of Animations associated with the scene
  91659. */
  91660. animations: Animation[];
  91661. /**
  91662. * All of the animation groups added to this scene
  91663. * @see http://doc.babylonjs.com/how_to/group
  91664. */
  91665. animationGroups: AnimationGroup[];
  91666. /**
  91667. * All of the multi-materials added to this scene
  91668. * @see http://doc.babylonjs.com/how_to/multi_materials
  91669. */
  91670. multiMaterials: MultiMaterial[];
  91671. /**
  91672. * All of the materials added to this scene
  91673. * In the context of a Scene, it is not supposed to be modified manually.
  91674. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  91675. * Note also that the order of the Material wihin the array is not significant and might change.
  91676. * @see http://doc.babylonjs.com/babylon101/materials
  91677. */
  91678. materials: Material[];
  91679. /**
  91680. * The list of morph target managers added to the scene
  91681. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  91682. */
  91683. morphTargetManagers: MorphTargetManager[];
  91684. /**
  91685. * The list of geometries used in the scene.
  91686. */
  91687. geometries: Geometry[];
  91688. /**
  91689. * All of the tranform nodes added to this scene
  91690. * In the context of a Scene, it is not supposed to be modified manually.
  91691. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  91692. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  91693. * @see http://doc.babylonjs.com/how_to/transformnode
  91694. */
  91695. transformNodes: TransformNode[];
  91696. /**
  91697. * ActionManagers available on the scene.
  91698. */
  91699. actionManagers: AbstractActionManager[];
  91700. /**
  91701. * Textures to keep.
  91702. */
  91703. textures: BaseTexture[];
  91704. }
  91705. }
  91706. declare module BABYLON {
  91707. /**
  91708. * Defines a sound that can be played in the application.
  91709. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  91710. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  91711. */
  91712. export class Sound {
  91713. /**
  91714. * The name of the sound in the scene.
  91715. */
  91716. name: string;
  91717. /**
  91718. * Does the sound autoplay once loaded.
  91719. */
  91720. autoplay: boolean;
  91721. /**
  91722. * Does the sound loop after it finishes playing once.
  91723. */
  91724. loop: boolean;
  91725. /**
  91726. * Does the sound use a custom attenuation curve to simulate the falloff
  91727. * happening when the source gets further away from the camera.
  91728. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  91729. */
  91730. useCustomAttenuation: boolean;
  91731. /**
  91732. * The sound track id this sound belongs to.
  91733. */
  91734. soundTrackId: number;
  91735. /**
  91736. * Is this sound currently played.
  91737. */
  91738. isPlaying: boolean;
  91739. /**
  91740. * Is this sound currently paused.
  91741. */
  91742. isPaused: boolean;
  91743. /**
  91744. * Does this sound enables spatial sound.
  91745. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91746. */
  91747. spatialSound: boolean;
  91748. /**
  91749. * Define the reference distance the sound should be heard perfectly.
  91750. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91751. */
  91752. refDistance: number;
  91753. /**
  91754. * Define the roll off factor of spatial sounds.
  91755. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91756. */
  91757. rolloffFactor: number;
  91758. /**
  91759. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  91760. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91761. */
  91762. maxDistance: number;
  91763. /**
  91764. * Define the distance attenuation model the sound will follow.
  91765. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91766. */
  91767. distanceModel: string;
  91768. /**
  91769. * @hidden
  91770. * Back Compat
  91771. **/
  91772. onended: () => any;
  91773. /**
  91774. * Observable event when the current playing sound finishes.
  91775. */
  91776. onEndedObservable: Observable<Sound>;
  91777. private _panningModel;
  91778. private _playbackRate;
  91779. private _streaming;
  91780. private _startTime;
  91781. private _startOffset;
  91782. private _position;
  91783. /** @hidden */
  91784. _positionInEmitterSpace: boolean;
  91785. private _localDirection;
  91786. private _volume;
  91787. private _isReadyToPlay;
  91788. private _isDirectional;
  91789. private _readyToPlayCallback;
  91790. private _audioBuffer;
  91791. private _soundSource;
  91792. private _streamingSource;
  91793. private _soundPanner;
  91794. private _soundGain;
  91795. private _inputAudioNode;
  91796. private _outputAudioNode;
  91797. private _coneInnerAngle;
  91798. private _coneOuterAngle;
  91799. private _coneOuterGain;
  91800. private _scene;
  91801. private _connectedTransformNode;
  91802. private _customAttenuationFunction;
  91803. private _registerFunc;
  91804. private _isOutputConnected;
  91805. private _htmlAudioElement;
  91806. private _urlType;
  91807. /** @hidden */
  91808. static _SceneComponentInitialization: (scene: Scene) => void;
  91809. /**
  91810. * Create a sound and attach it to a scene
  91811. * @param name Name of your sound
  91812. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  91813. * @param scene defines the scene the sound belongs to
  91814. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  91815. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  91816. */
  91817. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  91818. /**
  91819. * Release the sound and its associated resources
  91820. */
  91821. dispose(): void;
  91822. /**
  91823. * Gets if the sounds is ready to be played or not.
  91824. * @returns true if ready, otherwise false
  91825. */
  91826. isReady(): boolean;
  91827. private _soundLoaded;
  91828. /**
  91829. * Sets the data of the sound from an audiobuffer
  91830. * @param audioBuffer The audioBuffer containing the data
  91831. */
  91832. setAudioBuffer(audioBuffer: AudioBuffer): void;
  91833. /**
  91834. * Updates the current sounds options such as maxdistance, loop...
  91835. * @param options A JSON object containing values named as the object properties
  91836. */
  91837. updateOptions(options: any): void;
  91838. private _createSpatialParameters;
  91839. private _updateSpatialParameters;
  91840. /**
  91841. * Switch the panning model to HRTF:
  91842. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  91843. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91844. */
  91845. switchPanningModelToHRTF(): void;
  91846. /**
  91847. * Switch the panning model to Equal Power:
  91848. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  91849. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  91850. */
  91851. switchPanningModelToEqualPower(): void;
  91852. private _switchPanningModel;
  91853. /**
  91854. * Connect this sound to a sound track audio node like gain...
  91855. * @param soundTrackAudioNode the sound track audio node to connect to
  91856. */
  91857. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  91858. /**
  91859. * Transform this sound into a directional source
  91860. * @param coneInnerAngle Size of the inner cone in degree
  91861. * @param coneOuterAngle Size of the outer cone in degree
  91862. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  91863. */
  91864. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  91865. /**
  91866. * Gets or sets the inner angle for the directional cone.
  91867. */
  91868. /**
  91869. * Gets or sets the inner angle for the directional cone.
  91870. */
  91871. directionalConeInnerAngle: number;
  91872. /**
  91873. * Gets or sets the outer angle for the directional cone.
  91874. */
  91875. /**
  91876. * Gets or sets the outer angle for the directional cone.
  91877. */
  91878. directionalConeOuterAngle: number;
  91879. /**
  91880. * Sets the position of the emitter if spatial sound is enabled
  91881. * @param newPosition Defines the new posisiton
  91882. */
  91883. setPosition(newPosition: Vector3): void;
  91884. /**
  91885. * Sets the local direction of the emitter if spatial sound is enabled
  91886. * @param newLocalDirection Defines the new local direction
  91887. */
  91888. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  91889. private _updateDirection;
  91890. /** @hidden */
  91891. updateDistanceFromListener(): void;
  91892. /**
  91893. * Sets a new custom attenuation function for the sound.
  91894. * @param callback Defines the function used for the attenuation
  91895. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  91896. */
  91897. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  91898. /**
  91899. * Play the sound
  91900. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  91901. * @param offset (optional) Start the sound setting it at a specific time
  91902. */
  91903. play(time?: number, offset?: number): void;
  91904. private _onended;
  91905. /**
  91906. * Stop the sound
  91907. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  91908. */
  91909. stop(time?: number): void;
  91910. /**
  91911. * Put the sound in pause
  91912. */
  91913. pause(): void;
  91914. /**
  91915. * Sets a dedicated volume for this sounds
  91916. * @param newVolume Define the new volume of the sound
  91917. * @param time Define in how long the sound should be at this value
  91918. */
  91919. setVolume(newVolume: number, time?: number): void;
  91920. /**
  91921. * Set the sound play back rate
  91922. * @param newPlaybackRate Define the playback rate the sound should be played at
  91923. */
  91924. setPlaybackRate(newPlaybackRate: number): void;
  91925. /**
  91926. * Gets the volume of the sound.
  91927. * @returns the volume of the sound
  91928. */
  91929. getVolume(): number;
  91930. /**
  91931. * Attach the sound to a dedicated mesh
  91932. * @param transformNode The transform node to connect the sound with
  91933. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  91934. */
  91935. attachToMesh(transformNode: TransformNode): void;
  91936. /**
  91937. * Detach the sound from the previously attached mesh
  91938. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  91939. */
  91940. detachFromMesh(): void;
  91941. private _onRegisterAfterWorldMatrixUpdate;
  91942. /**
  91943. * Clone the current sound in the scene.
  91944. * @returns the new sound clone
  91945. */
  91946. clone(): Nullable<Sound>;
  91947. /**
  91948. * Gets the current underlying audio buffer containing the data
  91949. * @returns the audio buffer
  91950. */
  91951. getAudioBuffer(): Nullable<AudioBuffer>;
  91952. /**
  91953. * Serializes the Sound in a JSON representation
  91954. * @returns the JSON representation of the sound
  91955. */
  91956. serialize(): any;
  91957. /**
  91958. * Parse a JSON representation of a sound to innstantiate in a given scene
  91959. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  91960. * @param scene Define the scene the new parsed sound should be created in
  91961. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  91962. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  91963. * @returns the newly parsed sound
  91964. */
  91965. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  91966. }
  91967. }
  91968. declare module BABYLON {
  91969. /**
  91970. * This defines an action helpful to play a defined sound on a triggered action.
  91971. */
  91972. export class PlaySoundAction extends Action {
  91973. private _sound;
  91974. /**
  91975. * Instantiate the action
  91976. * @param triggerOptions defines the trigger options
  91977. * @param sound defines the sound to play
  91978. * @param condition defines the trigger related conditions
  91979. */
  91980. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  91981. /** @hidden */
  91982. _prepare(): void;
  91983. /**
  91984. * Execute the action and play the sound.
  91985. */
  91986. execute(): void;
  91987. /**
  91988. * Serializes the actions and its related information.
  91989. * @param parent defines the object to serialize in
  91990. * @returns the serialized object
  91991. */
  91992. serialize(parent: any): any;
  91993. }
  91994. /**
  91995. * This defines an action helpful to stop a defined sound on a triggered action.
  91996. */
  91997. export class StopSoundAction extends Action {
  91998. private _sound;
  91999. /**
  92000. * Instantiate the action
  92001. * @param triggerOptions defines the trigger options
  92002. * @param sound defines the sound to stop
  92003. * @param condition defines the trigger related conditions
  92004. */
  92005. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  92006. /** @hidden */
  92007. _prepare(): void;
  92008. /**
  92009. * Execute the action and stop the sound.
  92010. */
  92011. execute(): void;
  92012. /**
  92013. * Serializes the actions and its related information.
  92014. * @param parent defines the object to serialize in
  92015. * @returns the serialized object
  92016. */
  92017. serialize(parent: any): any;
  92018. }
  92019. }
  92020. declare module BABYLON {
  92021. /**
  92022. * This defines an action responsible to change the value of a property
  92023. * by interpolating between its current value and the newly set one once triggered.
  92024. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92025. */
  92026. export class InterpolateValueAction extends Action {
  92027. /**
  92028. * Defines the path of the property where the value should be interpolated
  92029. */
  92030. propertyPath: string;
  92031. /**
  92032. * Defines the target value at the end of the interpolation.
  92033. */
  92034. value: any;
  92035. /**
  92036. * Defines the time it will take for the property to interpolate to the value.
  92037. */
  92038. duration: number;
  92039. /**
  92040. * Defines if the other scene animations should be stopped when the action has been triggered
  92041. */
  92042. stopOtherAnimations?: boolean;
  92043. /**
  92044. * Defines a callback raised once the interpolation animation has been done.
  92045. */
  92046. onInterpolationDone?: () => void;
  92047. /**
  92048. * Observable triggered once the interpolation animation has been done.
  92049. */
  92050. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  92051. private _target;
  92052. private _effectiveTarget;
  92053. private _property;
  92054. /**
  92055. * Instantiate the action
  92056. * @param triggerOptions defines the trigger options
  92057. * @param target defines the object containing the value to interpolate
  92058. * @param propertyPath defines the path to the property in the target object
  92059. * @param value defines the target value at the end of the interpolation
  92060. * @param duration deines the time it will take for the property to interpolate to the value.
  92061. * @param condition defines the trigger related conditions
  92062. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  92063. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  92064. */
  92065. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  92066. /** @hidden */
  92067. _prepare(): void;
  92068. /**
  92069. * Execute the action starts the value interpolation.
  92070. */
  92071. execute(): void;
  92072. /**
  92073. * Serializes the actions and its related information.
  92074. * @param parent defines the object to serialize in
  92075. * @returns the serialized object
  92076. */
  92077. serialize(parent: any): any;
  92078. }
  92079. }
  92080. declare module BABYLON {
  92081. /**
  92082. * Options allowed during the creation of a sound track.
  92083. */
  92084. export interface ISoundTrackOptions {
  92085. /**
  92086. * The volume the sound track should take during creation
  92087. */
  92088. volume?: number;
  92089. /**
  92090. * Define if the sound track is the main sound track of the scene
  92091. */
  92092. mainTrack?: boolean;
  92093. }
  92094. /**
  92095. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  92096. * It will be also used in a future release to apply effects on a specific track.
  92097. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  92098. */
  92099. export class SoundTrack {
  92100. /**
  92101. * The unique identifier of the sound track in the scene.
  92102. */
  92103. id: number;
  92104. /**
  92105. * The list of sounds included in the sound track.
  92106. */
  92107. soundCollection: Array<Sound>;
  92108. private _outputAudioNode;
  92109. private _scene;
  92110. private _isMainTrack;
  92111. private _connectedAnalyser;
  92112. private _options;
  92113. private _isInitialized;
  92114. /**
  92115. * Creates a new sound track.
  92116. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  92117. * @param scene Define the scene the sound track belongs to
  92118. * @param options
  92119. */
  92120. constructor(scene: Scene, options?: ISoundTrackOptions);
  92121. private _initializeSoundTrackAudioGraph;
  92122. /**
  92123. * Release the sound track and its associated resources
  92124. */
  92125. dispose(): void;
  92126. /**
  92127. * Adds a sound to this sound track
  92128. * @param sound define the cound to add
  92129. * @ignoreNaming
  92130. */
  92131. AddSound(sound: Sound): void;
  92132. /**
  92133. * Removes a sound to this sound track
  92134. * @param sound define the cound to remove
  92135. * @ignoreNaming
  92136. */
  92137. RemoveSound(sound: Sound): void;
  92138. /**
  92139. * Set a global volume for the full sound track.
  92140. * @param newVolume Define the new volume of the sound track
  92141. */
  92142. setVolume(newVolume: number): void;
  92143. /**
  92144. * Switch the panning model to HRTF:
  92145. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  92146. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92147. */
  92148. switchPanningModelToHRTF(): void;
  92149. /**
  92150. * Switch the panning model to Equal Power:
  92151. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  92152. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  92153. */
  92154. switchPanningModelToEqualPower(): void;
  92155. /**
  92156. * Connect the sound track to an audio analyser allowing some amazing
  92157. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  92158. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  92159. * @param analyser The analyser to connect to the engine
  92160. */
  92161. connectToAnalyser(analyser: Analyser): void;
  92162. }
  92163. }
  92164. declare module BABYLON {
  92165. interface AbstractScene {
  92166. /**
  92167. * The list of sounds used in the scene.
  92168. */
  92169. sounds: Nullable<Array<Sound>>;
  92170. }
  92171. interface Scene {
  92172. /**
  92173. * @hidden
  92174. * Backing field
  92175. */
  92176. _mainSoundTrack: SoundTrack;
  92177. /**
  92178. * The main sound track played by the scene.
  92179. * It cotains your primary collection of sounds.
  92180. */
  92181. mainSoundTrack: SoundTrack;
  92182. /**
  92183. * The list of sound tracks added to the scene
  92184. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92185. */
  92186. soundTracks: Nullable<Array<SoundTrack>>;
  92187. /**
  92188. * Gets a sound using a given name
  92189. * @param name defines the name to search for
  92190. * @return the found sound or null if not found at all.
  92191. */
  92192. getSoundByName(name: string): Nullable<Sound>;
  92193. /**
  92194. * Gets or sets if audio support is enabled
  92195. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92196. */
  92197. audioEnabled: boolean;
  92198. /**
  92199. * Gets or sets if audio will be output to headphones
  92200. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92201. */
  92202. headphone: boolean;
  92203. }
  92204. /**
  92205. * Defines the sound scene component responsible to manage any sounds
  92206. * in a given scene.
  92207. */
  92208. export class AudioSceneComponent implements ISceneSerializableComponent {
  92209. /**
  92210. * The component name helpfull to identify the component in the list of scene components.
  92211. */
  92212. readonly name: string;
  92213. /**
  92214. * The scene the component belongs to.
  92215. */
  92216. scene: Scene;
  92217. private _audioEnabled;
  92218. /**
  92219. * Gets whether audio is enabled or not.
  92220. * Please use related enable/disable method to switch state.
  92221. */
  92222. readonly audioEnabled: boolean;
  92223. private _headphone;
  92224. /**
  92225. * Gets whether audio is outputing to headphone or not.
  92226. * Please use the according Switch methods to change output.
  92227. */
  92228. readonly headphone: boolean;
  92229. /**
  92230. * Creates a new instance of the component for the given scene
  92231. * @param scene Defines the scene to register the component in
  92232. */
  92233. constructor(scene: Scene);
  92234. /**
  92235. * Registers the component in a given scene
  92236. */
  92237. register(): void;
  92238. /**
  92239. * Rebuilds the elements related to this component in case of
  92240. * context lost for instance.
  92241. */
  92242. rebuild(): void;
  92243. /**
  92244. * Serializes the component data to the specified json object
  92245. * @param serializationObject The object to serialize to
  92246. */
  92247. serialize(serializationObject: any): void;
  92248. /**
  92249. * Adds all the element from the container to the scene
  92250. * @param container the container holding the elements
  92251. */
  92252. addFromContainer(container: AbstractScene): void;
  92253. /**
  92254. * Removes all the elements in the container from the scene
  92255. * @param container contains the elements to remove
  92256. */
  92257. removeFromContainer(container: AbstractScene): void;
  92258. /**
  92259. * Disposes the component and the associated ressources.
  92260. */
  92261. dispose(): void;
  92262. /**
  92263. * Disables audio in the associated scene.
  92264. */
  92265. disableAudio(): void;
  92266. /**
  92267. * Enables audio in the associated scene.
  92268. */
  92269. enableAudio(): void;
  92270. /**
  92271. * Switch audio to headphone output.
  92272. */
  92273. switchAudioModeForHeadphones(): void;
  92274. /**
  92275. * Switch audio to normal speakers.
  92276. */
  92277. switchAudioModeForNormalSpeakers(): void;
  92278. private _afterRender;
  92279. }
  92280. }
  92281. declare module BABYLON {
  92282. /**
  92283. * Wraps one or more Sound objects and selects one with random weight for playback.
  92284. */
  92285. export class WeightedSound {
  92286. /** When true a Sound will be selected and played when the current playing Sound completes. */
  92287. loop: boolean;
  92288. private _coneInnerAngle;
  92289. private _coneOuterAngle;
  92290. private _volume;
  92291. /** A Sound is currently playing. */
  92292. isPlaying: boolean;
  92293. /** A Sound is currently paused. */
  92294. isPaused: boolean;
  92295. private _sounds;
  92296. private _weights;
  92297. private _currentIndex?;
  92298. /**
  92299. * Creates a new WeightedSound from the list of sounds given.
  92300. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  92301. * @param sounds Array of Sounds that will be selected from.
  92302. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  92303. */
  92304. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  92305. /**
  92306. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  92307. */
  92308. /**
  92309. * The size of cone in degress for a directional sound in which there will be no attenuation.
  92310. */
  92311. directionalConeInnerAngle: number;
  92312. /**
  92313. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  92314. * Listener angles between innerAngle and outerAngle will falloff linearly.
  92315. */
  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. directionalConeOuterAngle: number;
  92321. /**
  92322. * Playback volume.
  92323. */
  92324. /**
  92325. * Playback volume.
  92326. */
  92327. volume: number;
  92328. private _onended;
  92329. /**
  92330. * Suspend playback
  92331. */
  92332. pause(): void;
  92333. /**
  92334. * Stop playback
  92335. */
  92336. stop(): void;
  92337. /**
  92338. * Start playback.
  92339. * @param startOffset Position the clip head at a specific time in seconds.
  92340. */
  92341. play(startOffset?: number): void;
  92342. }
  92343. }
  92344. declare module BABYLON {
  92345. /**
  92346. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  92347. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  92348. */
  92349. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  92350. /**
  92351. * Gets the name of the behavior.
  92352. */
  92353. readonly name: string;
  92354. /**
  92355. * The easing function used by animations
  92356. */
  92357. static EasingFunction: BackEase;
  92358. /**
  92359. * The easing mode used by animations
  92360. */
  92361. static EasingMode: number;
  92362. /**
  92363. * The duration of the animation, in milliseconds
  92364. */
  92365. transitionDuration: number;
  92366. /**
  92367. * Length of the distance animated by the transition when lower radius is reached
  92368. */
  92369. lowerRadiusTransitionRange: number;
  92370. /**
  92371. * Length of the distance animated by the transition when upper radius is reached
  92372. */
  92373. upperRadiusTransitionRange: number;
  92374. private _autoTransitionRange;
  92375. /**
  92376. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  92377. */
  92378. /**
  92379. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  92380. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  92381. */
  92382. autoTransitionRange: boolean;
  92383. private _attachedCamera;
  92384. private _onAfterCheckInputsObserver;
  92385. private _onMeshTargetChangedObserver;
  92386. /**
  92387. * Initializes the behavior.
  92388. */
  92389. init(): void;
  92390. /**
  92391. * Attaches the behavior to its arc rotate camera.
  92392. * @param camera Defines the camera to attach the behavior to
  92393. */
  92394. attach(camera: ArcRotateCamera): void;
  92395. /**
  92396. * Detaches the behavior from its current arc rotate camera.
  92397. */
  92398. detach(): void;
  92399. private _radiusIsAnimating;
  92400. private _radiusBounceTransition;
  92401. private _animatables;
  92402. private _cachedWheelPrecision;
  92403. /**
  92404. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  92405. * @param radiusLimit The limit to check against.
  92406. * @return Bool to indicate if at limit.
  92407. */
  92408. private _isRadiusAtLimit;
  92409. /**
  92410. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  92411. * @param radiusDelta The delta by which to animate to. Can be negative.
  92412. */
  92413. private _applyBoundRadiusAnimation;
  92414. /**
  92415. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  92416. */
  92417. protected _clearAnimationLocks(): void;
  92418. /**
  92419. * Stops and removes all animations that have been applied to the camera
  92420. */
  92421. stopAllAnimations(): void;
  92422. }
  92423. }
  92424. declare module BABYLON {
  92425. /**
  92426. * 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.
  92427. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  92428. */
  92429. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  92430. /**
  92431. * Gets the name of the behavior.
  92432. */
  92433. readonly name: string;
  92434. private _mode;
  92435. private _radiusScale;
  92436. private _positionScale;
  92437. private _defaultElevation;
  92438. private _elevationReturnTime;
  92439. private _elevationReturnWaitTime;
  92440. private _zoomStopsAnimation;
  92441. private _framingTime;
  92442. /**
  92443. * The easing function used by animations
  92444. */
  92445. static EasingFunction: ExponentialEase;
  92446. /**
  92447. * The easing mode used by animations
  92448. */
  92449. static EasingMode: number;
  92450. /**
  92451. * Sets the current mode used by the behavior
  92452. */
  92453. /**
  92454. * Gets current mode used by the behavior.
  92455. */
  92456. mode: number;
  92457. /**
  92458. * Sets the scale applied to the radius (1 by default)
  92459. */
  92460. /**
  92461. * Gets the scale applied to the radius
  92462. */
  92463. radiusScale: number;
  92464. /**
  92465. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  92466. */
  92467. /**
  92468. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  92469. */
  92470. positionScale: number;
  92471. /**
  92472. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  92473. * behaviour is triggered, in radians.
  92474. */
  92475. /**
  92476. * Gets 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. defaultElevation: number;
  92480. /**
  92481. * Sets the time (in milliseconds) taken to return to the default beta position.
  92482. * Negative value indicates camera should not return to default.
  92483. */
  92484. /**
  92485. * Gets the time (in milliseconds) taken to return to the default beta position.
  92486. * Negative value indicates camera should not return to default.
  92487. */
  92488. elevationReturnTime: number;
  92489. /**
  92490. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  92491. */
  92492. /**
  92493. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  92494. */
  92495. elevationReturnWaitTime: number;
  92496. /**
  92497. * Sets the flag that indicates if user zooming should stop animation.
  92498. */
  92499. /**
  92500. * Gets the flag that indicates if user zooming should stop animation.
  92501. */
  92502. zoomStopsAnimation: boolean;
  92503. /**
  92504. * Sets the transition time when framing the mesh, in milliseconds
  92505. */
  92506. /**
  92507. * Gets the transition time when framing the mesh, in milliseconds
  92508. */
  92509. framingTime: number;
  92510. /**
  92511. * Define if the behavior should automatically change the configured
  92512. * camera limits and sensibilities.
  92513. */
  92514. autoCorrectCameraLimitsAndSensibility: boolean;
  92515. private _onPrePointerObservableObserver;
  92516. private _onAfterCheckInputsObserver;
  92517. private _onMeshTargetChangedObserver;
  92518. private _attachedCamera;
  92519. private _isPointerDown;
  92520. private _lastInteractionTime;
  92521. /**
  92522. * Initializes the behavior.
  92523. */
  92524. init(): void;
  92525. /**
  92526. * Attaches the behavior to its arc rotate camera.
  92527. * @param camera Defines the camera to attach the behavior to
  92528. */
  92529. attach(camera: ArcRotateCamera): void;
  92530. /**
  92531. * Detaches the behavior from its current arc rotate camera.
  92532. */
  92533. detach(): void;
  92534. private _animatables;
  92535. private _betaIsAnimating;
  92536. private _betaTransition;
  92537. private _radiusTransition;
  92538. private _vectorTransition;
  92539. /**
  92540. * Targets the given mesh and updates zoom level accordingly.
  92541. * @param mesh The mesh to target.
  92542. * @param radius Optional. If a cached radius position already exists, overrides default.
  92543. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  92544. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  92545. * @param onAnimationEnd Callback triggered at the end of the framing animation
  92546. */
  92547. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  92548. /**
  92549. * Targets the given mesh with its children and updates zoom level accordingly.
  92550. * @param mesh The mesh to target.
  92551. * @param radius Optional. If a cached radius position already exists, overrides default.
  92552. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  92553. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  92554. * @param onAnimationEnd Callback triggered at the end of the framing animation
  92555. */
  92556. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  92557. /**
  92558. * Targets the given meshes with their children and updates zoom level accordingly.
  92559. * @param meshes The mesh to target.
  92560. * @param radius Optional. If a cached radius position already exists, overrides default.
  92561. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  92562. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  92563. * @param onAnimationEnd Callback triggered at the end of the framing animation
  92564. */
  92565. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  92566. /**
  92567. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  92568. * @param minimumWorld Determines the smaller position of the bounding box extend
  92569. * @param maximumWorld Determines the bigger position of the bounding box extend
  92570. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  92571. * @param onAnimationEnd Callback triggered at the end of the framing animation
  92572. */
  92573. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  92574. /**
  92575. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  92576. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  92577. * frustum width.
  92578. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  92579. * to fully enclose the mesh in the viewing frustum.
  92580. */
  92581. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  92582. /**
  92583. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  92584. * is automatically returned to its default position (expected to be above ground plane).
  92585. */
  92586. private _maintainCameraAboveGround;
  92587. /**
  92588. * Returns the frustum slope based on the canvas ratio and camera FOV
  92589. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  92590. */
  92591. private _getFrustumSlope;
  92592. /**
  92593. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  92594. */
  92595. private _clearAnimationLocks;
  92596. /**
  92597. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  92598. */
  92599. private _applyUserInteraction;
  92600. /**
  92601. * Stops and removes all animations that have been applied to the camera
  92602. */
  92603. stopAllAnimations(): void;
  92604. /**
  92605. * Gets a value indicating if the user is moving the camera
  92606. */
  92607. readonly isUserIsMoving: boolean;
  92608. /**
  92609. * The camera can move all the way towards the mesh.
  92610. */
  92611. static IgnoreBoundsSizeMode: number;
  92612. /**
  92613. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  92614. */
  92615. static FitFrustumSidesMode: number;
  92616. }
  92617. }
  92618. declare module BABYLON {
  92619. /**
  92620. * Base class for Camera Pointer Inputs.
  92621. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  92622. * for example usage.
  92623. */
  92624. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  92625. /**
  92626. * Defines the camera the input is attached to.
  92627. */
  92628. abstract camera: Camera;
  92629. /**
  92630. * Whether keyboard modifier keys are pressed at time of last mouse event.
  92631. */
  92632. protected _altKey: boolean;
  92633. protected _ctrlKey: boolean;
  92634. protected _metaKey: boolean;
  92635. protected _shiftKey: boolean;
  92636. /**
  92637. * Which mouse buttons were pressed at time of last mouse event.
  92638. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  92639. */
  92640. protected _buttonsPressed: number;
  92641. /**
  92642. * Defines the buttons associated with the input to handle camera move.
  92643. */
  92644. buttons: number[];
  92645. /**
  92646. * Attach the input controls to a specific dom element to get the input from.
  92647. * @param element Defines the element the controls should be listened from
  92648. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92649. */
  92650. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92651. /**
  92652. * Detach the current controls from the specified dom element.
  92653. * @param element Defines the element to stop listening the inputs from
  92654. */
  92655. detachControl(element: Nullable<HTMLElement>): void;
  92656. /**
  92657. * Gets the class name of the current input.
  92658. * @returns the class name
  92659. */
  92660. getClassName(): string;
  92661. /**
  92662. * Get the friendly name associated with the input class.
  92663. * @returns the input friendly name
  92664. */
  92665. getSimpleName(): string;
  92666. /**
  92667. * Called on pointer POINTERDOUBLETAP event.
  92668. * Override this method to provide functionality on POINTERDOUBLETAP event.
  92669. */
  92670. protected onDoubleTap(type: string): void;
  92671. /**
  92672. * Called on pointer POINTERMOVE event if only a single touch is active.
  92673. * Override this method to provide functionality.
  92674. */
  92675. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  92676. /**
  92677. * Called on pointer POINTERMOVE event if multiple touches are active.
  92678. * Override this method to provide functionality.
  92679. */
  92680. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  92681. /**
  92682. * Called on JS contextmenu event.
  92683. * Override this method to provide functionality.
  92684. */
  92685. protected onContextMenu(evt: PointerEvent): void;
  92686. /**
  92687. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  92688. * press.
  92689. * Override this method to provide functionality.
  92690. */
  92691. protected onButtonDown(evt: PointerEvent): void;
  92692. /**
  92693. * Called each time a new POINTERUP event occurs. Ie, for each button
  92694. * release.
  92695. * Override this method to provide functionality.
  92696. */
  92697. protected onButtonUp(evt: PointerEvent): void;
  92698. /**
  92699. * Called when window becomes inactive.
  92700. * Override this method to provide functionality.
  92701. */
  92702. protected onLostFocus(): void;
  92703. private _pointerInput;
  92704. private _observer;
  92705. private _onLostFocus;
  92706. private pointA;
  92707. private pointB;
  92708. }
  92709. }
  92710. declare module BABYLON {
  92711. /**
  92712. * Manage the pointers inputs to control an arc rotate camera.
  92713. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92714. */
  92715. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  92716. /**
  92717. * Defines the camera the input is attached to.
  92718. */
  92719. camera: ArcRotateCamera;
  92720. /**
  92721. * Gets the class name of the current input.
  92722. * @returns the class name
  92723. */
  92724. getClassName(): string;
  92725. /**
  92726. * Defines the buttons associated with the input to handle camera move.
  92727. */
  92728. buttons: number[];
  92729. /**
  92730. * Defines the pointer angular sensibility along the X axis or how fast is
  92731. * the camera rotating.
  92732. */
  92733. angularSensibilityX: number;
  92734. /**
  92735. * Defines the pointer angular sensibility along the Y axis or how fast is
  92736. * the camera rotating.
  92737. */
  92738. angularSensibilityY: number;
  92739. /**
  92740. * Defines the pointer pinch precision or how fast is the camera zooming.
  92741. */
  92742. pinchPrecision: number;
  92743. /**
  92744. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  92745. * from 0.
  92746. * It defines the percentage of current camera.radius to use as delta when
  92747. * pinch zoom is used.
  92748. */
  92749. pinchDeltaPercentage: number;
  92750. /**
  92751. * Defines the pointer panning sensibility or how fast is the camera moving.
  92752. */
  92753. panningSensibility: number;
  92754. /**
  92755. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  92756. */
  92757. multiTouchPanning: boolean;
  92758. /**
  92759. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  92760. * zoom (pinch) through multitouch.
  92761. */
  92762. multiTouchPanAndZoom: boolean;
  92763. /**
  92764. * Revers pinch action direction.
  92765. */
  92766. pinchInwards: boolean;
  92767. private _isPanClick;
  92768. private _twoFingerActivityCount;
  92769. private _isPinching;
  92770. /**
  92771. * Called on pointer POINTERMOVE event if only a single touch is active.
  92772. */
  92773. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  92774. /**
  92775. * Called on pointer POINTERDOUBLETAP event.
  92776. */
  92777. protected onDoubleTap(type: string): void;
  92778. /**
  92779. * Called on pointer POINTERMOVE event if multiple touches are active.
  92780. */
  92781. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  92782. /**
  92783. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  92784. * press.
  92785. */
  92786. protected onButtonDown(evt: PointerEvent): void;
  92787. /**
  92788. * Called each time a new POINTERUP event occurs. Ie, for each button
  92789. * release.
  92790. */
  92791. protected onButtonUp(evt: PointerEvent): void;
  92792. /**
  92793. * Called when window becomes inactive.
  92794. */
  92795. protected onLostFocus(): void;
  92796. }
  92797. }
  92798. declare module BABYLON {
  92799. /**
  92800. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  92801. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92802. */
  92803. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  92804. /**
  92805. * Defines the camera the input is attached to.
  92806. */
  92807. camera: ArcRotateCamera;
  92808. /**
  92809. * Defines the list of key codes associated with the up action (increase alpha)
  92810. */
  92811. keysUp: number[];
  92812. /**
  92813. * Defines the list of key codes associated with the down action (decrease alpha)
  92814. */
  92815. keysDown: number[];
  92816. /**
  92817. * Defines the list of key codes associated with the left action (increase beta)
  92818. */
  92819. keysLeft: number[];
  92820. /**
  92821. * Defines the list of key codes associated with the right action (decrease beta)
  92822. */
  92823. keysRight: number[];
  92824. /**
  92825. * Defines the list of key codes associated with the reset action.
  92826. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  92827. */
  92828. keysReset: number[];
  92829. /**
  92830. * Defines the panning sensibility of the inputs.
  92831. * (How fast is the camera paning)
  92832. */
  92833. panningSensibility: number;
  92834. /**
  92835. * Defines the zooming sensibility of the inputs.
  92836. * (How fast is the camera zooming)
  92837. */
  92838. zoomingSensibility: number;
  92839. /**
  92840. * Defines wether maintaining the alt key down switch the movement mode from
  92841. * orientation to zoom.
  92842. */
  92843. useAltToZoom: boolean;
  92844. /**
  92845. * Rotation speed of the camera
  92846. */
  92847. angularSpeed: number;
  92848. private _keys;
  92849. private _ctrlPressed;
  92850. private _altPressed;
  92851. private _onCanvasBlurObserver;
  92852. private _onKeyboardObserver;
  92853. private _engine;
  92854. private _scene;
  92855. /**
  92856. * Attach the input controls to a specific dom element to get the input from.
  92857. * @param element Defines the element the controls should be listened from
  92858. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92859. */
  92860. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92861. /**
  92862. * Detach the current controls from the specified dom element.
  92863. * @param element Defines the element to stop listening the inputs from
  92864. */
  92865. detachControl(element: Nullable<HTMLElement>): void;
  92866. /**
  92867. * Update the current camera state depending on the inputs that have been used this frame.
  92868. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92869. */
  92870. checkInputs(): void;
  92871. /**
  92872. * Gets the class name of the current intput.
  92873. * @returns the class name
  92874. */
  92875. getClassName(): string;
  92876. /**
  92877. * Get the friendly name associated with the input class.
  92878. * @returns the input friendly name
  92879. */
  92880. getSimpleName(): string;
  92881. }
  92882. }
  92883. declare module BABYLON {
  92884. /**
  92885. * Manage the mouse wheel inputs to control an arc rotate camera.
  92886. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92887. */
  92888. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  92889. /**
  92890. * Defines the camera the input is attached to.
  92891. */
  92892. camera: ArcRotateCamera;
  92893. /**
  92894. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  92895. */
  92896. wheelPrecision: number;
  92897. /**
  92898. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  92899. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  92900. */
  92901. wheelDeltaPercentage: number;
  92902. private _wheel;
  92903. private _observer;
  92904. /**
  92905. * Attach the input controls to a specific dom element to get the input from.
  92906. * @param element Defines the element the controls should be listened from
  92907. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92908. */
  92909. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92910. /**
  92911. * Detach the current controls from the specified dom element.
  92912. * @param element Defines the element to stop listening the inputs from
  92913. */
  92914. detachControl(element: Nullable<HTMLElement>): void;
  92915. /**
  92916. * Gets the class name of the current intput.
  92917. * @returns the class name
  92918. */
  92919. getClassName(): string;
  92920. /**
  92921. * Get the friendly name associated with the input class.
  92922. * @returns the input friendly name
  92923. */
  92924. getSimpleName(): string;
  92925. }
  92926. }
  92927. declare module BABYLON {
  92928. /**
  92929. * Default Inputs manager for the ArcRotateCamera.
  92930. * It groups all the default supported inputs for ease of use.
  92931. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92932. */
  92933. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  92934. /**
  92935. * Instantiates a new ArcRotateCameraInputsManager.
  92936. * @param camera Defines the camera the inputs belong to
  92937. */
  92938. constructor(camera: ArcRotateCamera);
  92939. /**
  92940. * Add mouse wheel input support to the input manager.
  92941. * @returns the current input manager
  92942. */
  92943. addMouseWheel(): ArcRotateCameraInputsManager;
  92944. /**
  92945. * Add pointers input support to the input manager.
  92946. * @returns the current input manager
  92947. */
  92948. addPointers(): ArcRotateCameraInputsManager;
  92949. /**
  92950. * Add keyboard input support to the input manager.
  92951. * @returns the current input manager
  92952. */
  92953. addKeyboard(): ArcRotateCameraInputsManager;
  92954. }
  92955. }
  92956. declare module BABYLON {
  92957. /**
  92958. * This represents an orbital type of camera.
  92959. *
  92960. * 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.
  92961. * 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.
  92962. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  92963. */
  92964. export class ArcRotateCamera extends TargetCamera {
  92965. /**
  92966. * Defines the rotation angle of the camera along the longitudinal axis.
  92967. */
  92968. alpha: number;
  92969. /**
  92970. * Defines the rotation angle of the camera along the latitudinal axis.
  92971. */
  92972. beta: number;
  92973. /**
  92974. * Defines the radius of the camera from it s target point.
  92975. */
  92976. radius: number;
  92977. protected _target: Vector3;
  92978. protected _targetHost: Nullable<AbstractMesh>;
  92979. /**
  92980. * Defines the target point of the camera.
  92981. * The camera looks towards it form the radius distance.
  92982. */
  92983. target: Vector3;
  92984. /**
  92985. * Define the current local position of the camera in the scene
  92986. */
  92987. position: Vector3;
  92988. /**
  92989. * Current inertia value on the longitudinal axis.
  92990. * The bigger this number the longer it will take for the camera to stop.
  92991. */
  92992. inertialAlphaOffset: number;
  92993. /**
  92994. * Current inertia value on the latitudinal axis.
  92995. * The bigger this number the longer it will take for the camera to stop.
  92996. */
  92997. inertialBetaOffset: number;
  92998. /**
  92999. * Current inertia value on the radius axis.
  93000. * The bigger this number the longer it will take for the camera to stop.
  93001. */
  93002. inertialRadiusOffset: number;
  93003. /**
  93004. * Minimum allowed angle on the longitudinal axis.
  93005. * This can help limiting how the Camera is able to move in the scene.
  93006. */
  93007. lowerAlphaLimit: Nullable<number>;
  93008. /**
  93009. * Maximum allowed angle on the longitudinal axis.
  93010. * This can help limiting how the Camera is able to move in the scene.
  93011. */
  93012. upperAlphaLimit: Nullable<number>;
  93013. /**
  93014. * Minimum allowed angle on the latitudinal axis.
  93015. * This can help limiting how the Camera is able to move in the scene.
  93016. */
  93017. lowerBetaLimit: number;
  93018. /**
  93019. * Maximum allowed angle on the latitudinal axis.
  93020. * This can help limiting how the Camera is able to move in the scene.
  93021. */
  93022. upperBetaLimit: number;
  93023. /**
  93024. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  93025. * This can help limiting how the Camera is able to move in the scene.
  93026. */
  93027. lowerRadiusLimit: Nullable<number>;
  93028. /**
  93029. * Maximum allowed distance of the camera to the target (The camera can not get further).
  93030. * This can help limiting how the Camera is able to move in the scene.
  93031. */
  93032. upperRadiusLimit: Nullable<number>;
  93033. /**
  93034. * Defines the current inertia value used during panning of the camera along the X axis.
  93035. */
  93036. inertialPanningX: number;
  93037. /**
  93038. * Defines the current inertia value used during panning of the camera along the Y axis.
  93039. */
  93040. inertialPanningY: number;
  93041. /**
  93042. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  93043. * Basically if your fingers moves away from more than this distance you will be considered
  93044. * in pinch mode.
  93045. */
  93046. pinchToPanMaxDistance: number;
  93047. /**
  93048. * Defines the maximum distance the camera can pan.
  93049. * This could help keeping the cammera always in your scene.
  93050. */
  93051. panningDistanceLimit: Nullable<number>;
  93052. /**
  93053. * Defines the target of the camera before paning.
  93054. */
  93055. panningOriginTarget: Vector3;
  93056. /**
  93057. * Defines the value of the inertia used during panning.
  93058. * 0 would mean stop inertia and one would mean no decelleration at all.
  93059. */
  93060. panningInertia: number;
  93061. /**
  93062. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  93063. */
  93064. angularSensibilityX: number;
  93065. /**
  93066. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  93067. */
  93068. angularSensibilityY: number;
  93069. /**
  93070. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  93071. */
  93072. pinchPrecision: number;
  93073. /**
  93074. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  93075. * It will be used instead of pinchDeltaPrecision if different from 0.
  93076. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  93077. */
  93078. pinchDeltaPercentage: number;
  93079. /**
  93080. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  93081. */
  93082. panningSensibility: number;
  93083. /**
  93084. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  93085. */
  93086. keysUp: number[];
  93087. /**
  93088. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  93089. */
  93090. keysDown: number[];
  93091. /**
  93092. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  93093. */
  93094. keysLeft: number[];
  93095. /**
  93096. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  93097. */
  93098. keysRight: number[];
  93099. /**
  93100. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  93101. */
  93102. wheelPrecision: number;
  93103. /**
  93104. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  93105. * It will be used instead of pinchDeltaPrecision if different from 0.
  93106. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  93107. */
  93108. wheelDeltaPercentage: number;
  93109. /**
  93110. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  93111. */
  93112. zoomOnFactor: number;
  93113. /**
  93114. * Defines a screen offset for the camera position.
  93115. */
  93116. targetScreenOffset: Vector2;
  93117. /**
  93118. * Allows the camera to be completely reversed.
  93119. * If false the camera can not arrive upside down.
  93120. */
  93121. allowUpsideDown: boolean;
  93122. /**
  93123. * Define if double tap/click is used to restore the previously saved state of the camera.
  93124. */
  93125. useInputToRestoreState: boolean;
  93126. /** @hidden */
  93127. _viewMatrix: Matrix;
  93128. /** @hidden */
  93129. _useCtrlForPanning: boolean;
  93130. /** @hidden */
  93131. _panningMouseButton: number;
  93132. /**
  93133. * Defines the input associated to the camera.
  93134. */
  93135. inputs: ArcRotateCameraInputsManager;
  93136. /** @hidden */
  93137. _reset: () => void;
  93138. /**
  93139. * Defines the allowed panning axis.
  93140. */
  93141. panningAxis: Vector3;
  93142. protected _localDirection: Vector3;
  93143. protected _transformedDirection: Vector3;
  93144. private _bouncingBehavior;
  93145. /**
  93146. * Gets the bouncing behavior of the camera if it has been enabled.
  93147. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  93148. */
  93149. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  93150. /**
  93151. * Defines if the bouncing behavior of the camera is enabled on the camera.
  93152. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  93153. */
  93154. useBouncingBehavior: boolean;
  93155. private _framingBehavior;
  93156. /**
  93157. * Gets the framing behavior of the camera if it has been enabled.
  93158. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93159. */
  93160. readonly framingBehavior: Nullable<FramingBehavior>;
  93161. /**
  93162. * Defines if the framing behavior of the camera is enabled on the camera.
  93163. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93164. */
  93165. useFramingBehavior: boolean;
  93166. private _autoRotationBehavior;
  93167. /**
  93168. * Gets the auto rotation behavior of the camera if it has been enabled.
  93169. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  93170. */
  93171. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  93172. /**
  93173. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  93174. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  93175. */
  93176. useAutoRotationBehavior: boolean;
  93177. /**
  93178. * Observable triggered when the mesh target has been changed on the camera.
  93179. */
  93180. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  93181. /**
  93182. * Event raised when the camera is colliding with a mesh.
  93183. */
  93184. onCollide: (collidedMesh: AbstractMesh) => void;
  93185. /**
  93186. * Defines whether the camera should check collision with the objects oh the scene.
  93187. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  93188. */
  93189. checkCollisions: boolean;
  93190. /**
  93191. * Defines the collision radius of the camera.
  93192. * This simulates a sphere around the camera.
  93193. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  93194. */
  93195. collisionRadius: Vector3;
  93196. protected _collider: Collider;
  93197. protected _previousPosition: Vector3;
  93198. protected _collisionVelocity: Vector3;
  93199. protected _newPosition: Vector3;
  93200. protected _previousAlpha: number;
  93201. protected _previousBeta: number;
  93202. protected _previousRadius: number;
  93203. protected _collisionTriggered: boolean;
  93204. protected _targetBoundingCenter: Nullable<Vector3>;
  93205. private _computationVector;
  93206. private _tempAxisVector;
  93207. private _tempAxisRotationMatrix;
  93208. /**
  93209. * Instantiates a new ArcRotateCamera in a given scene
  93210. * @param name Defines the name of the camera
  93211. * @param alpha Defines the camera rotation along the logitudinal axis
  93212. * @param beta Defines the camera rotation along the latitudinal axis
  93213. * @param radius Defines the camera distance from its target
  93214. * @param target Defines the camera target
  93215. * @param scene Defines the scene the camera belongs to
  93216. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  93217. */
  93218. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93219. /** @hidden */
  93220. _initCache(): void;
  93221. /** @hidden */
  93222. _updateCache(ignoreParentClass?: boolean): void;
  93223. protected _getTargetPosition(): Vector3;
  93224. private _storedAlpha;
  93225. private _storedBeta;
  93226. private _storedRadius;
  93227. private _storedTarget;
  93228. /**
  93229. * Stores the current state of the camera (alpha, beta, radius and target)
  93230. * @returns the camera itself
  93231. */
  93232. storeState(): Camera;
  93233. /**
  93234. * @hidden
  93235. * Restored camera state. You must call storeState() first
  93236. */
  93237. _restoreStateValues(): boolean;
  93238. /** @hidden */
  93239. _isSynchronizedViewMatrix(): boolean;
  93240. /**
  93241. * Attached controls to the current camera.
  93242. * @param element Defines the element the controls should be listened from
  93243. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93244. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  93245. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  93246. */
  93247. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  93248. /**
  93249. * Detach the current controls from the camera.
  93250. * The camera will stop reacting to inputs.
  93251. * @param element Defines the element to stop listening the inputs from
  93252. */
  93253. detachControl(element: HTMLElement): void;
  93254. /** @hidden */
  93255. _checkInputs(): void;
  93256. protected _checkLimits(): void;
  93257. /**
  93258. * Rebuilds angles (alpha, beta) and radius from the give position and target
  93259. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  93260. */
  93261. rebuildAnglesAndRadius(updateView?: boolean): void;
  93262. /**
  93263. * Use a position to define the current camera related information like aplha, beta and radius
  93264. * @param position Defines the position to set the camera at
  93265. */
  93266. setPosition(position: Vector3): void;
  93267. /**
  93268. * Defines the target the camera should look at.
  93269. * This will automatically adapt alpha beta and radius to fit within the new target.
  93270. * @param target Defines the new target as a Vector or a mesh
  93271. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  93272. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  93273. */
  93274. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  93275. /** @hidden */
  93276. _getViewMatrix(): Matrix;
  93277. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  93278. /**
  93279. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  93280. * @param meshes Defines the mesh to zoom on
  93281. * @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)
  93282. */
  93283. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  93284. /**
  93285. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  93286. * The target will be changed but the radius
  93287. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  93288. * @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)
  93289. */
  93290. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  93291. min: Vector3;
  93292. max: Vector3;
  93293. distance: number;
  93294. }, doNotUpdateMaxZ?: boolean): void;
  93295. /**
  93296. * @override
  93297. * Override Camera.createRigCamera
  93298. */
  93299. createRigCamera(name: string, cameraIndex: number): Camera;
  93300. /**
  93301. * @hidden
  93302. * @override
  93303. * Override Camera._updateRigCameras
  93304. */
  93305. _updateRigCameras(): void;
  93306. /**
  93307. * Destroy the camera and release the current resources hold by it.
  93308. */
  93309. dispose(): void;
  93310. /**
  93311. * Gets the current object class name.
  93312. * @return the class name
  93313. */
  93314. getClassName(): string;
  93315. }
  93316. }
  93317. declare module BABYLON {
  93318. /**
  93319. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  93320. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  93321. */
  93322. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  93323. /**
  93324. * Gets the name of the behavior.
  93325. */
  93326. readonly name: string;
  93327. private _zoomStopsAnimation;
  93328. private _idleRotationSpeed;
  93329. private _idleRotationWaitTime;
  93330. private _idleRotationSpinupTime;
  93331. /**
  93332. * Sets the flag that indicates if user zooming should stop animation.
  93333. */
  93334. /**
  93335. * Gets the flag that indicates if user zooming should stop animation.
  93336. */
  93337. zoomStopsAnimation: boolean;
  93338. /**
  93339. * Sets the default speed at which the camera rotates around the model.
  93340. */
  93341. /**
  93342. * Gets the default speed at which the camera rotates around the model.
  93343. */
  93344. idleRotationSpeed: number;
  93345. /**
  93346. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  93347. */
  93348. /**
  93349. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  93350. */
  93351. idleRotationWaitTime: number;
  93352. /**
  93353. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  93354. */
  93355. /**
  93356. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  93357. */
  93358. idleRotationSpinupTime: number;
  93359. /**
  93360. * Gets a value indicating if the camera is currently rotating because of this behavior
  93361. */
  93362. readonly rotationInProgress: boolean;
  93363. private _onPrePointerObservableObserver;
  93364. private _onAfterCheckInputsObserver;
  93365. private _attachedCamera;
  93366. private _isPointerDown;
  93367. private _lastFrameTime;
  93368. private _lastInteractionTime;
  93369. private _cameraRotationSpeed;
  93370. /**
  93371. * Initializes the behavior.
  93372. */
  93373. init(): void;
  93374. /**
  93375. * Attaches the behavior to its arc rotate camera.
  93376. * @param camera Defines the camera to attach the behavior to
  93377. */
  93378. attach(camera: ArcRotateCamera): void;
  93379. /**
  93380. * Detaches the behavior from its current arc rotate camera.
  93381. */
  93382. detach(): void;
  93383. /**
  93384. * Returns true if user is scrolling.
  93385. * @return true if user is scrolling.
  93386. */
  93387. private _userIsZooming;
  93388. private _lastFrameRadius;
  93389. private _shouldAnimationStopForInteraction;
  93390. /**
  93391. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  93392. */
  93393. private _applyUserInteraction;
  93394. private _userIsMoving;
  93395. }
  93396. }
  93397. declare module BABYLON {
  93398. /**
  93399. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  93400. */
  93401. export class AttachToBoxBehavior implements Behavior<Mesh> {
  93402. private ui;
  93403. /**
  93404. * The name of the behavior
  93405. */
  93406. name: string;
  93407. /**
  93408. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  93409. */
  93410. distanceAwayFromFace: number;
  93411. /**
  93412. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  93413. */
  93414. distanceAwayFromBottomOfFace: number;
  93415. private _faceVectors;
  93416. private _target;
  93417. private _scene;
  93418. private _onRenderObserver;
  93419. private _tmpMatrix;
  93420. private _tmpVector;
  93421. /**
  93422. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  93423. * @param ui The transform node that should be attched to the mesh
  93424. */
  93425. constructor(ui: TransformNode);
  93426. /**
  93427. * Initializes the behavior
  93428. */
  93429. init(): void;
  93430. private _closestFace;
  93431. private _zeroVector;
  93432. private _lookAtTmpMatrix;
  93433. private _lookAtToRef;
  93434. /**
  93435. * Attaches the AttachToBoxBehavior to the passed in mesh
  93436. * @param target The mesh that the specified node will be attached to
  93437. */
  93438. attach(target: Mesh): void;
  93439. /**
  93440. * Detaches the behavior from the mesh
  93441. */
  93442. detach(): void;
  93443. }
  93444. }
  93445. declare module BABYLON {
  93446. /**
  93447. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  93448. */
  93449. export class FadeInOutBehavior implements Behavior<Mesh> {
  93450. /**
  93451. * Time in milliseconds to delay before fading in (Default: 0)
  93452. */
  93453. delay: number;
  93454. /**
  93455. * Time in milliseconds for the mesh to fade in (Default: 300)
  93456. */
  93457. fadeInTime: number;
  93458. private _millisecondsPerFrame;
  93459. private _hovered;
  93460. private _hoverValue;
  93461. private _ownerNode;
  93462. /**
  93463. * Instatiates the FadeInOutBehavior
  93464. */
  93465. constructor();
  93466. /**
  93467. * The name of the behavior
  93468. */
  93469. readonly name: string;
  93470. /**
  93471. * Initializes the behavior
  93472. */
  93473. init(): void;
  93474. /**
  93475. * Attaches the fade behavior on the passed in mesh
  93476. * @param ownerNode The mesh that will be faded in/out once attached
  93477. */
  93478. attach(ownerNode: Mesh): void;
  93479. /**
  93480. * Detaches the behavior from the mesh
  93481. */
  93482. detach(): void;
  93483. /**
  93484. * Triggers the mesh to begin fading in or out
  93485. * @param value if the object should fade in or out (true to fade in)
  93486. */
  93487. fadeIn(value: boolean): void;
  93488. private _update;
  93489. private _setAllVisibility;
  93490. }
  93491. }
  93492. declare module BABYLON {
  93493. /**
  93494. * Class containing a set of static utilities functions for managing Pivots
  93495. * @hidden
  93496. */
  93497. export class PivotTools {
  93498. private static _PivotCached;
  93499. private static _OldPivotPoint;
  93500. private static _PivotTranslation;
  93501. private static _PivotTmpVector;
  93502. /** @hidden */
  93503. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  93504. /** @hidden */
  93505. static _RestorePivotPoint(mesh: AbstractMesh): void;
  93506. }
  93507. }
  93508. declare module BABYLON {
  93509. /**
  93510. * Class containing static functions to help procedurally build meshes
  93511. */
  93512. export class PlaneBuilder {
  93513. /**
  93514. * Creates a plane mesh
  93515. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  93516. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  93517. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  93518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  93519. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  93520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  93521. * @param name defines the name of the mesh
  93522. * @param options defines the options used to create the mesh
  93523. * @param scene defines the hosting scene
  93524. * @returns the plane mesh
  93525. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  93526. */
  93527. static CreatePlane(name: string, options: {
  93528. size?: number;
  93529. width?: number;
  93530. height?: number;
  93531. sideOrientation?: number;
  93532. frontUVs?: Vector4;
  93533. backUVs?: Vector4;
  93534. updatable?: boolean;
  93535. sourcePlane?: Plane;
  93536. }, scene: Scene): Mesh;
  93537. }
  93538. }
  93539. declare module BABYLON {
  93540. /**
  93541. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  93542. */
  93543. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  93544. private static _AnyMouseID;
  93545. private _attachedNode;
  93546. private _dragPlane;
  93547. private _scene;
  93548. private _pointerObserver;
  93549. private _beforeRenderObserver;
  93550. private static _planeScene;
  93551. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  93552. /**
  93553. * 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)
  93554. */
  93555. maxDragAngle: number;
  93556. /**
  93557. * @hidden
  93558. */
  93559. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  93560. /**
  93561. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  93562. */
  93563. currentDraggingPointerID: number;
  93564. /**
  93565. * The last position where the pointer hit the drag plane in world space
  93566. */
  93567. lastDragPosition: Vector3;
  93568. /**
  93569. * If the behavior is currently in a dragging state
  93570. */
  93571. dragging: boolean;
  93572. /**
  93573. * 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)
  93574. */
  93575. dragDeltaRatio: number;
  93576. /**
  93577. * If the drag plane orientation should be updated during the dragging (Default: true)
  93578. */
  93579. updateDragPlane: boolean;
  93580. private _debugMode;
  93581. private _moving;
  93582. /**
  93583. * Fires each time the attached mesh is dragged with the pointer
  93584. * * delta between last drag position and current drag position in world space
  93585. * * dragDistance along the drag axis
  93586. * * dragPlaneNormal normal of the current drag plane used during the drag
  93587. * * dragPlanePoint in world space where the drag intersects the drag plane
  93588. */
  93589. onDragObservable: Observable<{
  93590. delta: Vector3;
  93591. dragPlanePoint: Vector3;
  93592. dragPlaneNormal: Vector3;
  93593. dragDistance: number;
  93594. pointerId: number;
  93595. }>;
  93596. /**
  93597. * Fires each time a drag begins (eg. mouse down on mesh)
  93598. */
  93599. onDragStartObservable: Observable<{
  93600. dragPlanePoint: Vector3;
  93601. pointerId: number;
  93602. }>;
  93603. /**
  93604. * Fires each time a drag ends (eg. mouse release after drag)
  93605. */
  93606. onDragEndObservable: Observable<{
  93607. dragPlanePoint: Vector3;
  93608. pointerId: number;
  93609. }>;
  93610. /**
  93611. * If the attached mesh should be moved when dragged
  93612. */
  93613. moveAttached: boolean;
  93614. /**
  93615. * If the drag behavior will react to drag events (Default: true)
  93616. */
  93617. enabled: boolean;
  93618. /**
  93619. * If camera controls should be detached during the drag
  93620. */
  93621. detachCameraControls: boolean;
  93622. /**
  93623. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  93624. */
  93625. useObjectOrienationForDragging: boolean;
  93626. private _options;
  93627. /**
  93628. * Creates a pointer drag behavior that can be attached to a mesh
  93629. * @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)
  93630. */
  93631. constructor(options?: {
  93632. dragAxis?: Vector3;
  93633. dragPlaneNormal?: Vector3;
  93634. });
  93635. /**
  93636. * Predicate to determine if it is valid to move the object to a new position when it is moved
  93637. */
  93638. validateDrag: (targetPosition: Vector3) => boolean;
  93639. /**
  93640. * The name of the behavior
  93641. */
  93642. readonly name: string;
  93643. /**
  93644. * Initializes the behavior
  93645. */
  93646. init(): void;
  93647. private _tmpVector;
  93648. private _alternatePickedPoint;
  93649. private _worldDragAxis;
  93650. private _targetPosition;
  93651. private _attachedElement;
  93652. /**
  93653. * Attaches the drag behavior the passed in mesh
  93654. * @param ownerNode The mesh that will be dragged around once attached
  93655. */
  93656. attach(ownerNode: AbstractMesh): void;
  93657. /**
  93658. * Force relase the drag action by code.
  93659. */
  93660. releaseDrag(): void;
  93661. private _startDragRay;
  93662. private _lastPointerRay;
  93663. /**
  93664. * Simulates the start of a pointer drag event on the behavior
  93665. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  93666. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  93667. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  93668. */
  93669. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  93670. private _startDrag;
  93671. private _dragDelta;
  93672. private _moveDrag;
  93673. private _pickWithRayOnDragPlane;
  93674. private _pointA;
  93675. private _pointB;
  93676. private _pointC;
  93677. private _lineA;
  93678. private _lineB;
  93679. private _localAxis;
  93680. private _lookAt;
  93681. private _updateDragPlanePosition;
  93682. /**
  93683. * Detaches the behavior from the mesh
  93684. */
  93685. detach(): void;
  93686. }
  93687. }
  93688. declare module BABYLON {
  93689. /**
  93690. * A behavior that when attached to a mesh will allow the mesh to be scaled
  93691. */
  93692. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  93693. private _dragBehaviorA;
  93694. private _dragBehaviorB;
  93695. private _startDistance;
  93696. private _initialScale;
  93697. private _targetScale;
  93698. private _ownerNode;
  93699. private _sceneRenderObserver;
  93700. /**
  93701. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  93702. */
  93703. constructor();
  93704. /**
  93705. * The name of the behavior
  93706. */
  93707. readonly name: string;
  93708. /**
  93709. * Initializes the behavior
  93710. */
  93711. init(): void;
  93712. private _getCurrentDistance;
  93713. /**
  93714. * Attaches the scale behavior the passed in mesh
  93715. * @param ownerNode The mesh that will be scaled around once attached
  93716. */
  93717. attach(ownerNode: Mesh): void;
  93718. /**
  93719. * Detaches the behavior from the mesh
  93720. */
  93721. detach(): void;
  93722. }
  93723. }
  93724. declare module BABYLON {
  93725. /**
  93726. * 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
  93727. */
  93728. export class SixDofDragBehavior implements Behavior<Mesh> {
  93729. private static _virtualScene;
  93730. private _ownerNode;
  93731. private _sceneRenderObserver;
  93732. private _scene;
  93733. private _targetPosition;
  93734. private _virtualOriginMesh;
  93735. private _virtualDragMesh;
  93736. private _pointerObserver;
  93737. private _moving;
  93738. private _startingOrientation;
  93739. /**
  93740. * 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)
  93741. */
  93742. private zDragFactor;
  93743. /**
  93744. * If the object should rotate to face the drag origin
  93745. */
  93746. rotateDraggedObject: boolean;
  93747. /**
  93748. * If the behavior is currently in a dragging state
  93749. */
  93750. dragging: boolean;
  93751. /**
  93752. * 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)
  93753. */
  93754. dragDeltaRatio: number;
  93755. /**
  93756. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  93757. */
  93758. currentDraggingPointerID: number;
  93759. /**
  93760. * If camera controls should be detached during the drag
  93761. */
  93762. detachCameraControls: boolean;
  93763. /**
  93764. * Fires each time a drag starts
  93765. */
  93766. onDragStartObservable: Observable<{}>;
  93767. /**
  93768. * Fires each time a drag ends (eg. mouse release after drag)
  93769. */
  93770. onDragEndObservable: Observable<{}>;
  93771. /**
  93772. * 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
  93773. */
  93774. constructor();
  93775. /**
  93776. * The name of the behavior
  93777. */
  93778. readonly name: string;
  93779. /**
  93780. * Initializes the behavior
  93781. */
  93782. init(): void;
  93783. /**
  93784. * Attaches the scale behavior the passed in mesh
  93785. * @param ownerNode The mesh that will be scaled around once attached
  93786. */
  93787. attach(ownerNode: Mesh): void;
  93788. /**
  93789. * Detaches the behavior from the mesh
  93790. */
  93791. detach(): void;
  93792. }
  93793. }
  93794. declare module BABYLON {
  93795. /**
  93796. * Class used to apply inverse kinematics to bones
  93797. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  93798. */
  93799. export class BoneIKController {
  93800. private static _tmpVecs;
  93801. private static _tmpQuat;
  93802. private static _tmpMats;
  93803. /**
  93804. * Gets or sets the target mesh
  93805. */
  93806. targetMesh: AbstractMesh;
  93807. /** Gets or sets the mesh used as pole */
  93808. poleTargetMesh: AbstractMesh;
  93809. /**
  93810. * Gets or sets the bone used as pole
  93811. */
  93812. poleTargetBone: Nullable<Bone>;
  93813. /**
  93814. * Gets or sets the target position
  93815. */
  93816. targetPosition: Vector3;
  93817. /**
  93818. * Gets or sets the pole target position
  93819. */
  93820. poleTargetPosition: Vector3;
  93821. /**
  93822. * Gets or sets the pole target local offset
  93823. */
  93824. poleTargetLocalOffset: Vector3;
  93825. /**
  93826. * Gets or sets the pole angle
  93827. */
  93828. poleAngle: number;
  93829. /**
  93830. * Gets or sets the mesh associated with the controller
  93831. */
  93832. mesh: AbstractMesh;
  93833. /**
  93834. * 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)
  93835. */
  93836. slerpAmount: number;
  93837. private _bone1Quat;
  93838. private _bone1Mat;
  93839. private _bone2Ang;
  93840. private _bone1;
  93841. private _bone2;
  93842. private _bone1Length;
  93843. private _bone2Length;
  93844. private _maxAngle;
  93845. private _maxReach;
  93846. private _rightHandedSystem;
  93847. private _bendAxis;
  93848. private _slerping;
  93849. private _adjustRoll;
  93850. /**
  93851. * Gets or sets maximum allowed angle
  93852. */
  93853. maxAngle: number;
  93854. /**
  93855. * Creates a new BoneIKController
  93856. * @param mesh defines the mesh to control
  93857. * @param bone defines the bone to control
  93858. * @param options defines options to set up the controller
  93859. */
  93860. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  93861. targetMesh?: AbstractMesh;
  93862. poleTargetMesh?: AbstractMesh;
  93863. poleTargetBone?: Bone;
  93864. poleTargetLocalOffset?: Vector3;
  93865. poleAngle?: number;
  93866. bendAxis?: Vector3;
  93867. maxAngle?: number;
  93868. slerpAmount?: number;
  93869. });
  93870. private _setMaxAngle;
  93871. /**
  93872. * Force the controller to update the bones
  93873. */
  93874. update(): void;
  93875. }
  93876. }
  93877. declare module BABYLON {
  93878. /**
  93879. * Class used to make a bone look toward a point in space
  93880. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  93881. */
  93882. export class BoneLookController {
  93883. private static _tmpVecs;
  93884. private static _tmpQuat;
  93885. private static _tmpMats;
  93886. /**
  93887. * The target Vector3 that the bone will look at
  93888. */
  93889. target: Vector3;
  93890. /**
  93891. * The mesh that the bone is attached to
  93892. */
  93893. mesh: AbstractMesh;
  93894. /**
  93895. * The bone that will be looking to the target
  93896. */
  93897. bone: Bone;
  93898. /**
  93899. * The up axis of the coordinate system that is used when the bone is rotated
  93900. */
  93901. upAxis: Vector3;
  93902. /**
  93903. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  93904. */
  93905. upAxisSpace: Space;
  93906. /**
  93907. * Used to make an adjustment to the yaw of the bone
  93908. */
  93909. adjustYaw: number;
  93910. /**
  93911. * Used to make an adjustment to the pitch of the bone
  93912. */
  93913. adjustPitch: number;
  93914. /**
  93915. * Used to make an adjustment to the roll of the bone
  93916. */
  93917. adjustRoll: number;
  93918. /**
  93919. * 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)
  93920. */
  93921. slerpAmount: number;
  93922. private _minYaw;
  93923. private _maxYaw;
  93924. private _minPitch;
  93925. private _maxPitch;
  93926. private _minYawSin;
  93927. private _minYawCos;
  93928. private _maxYawSin;
  93929. private _maxYawCos;
  93930. private _midYawConstraint;
  93931. private _minPitchTan;
  93932. private _maxPitchTan;
  93933. private _boneQuat;
  93934. private _slerping;
  93935. private _transformYawPitch;
  93936. private _transformYawPitchInv;
  93937. private _firstFrameSkipped;
  93938. private _yawRange;
  93939. private _fowardAxis;
  93940. /**
  93941. * Gets or sets the minimum yaw angle that the bone can look to
  93942. */
  93943. minYaw: number;
  93944. /**
  93945. * Gets or sets the maximum yaw angle that the bone can look to
  93946. */
  93947. maxYaw: number;
  93948. /**
  93949. * Gets or sets the minimum pitch angle that the bone can look to
  93950. */
  93951. minPitch: number;
  93952. /**
  93953. * Gets or sets the maximum pitch angle that the bone can look to
  93954. */
  93955. maxPitch: number;
  93956. /**
  93957. * Create a BoneLookController
  93958. * @param mesh the mesh that the bone belongs to
  93959. * @param bone the bone that will be looking to the target
  93960. * @param target the target Vector3 to look at
  93961. * @param options optional settings:
  93962. * * maxYaw: the maximum angle the bone will yaw to
  93963. * * minYaw: the minimum angle the bone will yaw to
  93964. * * maxPitch: the maximum angle the bone will pitch to
  93965. * * minPitch: the minimum angle the bone will yaw to
  93966. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  93967. * * upAxis: the up axis of the coordinate system
  93968. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  93969. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  93970. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  93971. * * adjustYaw: used to make an adjustment to the yaw of the bone
  93972. * * adjustPitch: used to make an adjustment to the pitch of the bone
  93973. * * adjustRoll: used to make an adjustment to the roll of the bone
  93974. **/
  93975. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  93976. maxYaw?: number;
  93977. minYaw?: number;
  93978. maxPitch?: number;
  93979. minPitch?: number;
  93980. slerpAmount?: number;
  93981. upAxis?: Vector3;
  93982. upAxisSpace?: Space;
  93983. yawAxis?: Vector3;
  93984. pitchAxis?: Vector3;
  93985. adjustYaw?: number;
  93986. adjustPitch?: number;
  93987. adjustRoll?: number;
  93988. });
  93989. /**
  93990. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  93991. */
  93992. update(): void;
  93993. private _getAngleDiff;
  93994. private _getAngleBetween;
  93995. private _isAngleBetween;
  93996. }
  93997. }
  93998. declare module BABYLON {
  93999. /**
  94000. * Manage the gamepad inputs to control an arc rotate camera.
  94001. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94002. */
  94003. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  94004. /**
  94005. * Defines the camera the input is attached to.
  94006. */
  94007. camera: ArcRotateCamera;
  94008. /**
  94009. * Defines the gamepad the input is gathering event from.
  94010. */
  94011. gamepad: Nullable<Gamepad>;
  94012. /**
  94013. * Defines the gamepad rotation sensiblity.
  94014. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  94015. */
  94016. gamepadRotationSensibility: number;
  94017. /**
  94018. * Defines the gamepad move sensiblity.
  94019. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  94020. */
  94021. gamepadMoveSensibility: number;
  94022. private _onGamepadConnectedObserver;
  94023. private _onGamepadDisconnectedObserver;
  94024. /**
  94025. * Attach the input controls to a specific dom element to get the input from.
  94026. * @param element Defines the element the controls should be listened from
  94027. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94028. */
  94029. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94030. /**
  94031. * Detach the current controls from the specified dom element.
  94032. * @param element Defines the element to stop listening the inputs from
  94033. */
  94034. detachControl(element: Nullable<HTMLElement>): void;
  94035. /**
  94036. * Update the current camera state depending on the inputs that have been used this frame.
  94037. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94038. */
  94039. checkInputs(): void;
  94040. /**
  94041. * Gets the class name of the current intput.
  94042. * @returns the class name
  94043. */
  94044. getClassName(): string;
  94045. /**
  94046. * Get the friendly name associated with the input class.
  94047. * @returns the input friendly name
  94048. */
  94049. getSimpleName(): string;
  94050. }
  94051. }
  94052. declare module BABYLON {
  94053. interface ArcRotateCameraInputsManager {
  94054. /**
  94055. * Add orientation input support to the input manager.
  94056. * @returns the current input manager
  94057. */
  94058. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  94059. }
  94060. /**
  94061. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  94062. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94063. */
  94064. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  94065. /**
  94066. * Defines the camera the input is attached to.
  94067. */
  94068. camera: ArcRotateCamera;
  94069. /**
  94070. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  94071. */
  94072. alphaCorrection: number;
  94073. /**
  94074. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  94075. */
  94076. gammaCorrection: number;
  94077. private _alpha;
  94078. private _gamma;
  94079. private _dirty;
  94080. private _deviceOrientationHandler;
  94081. /**
  94082. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  94083. */
  94084. constructor();
  94085. /**
  94086. * Attach the input controls to a specific dom element to get the input from.
  94087. * @param element Defines the element the controls should be listened from
  94088. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94089. */
  94090. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94091. /** @hidden */
  94092. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  94093. /**
  94094. * Update the current camera state depending on the inputs that have been used this frame.
  94095. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94096. */
  94097. checkInputs(): void;
  94098. /**
  94099. * Detach the current controls from the specified dom element.
  94100. * @param element Defines the element to stop listening the inputs from
  94101. */
  94102. detachControl(element: Nullable<HTMLElement>): void;
  94103. /**
  94104. * Gets the class name of the current intput.
  94105. * @returns the class name
  94106. */
  94107. getClassName(): string;
  94108. /**
  94109. * Get the friendly name associated with the input class.
  94110. * @returns the input friendly name
  94111. */
  94112. getSimpleName(): string;
  94113. }
  94114. }
  94115. declare module BABYLON {
  94116. /**
  94117. * Listen to mouse events to control the camera.
  94118. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94119. */
  94120. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  94121. /**
  94122. * Defines the camera the input is attached to.
  94123. */
  94124. camera: FlyCamera;
  94125. /**
  94126. * Defines if touch is enabled. (Default is true.)
  94127. */
  94128. touchEnabled: boolean;
  94129. /**
  94130. * Defines the buttons associated with the input to handle camera rotation.
  94131. */
  94132. buttons: number[];
  94133. /**
  94134. * Assign buttons for Yaw control.
  94135. */
  94136. buttonsYaw: number[];
  94137. /**
  94138. * Assign buttons for Pitch control.
  94139. */
  94140. buttonsPitch: number[];
  94141. /**
  94142. * Assign buttons for Roll control.
  94143. */
  94144. buttonsRoll: number[];
  94145. /**
  94146. * Detect if any button is being pressed while mouse is moved.
  94147. * -1 = Mouse locked.
  94148. * 0 = Left button.
  94149. * 1 = Middle Button.
  94150. * 2 = Right Button.
  94151. */
  94152. activeButton: number;
  94153. /**
  94154. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  94155. * Higher values reduce its sensitivity.
  94156. */
  94157. angularSensibility: number;
  94158. private _mousemoveCallback;
  94159. private _observer;
  94160. private _rollObserver;
  94161. private previousPosition;
  94162. private noPreventDefault;
  94163. private element;
  94164. /**
  94165. * Listen to mouse events to control the camera.
  94166. * @param touchEnabled Define if touch is enabled. (Default is true.)
  94167. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94168. */
  94169. constructor(touchEnabled?: boolean);
  94170. /**
  94171. * Attach the mouse control to the HTML DOM element.
  94172. * @param element Defines the element that listens to the input events.
  94173. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  94174. */
  94175. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94176. /**
  94177. * Detach the current controls from the specified dom element.
  94178. * @param element Defines the element to stop listening the inputs from
  94179. */
  94180. detachControl(element: Nullable<HTMLElement>): void;
  94181. /**
  94182. * Gets the class name of the current input.
  94183. * @returns the class name.
  94184. */
  94185. getClassName(): string;
  94186. /**
  94187. * Get the friendly name associated with the input class.
  94188. * @returns the input's friendly name.
  94189. */
  94190. getSimpleName(): string;
  94191. private _pointerInput;
  94192. private _onMouseMove;
  94193. /**
  94194. * Rotate camera by mouse offset.
  94195. */
  94196. private rotateCamera;
  94197. }
  94198. }
  94199. declare module BABYLON {
  94200. /**
  94201. * Default Inputs manager for the FlyCamera.
  94202. * It groups all the default supported inputs for ease of use.
  94203. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94204. */
  94205. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  94206. /**
  94207. * Instantiates a new FlyCameraInputsManager.
  94208. * @param camera Defines the camera the inputs belong to.
  94209. */
  94210. constructor(camera: FlyCamera);
  94211. /**
  94212. * Add keyboard input support to the input manager.
  94213. * @returns the new FlyCameraKeyboardMoveInput().
  94214. */
  94215. addKeyboard(): FlyCameraInputsManager;
  94216. /**
  94217. * Add mouse input support to the input manager.
  94218. * @param touchEnabled Enable touch screen support.
  94219. * @returns the new FlyCameraMouseInput().
  94220. */
  94221. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  94222. }
  94223. }
  94224. declare module BABYLON {
  94225. /**
  94226. * This is a flying camera, designed for 3D movement and rotation in all directions,
  94227. * such as in a 3D Space Shooter or a Flight Simulator.
  94228. */
  94229. export class FlyCamera extends TargetCamera {
  94230. /**
  94231. * Define the collision ellipsoid of the camera.
  94232. * This is helpful for simulating a camera body, like a player's body.
  94233. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  94234. */
  94235. ellipsoid: Vector3;
  94236. /**
  94237. * Define an offset for the position of the ellipsoid around the camera.
  94238. * This can be helpful if the camera is attached away from the player's body center,
  94239. * such as at its head.
  94240. */
  94241. ellipsoidOffset: Vector3;
  94242. /**
  94243. * Enable or disable collisions of the camera with the rest of the scene objects.
  94244. */
  94245. checkCollisions: boolean;
  94246. /**
  94247. * Enable or disable gravity on the camera.
  94248. */
  94249. applyGravity: boolean;
  94250. /**
  94251. * Define the current direction the camera is moving to.
  94252. */
  94253. cameraDirection: Vector3;
  94254. /**
  94255. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  94256. * This overrides and empties cameraRotation.
  94257. */
  94258. rotationQuaternion: Quaternion;
  94259. /**
  94260. * Track Roll to maintain the wanted Rolling when looking around.
  94261. */
  94262. _trackRoll: number;
  94263. /**
  94264. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  94265. */
  94266. rollCorrect: number;
  94267. /**
  94268. * Mimic a banked turn, Rolling the camera when Yawing.
  94269. * It's recommended to use rollCorrect = 10 for faster banking correction.
  94270. */
  94271. bankedTurn: boolean;
  94272. /**
  94273. * Limit in radians for how much Roll banking will add. (Default: 90°)
  94274. */
  94275. bankedTurnLimit: number;
  94276. /**
  94277. * Value of 0 disables the banked Roll.
  94278. * Value of 1 is equal to the Yaw angle in radians.
  94279. */
  94280. bankedTurnMultiplier: number;
  94281. /**
  94282. * The inputs manager loads all the input sources, such as keyboard and mouse.
  94283. */
  94284. inputs: FlyCameraInputsManager;
  94285. /**
  94286. * Gets the input sensibility for mouse input.
  94287. * Higher values reduce sensitivity.
  94288. */
  94289. /**
  94290. * Sets the input sensibility for a mouse input.
  94291. * Higher values reduce sensitivity.
  94292. */
  94293. angularSensibility: number;
  94294. /**
  94295. * Get the keys for camera movement forward.
  94296. */
  94297. /**
  94298. * Set the keys for camera movement forward.
  94299. */
  94300. keysForward: number[];
  94301. /**
  94302. * Get the keys for camera movement backward.
  94303. */
  94304. keysBackward: number[];
  94305. /**
  94306. * Get the keys for camera movement up.
  94307. */
  94308. /**
  94309. * Set the keys for camera movement up.
  94310. */
  94311. keysUp: number[];
  94312. /**
  94313. * Get the keys for camera movement down.
  94314. */
  94315. /**
  94316. * Set the keys for camera movement down.
  94317. */
  94318. keysDown: number[];
  94319. /**
  94320. * Get the keys for camera movement left.
  94321. */
  94322. /**
  94323. * Set the keys for camera movement left.
  94324. */
  94325. keysLeft: number[];
  94326. /**
  94327. * Set the keys for camera movement right.
  94328. */
  94329. /**
  94330. * Set the keys for camera movement right.
  94331. */
  94332. keysRight: number[];
  94333. /**
  94334. * Event raised when the camera collides with a mesh in the scene.
  94335. */
  94336. onCollide: (collidedMesh: AbstractMesh) => void;
  94337. private _collider;
  94338. private _needMoveForGravity;
  94339. private _oldPosition;
  94340. private _diffPosition;
  94341. private _newPosition;
  94342. /** @hidden */
  94343. _localDirection: Vector3;
  94344. /** @hidden */
  94345. _transformedDirection: Vector3;
  94346. /**
  94347. * Instantiates a FlyCamera.
  94348. * This is a flying camera, designed for 3D movement and rotation in all directions,
  94349. * such as in a 3D Space Shooter or a Flight Simulator.
  94350. * @param name Define the name of the camera in the scene.
  94351. * @param position Define the starting position of the camera in the scene.
  94352. * @param scene Define the scene the camera belongs to.
  94353. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  94354. */
  94355. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94356. /**
  94357. * Attach a control to the HTML DOM element.
  94358. * @param element Defines the element that listens to the input events.
  94359. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  94360. */
  94361. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94362. /**
  94363. * Detach a control from the HTML DOM element.
  94364. * The camera will stop reacting to that input.
  94365. * @param element Defines the element that listens to the input events.
  94366. */
  94367. detachControl(element: HTMLElement): void;
  94368. private _collisionMask;
  94369. /**
  94370. * Get the mask that the camera ignores in collision events.
  94371. */
  94372. /**
  94373. * Set the mask that the camera ignores in collision events.
  94374. */
  94375. collisionMask: number;
  94376. /** @hidden */
  94377. _collideWithWorld(displacement: Vector3): void;
  94378. /** @hidden */
  94379. private _onCollisionPositionChange;
  94380. /** @hidden */
  94381. _checkInputs(): void;
  94382. /** @hidden */
  94383. _decideIfNeedsToMove(): boolean;
  94384. /** @hidden */
  94385. _updatePosition(): void;
  94386. /**
  94387. * Restore the Roll to its target value at the rate specified.
  94388. * @param rate - Higher means slower restoring.
  94389. * @hidden
  94390. */
  94391. restoreRoll(rate: number): void;
  94392. /**
  94393. * Destroy the camera and release the current resources held by it.
  94394. */
  94395. dispose(): void;
  94396. /**
  94397. * Get the current object class name.
  94398. * @returns the class name.
  94399. */
  94400. getClassName(): string;
  94401. }
  94402. }
  94403. declare module BABYLON {
  94404. /**
  94405. * Listen to keyboard events to control the camera.
  94406. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94407. */
  94408. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  94409. /**
  94410. * Defines the camera the input is attached to.
  94411. */
  94412. camera: FlyCamera;
  94413. /**
  94414. * The list of keyboard keys used to control the forward move of the camera.
  94415. */
  94416. keysForward: number[];
  94417. /**
  94418. * The list of keyboard keys used to control the backward move of the camera.
  94419. */
  94420. keysBackward: number[];
  94421. /**
  94422. * The list of keyboard keys used to control the forward move of the camera.
  94423. */
  94424. keysUp: number[];
  94425. /**
  94426. * The list of keyboard keys used to control the backward move of the camera.
  94427. */
  94428. keysDown: number[];
  94429. /**
  94430. * The list of keyboard keys used to control the right strafe move of the camera.
  94431. */
  94432. keysRight: number[];
  94433. /**
  94434. * The list of keyboard keys used to control the left strafe move of the camera.
  94435. */
  94436. keysLeft: number[];
  94437. private _keys;
  94438. private _onCanvasBlurObserver;
  94439. private _onKeyboardObserver;
  94440. private _engine;
  94441. private _scene;
  94442. /**
  94443. * Attach the input controls to a specific dom element to get the input from.
  94444. * @param element Defines the element the controls should be listened from
  94445. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94446. */
  94447. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94448. /**
  94449. * Detach the current controls from the specified dom element.
  94450. * @param element Defines the element to stop listening the inputs from
  94451. */
  94452. detachControl(element: Nullable<HTMLElement>): void;
  94453. /**
  94454. * Gets the class name of the current intput.
  94455. * @returns the class name
  94456. */
  94457. getClassName(): string;
  94458. /** @hidden */
  94459. _onLostFocus(e: FocusEvent): void;
  94460. /**
  94461. * Get the friendly name associated with the input class.
  94462. * @returns the input friendly name
  94463. */
  94464. getSimpleName(): string;
  94465. /**
  94466. * Update the current camera state depending on the inputs that have been used this frame.
  94467. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94468. */
  94469. checkInputs(): void;
  94470. }
  94471. }
  94472. declare module BABYLON {
  94473. /**
  94474. * Manage the mouse wheel inputs to control a follow camera.
  94475. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94476. */
  94477. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  94478. /**
  94479. * Defines the camera the input is attached to.
  94480. */
  94481. camera: FollowCamera;
  94482. /**
  94483. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  94484. */
  94485. axisControlRadius: boolean;
  94486. /**
  94487. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  94488. */
  94489. axisControlHeight: boolean;
  94490. /**
  94491. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  94492. */
  94493. axisControlRotation: boolean;
  94494. /**
  94495. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  94496. * relation to mouseWheel events.
  94497. */
  94498. wheelPrecision: number;
  94499. /**
  94500. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  94501. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  94502. */
  94503. wheelDeltaPercentage: number;
  94504. private _wheel;
  94505. private _observer;
  94506. /**
  94507. * Attach the input controls to a specific dom element to get the input from.
  94508. * @param element Defines the element the controls should be listened from
  94509. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94510. */
  94511. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94512. /**
  94513. * Detach the current controls from the specified dom element.
  94514. * @param element Defines the element to stop listening the inputs from
  94515. */
  94516. detachControl(element: Nullable<HTMLElement>): void;
  94517. /**
  94518. * Gets the class name of the current intput.
  94519. * @returns the class name
  94520. */
  94521. getClassName(): string;
  94522. /**
  94523. * Get the friendly name associated with the input class.
  94524. * @returns the input friendly name
  94525. */
  94526. getSimpleName(): string;
  94527. }
  94528. }
  94529. declare module BABYLON {
  94530. /**
  94531. * Manage the pointers inputs to control an follow camera.
  94532. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94533. */
  94534. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  94535. /**
  94536. * Defines the camera the input is attached to.
  94537. */
  94538. camera: FollowCamera;
  94539. /**
  94540. * Gets the class name of the current input.
  94541. * @returns the class name
  94542. */
  94543. getClassName(): string;
  94544. /**
  94545. * Defines the pointer angular sensibility along the X axis or how fast is
  94546. * the camera rotating.
  94547. * A negative number will reverse the axis direction.
  94548. */
  94549. angularSensibilityX: number;
  94550. /**
  94551. * Defines the pointer angular sensibility along the Y axis or how fast is
  94552. * the camera rotating.
  94553. * A negative number will reverse the axis direction.
  94554. */
  94555. angularSensibilityY: number;
  94556. /**
  94557. * Defines the pointer pinch precision or how fast is the camera zooming.
  94558. * A negative number will reverse the axis direction.
  94559. */
  94560. pinchPrecision: number;
  94561. /**
  94562. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  94563. * from 0.
  94564. * It defines the percentage of current camera.radius to use as delta when
  94565. * pinch zoom is used.
  94566. */
  94567. pinchDeltaPercentage: number;
  94568. /**
  94569. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  94570. */
  94571. axisXControlRadius: boolean;
  94572. /**
  94573. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  94574. */
  94575. axisXControlHeight: boolean;
  94576. /**
  94577. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  94578. */
  94579. axisXControlRotation: boolean;
  94580. /**
  94581. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  94582. */
  94583. axisYControlRadius: boolean;
  94584. /**
  94585. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  94586. */
  94587. axisYControlHeight: boolean;
  94588. /**
  94589. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  94590. */
  94591. axisYControlRotation: boolean;
  94592. /**
  94593. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  94594. */
  94595. axisPinchControlRadius: boolean;
  94596. /**
  94597. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  94598. */
  94599. axisPinchControlHeight: boolean;
  94600. /**
  94601. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  94602. */
  94603. axisPinchControlRotation: boolean;
  94604. /**
  94605. * Log error messages if basic misconfiguration has occurred.
  94606. */
  94607. warningEnable: boolean;
  94608. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94609. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94610. private _warningCounter;
  94611. private _warning;
  94612. }
  94613. }
  94614. declare module BABYLON {
  94615. /**
  94616. * Default Inputs manager for the FollowCamera.
  94617. * It groups all the default supported inputs for ease of use.
  94618. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94619. */
  94620. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  94621. /**
  94622. * Instantiates a new FollowCameraInputsManager.
  94623. * @param camera Defines the camera the inputs belong to
  94624. */
  94625. constructor(camera: FollowCamera);
  94626. /**
  94627. * Add keyboard input support to the input manager.
  94628. * @returns the current input manager
  94629. */
  94630. addKeyboard(): FollowCameraInputsManager;
  94631. /**
  94632. * Add mouse wheel input support to the input manager.
  94633. * @returns the current input manager
  94634. */
  94635. addMouseWheel(): FollowCameraInputsManager;
  94636. /**
  94637. * Add pointers input support to the input manager.
  94638. * @returns the current input manager
  94639. */
  94640. addPointers(): FollowCameraInputsManager;
  94641. /**
  94642. * Add orientation input support to the input manager.
  94643. * @returns the current input manager
  94644. */
  94645. addVRDeviceOrientation(): FollowCameraInputsManager;
  94646. }
  94647. }
  94648. declare module BABYLON {
  94649. /**
  94650. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  94651. * an arc rotate version arcFollowCamera are available.
  94652. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  94653. */
  94654. export class FollowCamera extends TargetCamera {
  94655. /**
  94656. * Distance the follow camera should follow an object at
  94657. */
  94658. radius: number;
  94659. /**
  94660. * Minimum allowed distance of the camera to the axis of rotation
  94661. * (The camera can not get closer).
  94662. * This can help limiting how the Camera is able to move in the scene.
  94663. */
  94664. lowerRadiusLimit: Nullable<number>;
  94665. /**
  94666. * Maximum allowed distance of the camera to the axis of rotation
  94667. * (The camera can not get further).
  94668. * This can help limiting how the Camera is able to move in the scene.
  94669. */
  94670. upperRadiusLimit: Nullable<number>;
  94671. /**
  94672. * Define a rotation offset between the camera and the object it follows
  94673. */
  94674. rotationOffset: number;
  94675. /**
  94676. * Minimum allowed angle to camera position relative to target object.
  94677. * This can help limiting how the Camera is able to move in the scene.
  94678. */
  94679. lowerRotationOffsetLimit: Nullable<number>;
  94680. /**
  94681. * Maximum allowed angle to camera position relative to target object.
  94682. * This can help limiting how the Camera is able to move in the scene.
  94683. */
  94684. upperRotationOffsetLimit: Nullable<number>;
  94685. /**
  94686. * Define a height offset between the camera and the object it follows.
  94687. * It can help following an object from the top (like a car chaing a plane)
  94688. */
  94689. heightOffset: number;
  94690. /**
  94691. * Minimum allowed height of camera position relative to target object.
  94692. * This can help limiting how the Camera is able to move in the scene.
  94693. */
  94694. lowerHeightOffsetLimit: Nullable<number>;
  94695. /**
  94696. * Maximum allowed height of camera position relative to target object.
  94697. * This can help limiting how the Camera is able to move in the scene.
  94698. */
  94699. upperHeightOffsetLimit: Nullable<number>;
  94700. /**
  94701. * Define how fast the camera can accelerate to follow it s target.
  94702. */
  94703. cameraAcceleration: number;
  94704. /**
  94705. * Define the speed limit of the camera following an object.
  94706. */
  94707. maxCameraSpeed: number;
  94708. /**
  94709. * Define the target of the camera.
  94710. */
  94711. lockedTarget: Nullable<AbstractMesh>;
  94712. /**
  94713. * Defines the input associated with the camera.
  94714. */
  94715. inputs: FollowCameraInputsManager;
  94716. /**
  94717. * Instantiates the follow camera.
  94718. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  94719. * @param name Define the name of the camera in the scene
  94720. * @param position Define the position of the camera
  94721. * @param scene Define the scene the camera belong to
  94722. * @param lockedTarget Define the target of the camera
  94723. */
  94724. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  94725. private _follow;
  94726. /**
  94727. * Attached controls to the current camera.
  94728. * @param element Defines the element the controls should be listened from
  94729. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94730. */
  94731. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94732. /**
  94733. * Detach the current controls from the camera.
  94734. * The camera will stop reacting to inputs.
  94735. * @param element Defines the element to stop listening the inputs from
  94736. */
  94737. detachControl(element: HTMLElement): void;
  94738. /** @hidden */
  94739. _checkInputs(): void;
  94740. private _checkLimits;
  94741. /**
  94742. * Gets the camera class name.
  94743. * @returns the class name
  94744. */
  94745. getClassName(): string;
  94746. }
  94747. /**
  94748. * Arc Rotate version of the follow camera.
  94749. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  94750. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  94751. */
  94752. export class ArcFollowCamera extends TargetCamera {
  94753. /** The longitudinal angle of the camera */
  94754. alpha: number;
  94755. /** The latitudinal angle of the camera */
  94756. beta: number;
  94757. /** The radius of the camera from its target */
  94758. radius: number;
  94759. /** Define the camera target (the messh it should follow) */
  94760. target: Nullable<AbstractMesh>;
  94761. private _cartesianCoordinates;
  94762. /**
  94763. * Instantiates a new ArcFollowCamera
  94764. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  94765. * @param name Define the name of the camera
  94766. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  94767. * @param beta Define the rotation angle of the camera around the elevation axis
  94768. * @param radius Define the radius of the camera from its target point
  94769. * @param target Define the target of the camera
  94770. * @param scene Define the scene the camera belongs to
  94771. */
  94772. constructor(name: string,
  94773. /** The longitudinal angle of the camera */
  94774. alpha: number,
  94775. /** The latitudinal angle of the camera */
  94776. beta: number,
  94777. /** The radius of the camera from its target */
  94778. radius: number,
  94779. /** Define the camera target (the messh it should follow) */
  94780. target: Nullable<AbstractMesh>, scene: Scene);
  94781. private _follow;
  94782. /** @hidden */
  94783. _checkInputs(): void;
  94784. /**
  94785. * Returns the class name of the object.
  94786. * It is mostly used internally for serialization purposes.
  94787. */
  94788. getClassName(): string;
  94789. }
  94790. }
  94791. declare module BABYLON {
  94792. /**
  94793. * Manage the keyboard inputs to control the movement of a follow camera.
  94794. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94795. */
  94796. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  94797. /**
  94798. * Defines the camera the input is attached to.
  94799. */
  94800. camera: FollowCamera;
  94801. /**
  94802. * Defines the list of key codes associated with the up action (increase heightOffset)
  94803. */
  94804. keysHeightOffsetIncr: number[];
  94805. /**
  94806. * Defines the list of key codes associated with the down action (decrease heightOffset)
  94807. */
  94808. keysHeightOffsetDecr: number[];
  94809. /**
  94810. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  94811. */
  94812. keysHeightOffsetModifierAlt: boolean;
  94813. /**
  94814. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  94815. */
  94816. keysHeightOffsetModifierCtrl: boolean;
  94817. /**
  94818. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  94819. */
  94820. keysHeightOffsetModifierShift: boolean;
  94821. /**
  94822. * Defines the list of key codes associated with the left action (increase rotationOffset)
  94823. */
  94824. keysRotationOffsetIncr: number[];
  94825. /**
  94826. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  94827. */
  94828. keysRotationOffsetDecr: number[];
  94829. /**
  94830. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  94831. */
  94832. keysRotationOffsetModifierAlt: boolean;
  94833. /**
  94834. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  94835. */
  94836. keysRotationOffsetModifierCtrl: boolean;
  94837. /**
  94838. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  94839. */
  94840. keysRotationOffsetModifierShift: boolean;
  94841. /**
  94842. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  94843. */
  94844. keysRadiusIncr: number[];
  94845. /**
  94846. * Defines the list of key codes associated with the zoom-out action (increase radius)
  94847. */
  94848. keysRadiusDecr: number[];
  94849. /**
  94850. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  94851. */
  94852. keysRadiusModifierAlt: boolean;
  94853. /**
  94854. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  94855. */
  94856. keysRadiusModifierCtrl: boolean;
  94857. /**
  94858. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  94859. */
  94860. keysRadiusModifierShift: boolean;
  94861. /**
  94862. * Defines the rate of change of heightOffset.
  94863. */
  94864. heightSensibility: number;
  94865. /**
  94866. * Defines the rate of change of rotationOffset.
  94867. */
  94868. rotationSensibility: number;
  94869. /**
  94870. * Defines the rate of change of radius.
  94871. */
  94872. radiusSensibility: number;
  94873. private _keys;
  94874. private _ctrlPressed;
  94875. private _altPressed;
  94876. private _shiftPressed;
  94877. private _onCanvasBlurObserver;
  94878. private _onKeyboardObserver;
  94879. private _engine;
  94880. private _scene;
  94881. /**
  94882. * Attach the input controls to a specific dom element to get the input from.
  94883. * @param element Defines the element the controls should be listened from
  94884. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94885. */
  94886. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94887. /**
  94888. * Detach the current controls from the specified dom element.
  94889. * @param element Defines the element to stop listening the inputs from
  94890. */
  94891. detachControl(element: Nullable<HTMLElement>): void;
  94892. /**
  94893. * Update the current camera state depending on the inputs that have been used this frame.
  94894. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94895. */
  94896. checkInputs(): void;
  94897. /**
  94898. * Gets the class name of the current input.
  94899. * @returns the class name
  94900. */
  94901. getClassName(): string;
  94902. /**
  94903. * Get the friendly name associated with the input class.
  94904. * @returns the input friendly name
  94905. */
  94906. getSimpleName(): string;
  94907. /**
  94908. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  94909. * allow modification of the heightOffset value.
  94910. */
  94911. private _modifierHeightOffset;
  94912. /**
  94913. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  94914. * allow modification of the rotationOffset value.
  94915. */
  94916. private _modifierRotationOffset;
  94917. /**
  94918. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  94919. * allow modification of the radius value.
  94920. */
  94921. private _modifierRadius;
  94922. }
  94923. }
  94924. declare module BABYLON {
  94925. interface FreeCameraInputsManager {
  94926. /**
  94927. * Add orientation input support to the input manager.
  94928. * @returns the current input manager
  94929. */
  94930. addDeviceOrientation(): FreeCameraInputsManager;
  94931. }
  94932. /**
  94933. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  94934. * Screen rotation is taken into account.
  94935. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94936. */
  94937. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  94938. private _camera;
  94939. private _screenOrientationAngle;
  94940. private _constantTranform;
  94941. private _screenQuaternion;
  94942. private _alpha;
  94943. private _beta;
  94944. private _gamma;
  94945. /**
  94946. * Instantiates a new input
  94947. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94948. */
  94949. constructor();
  94950. /**
  94951. * Define the camera controlled by the input.
  94952. */
  94953. camera: FreeCamera;
  94954. /**
  94955. * Attach the input controls to a specific dom element to get the input from.
  94956. * @param element Defines the element the controls should be listened from
  94957. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94958. */
  94959. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94960. private _orientationChanged;
  94961. private _deviceOrientation;
  94962. /**
  94963. * Detach the current controls from the specified dom element.
  94964. * @param element Defines the element to stop listening the inputs from
  94965. */
  94966. detachControl(element: Nullable<HTMLElement>): void;
  94967. /**
  94968. * Update the current camera state depending on the inputs that have been used this frame.
  94969. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94970. */
  94971. checkInputs(): void;
  94972. /**
  94973. * Gets the class name of the current intput.
  94974. * @returns the class name
  94975. */
  94976. getClassName(): string;
  94977. /**
  94978. * Get the friendly name associated with the input class.
  94979. * @returns the input friendly name
  94980. */
  94981. getSimpleName(): string;
  94982. }
  94983. }
  94984. declare module BABYLON {
  94985. /**
  94986. * Manage the gamepad inputs to control a free camera.
  94987. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94988. */
  94989. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  94990. /**
  94991. * Define the camera the input is attached to.
  94992. */
  94993. camera: FreeCamera;
  94994. /**
  94995. * Define the Gamepad controlling the input
  94996. */
  94997. gamepad: Nullable<Gamepad>;
  94998. /**
  94999. * Defines the gamepad rotation sensiblity.
  95000. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95001. */
  95002. gamepadAngularSensibility: number;
  95003. /**
  95004. * Defines the gamepad move sensiblity.
  95005. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95006. */
  95007. gamepadMoveSensibility: number;
  95008. private _onGamepadConnectedObserver;
  95009. private _onGamepadDisconnectedObserver;
  95010. private _cameraTransform;
  95011. private _deltaTransform;
  95012. private _vector3;
  95013. private _vector2;
  95014. /**
  95015. * Attach the input controls to a specific dom element to get the input from.
  95016. * @param element Defines the element the controls should be listened from
  95017. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95018. */
  95019. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95020. /**
  95021. * Detach the current controls from the specified dom element.
  95022. * @param element Defines the element to stop listening the inputs from
  95023. */
  95024. detachControl(element: Nullable<HTMLElement>): void;
  95025. /**
  95026. * Update the current camera state depending on the inputs that have been used this frame.
  95027. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95028. */
  95029. checkInputs(): void;
  95030. /**
  95031. * Gets the class name of the current intput.
  95032. * @returns the class name
  95033. */
  95034. getClassName(): string;
  95035. /**
  95036. * Get the friendly name associated with the input class.
  95037. * @returns the input friendly name
  95038. */
  95039. getSimpleName(): string;
  95040. }
  95041. }
  95042. declare module BABYLON {
  95043. /**
  95044. * Defines the potential axis of a Joystick
  95045. */
  95046. export enum JoystickAxis {
  95047. /** X axis */
  95048. X = 0,
  95049. /** Y axis */
  95050. Y = 1,
  95051. /** Z axis */
  95052. Z = 2
  95053. }
  95054. /**
  95055. * Class used to define virtual joystick (used in touch mode)
  95056. */
  95057. export class VirtualJoystick {
  95058. /**
  95059. * Gets or sets a boolean indicating that left and right values must be inverted
  95060. */
  95061. reverseLeftRight: boolean;
  95062. /**
  95063. * Gets or sets a boolean indicating that up and down values must be inverted
  95064. */
  95065. reverseUpDown: boolean;
  95066. /**
  95067. * Gets the offset value for the position (ie. the change of the position value)
  95068. */
  95069. deltaPosition: Vector3;
  95070. /**
  95071. * Gets a boolean indicating if the virtual joystick was pressed
  95072. */
  95073. pressed: boolean;
  95074. /**
  95075. * Canvas the virtual joystick will render onto, default z-index of this is 5
  95076. */
  95077. static Canvas: Nullable<HTMLCanvasElement>;
  95078. private static _globalJoystickIndex;
  95079. private static vjCanvasContext;
  95080. private static vjCanvasWidth;
  95081. private static vjCanvasHeight;
  95082. private static halfWidth;
  95083. private _action;
  95084. private _axisTargetedByLeftAndRight;
  95085. private _axisTargetedByUpAndDown;
  95086. private _joystickSensibility;
  95087. private _inversedSensibility;
  95088. private _joystickPointerID;
  95089. private _joystickColor;
  95090. private _joystickPointerPos;
  95091. private _joystickPreviousPointerPos;
  95092. private _joystickPointerStartPos;
  95093. private _deltaJoystickVector;
  95094. private _leftJoystick;
  95095. private _touches;
  95096. private _onPointerDownHandlerRef;
  95097. private _onPointerMoveHandlerRef;
  95098. private _onPointerUpHandlerRef;
  95099. private _onResize;
  95100. /**
  95101. * Creates a new virtual joystick
  95102. * @param leftJoystick defines that the joystick is for left hand (false by default)
  95103. */
  95104. constructor(leftJoystick?: boolean);
  95105. /**
  95106. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  95107. * @param newJoystickSensibility defines the new sensibility
  95108. */
  95109. setJoystickSensibility(newJoystickSensibility: number): void;
  95110. private _onPointerDown;
  95111. private _onPointerMove;
  95112. private _onPointerUp;
  95113. /**
  95114. * Change the color of the virtual joystick
  95115. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  95116. */
  95117. setJoystickColor(newColor: string): void;
  95118. /**
  95119. * Defines a callback to call when the joystick is touched
  95120. * @param action defines the callback
  95121. */
  95122. setActionOnTouch(action: () => any): void;
  95123. /**
  95124. * Defines which axis you'd like to control for left & right
  95125. * @param axis defines the axis to use
  95126. */
  95127. setAxisForLeftRight(axis: JoystickAxis): void;
  95128. /**
  95129. * Defines which axis you'd like to control for up & down
  95130. * @param axis defines the axis to use
  95131. */
  95132. setAxisForUpDown(axis: JoystickAxis): void;
  95133. private _drawVirtualJoystick;
  95134. /**
  95135. * Release internal HTML canvas
  95136. */
  95137. releaseCanvas(): void;
  95138. }
  95139. }
  95140. declare module BABYLON {
  95141. interface FreeCameraInputsManager {
  95142. /**
  95143. * Add virtual joystick input support to the input manager.
  95144. * @returns the current input manager
  95145. */
  95146. addVirtualJoystick(): FreeCameraInputsManager;
  95147. }
  95148. /**
  95149. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  95150. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95151. */
  95152. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  95153. /**
  95154. * Defines the camera the input is attached to.
  95155. */
  95156. camera: FreeCamera;
  95157. private _leftjoystick;
  95158. private _rightjoystick;
  95159. /**
  95160. * Gets the left stick of the virtual joystick.
  95161. * @returns The virtual Joystick
  95162. */
  95163. getLeftJoystick(): VirtualJoystick;
  95164. /**
  95165. * Gets the right stick of the virtual joystick.
  95166. * @returns The virtual Joystick
  95167. */
  95168. getRightJoystick(): VirtualJoystick;
  95169. /**
  95170. * Update the current camera state depending on the inputs that have been used this frame.
  95171. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95172. */
  95173. checkInputs(): void;
  95174. /**
  95175. * Attach the input controls to a specific dom element to get the input from.
  95176. * @param element Defines the element the controls should be listened from
  95177. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95178. */
  95179. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95180. /**
  95181. * Detach the current controls from the specified dom element.
  95182. * @param element Defines the element to stop listening the inputs from
  95183. */
  95184. detachControl(element: Nullable<HTMLElement>): void;
  95185. /**
  95186. * Gets the class name of the current intput.
  95187. * @returns the class name
  95188. */
  95189. getClassName(): string;
  95190. /**
  95191. * Get the friendly name associated with the input class.
  95192. * @returns the input friendly name
  95193. */
  95194. getSimpleName(): string;
  95195. }
  95196. }
  95197. declare module BABYLON {
  95198. /**
  95199. * This represents a FPS type of camera controlled by touch.
  95200. * This is like a universal camera minus the Gamepad controls.
  95201. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95202. */
  95203. export class TouchCamera extends FreeCamera {
  95204. /**
  95205. * Defines the touch sensibility for rotation.
  95206. * The higher the faster.
  95207. */
  95208. touchAngularSensibility: number;
  95209. /**
  95210. * Defines the touch sensibility for move.
  95211. * The higher the faster.
  95212. */
  95213. touchMoveSensibility: number;
  95214. /**
  95215. * Instantiates a new touch camera.
  95216. * This represents a FPS type of camera controlled by touch.
  95217. * This is like a universal camera minus the Gamepad controls.
  95218. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95219. * @param name Define the name of the camera in the scene
  95220. * @param position Define the start position of the camera in the scene
  95221. * @param scene Define the scene the camera belongs to
  95222. */
  95223. constructor(name: string, position: Vector3, scene: Scene);
  95224. /**
  95225. * Gets the current object class name.
  95226. * @return the class name
  95227. */
  95228. getClassName(): string;
  95229. /** @hidden */
  95230. _setupInputs(): void;
  95231. }
  95232. }
  95233. declare module BABYLON {
  95234. /**
  95235. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  95236. * being tilted forward or back and left or right.
  95237. */
  95238. export class DeviceOrientationCamera extends FreeCamera {
  95239. private _initialQuaternion;
  95240. private _quaternionCache;
  95241. /**
  95242. * Creates a new device orientation camera
  95243. * @param name The name of the camera
  95244. * @param position The start position camera
  95245. * @param scene The scene the camera belongs to
  95246. */
  95247. constructor(name: string, position: Vector3, scene: Scene);
  95248. /**
  95249. * Gets the current instance class name ("DeviceOrientationCamera").
  95250. * This helps avoiding instanceof at run time.
  95251. * @returns the class name
  95252. */
  95253. getClassName(): string;
  95254. /**
  95255. * @hidden
  95256. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  95257. */
  95258. _checkInputs(): void;
  95259. /**
  95260. * Reset the camera to its default orientation on the specified axis only.
  95261. * @param axis The axis to reset
  95262. */
  95263. resetToCurrentRotation(axis?: Axis): void;
  95264. }
  95265. }
  95266. declare module BABYLON {
  95267. /**
  95268. * 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,
  95269. * which still works and will still be found in many Playgrounds.
  95270. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95271. */
  95272. export class UniversalCamera extends TouchCamera {
  95273. /**
  95274. * Defines the gamepad rotation sensiblity.
  95275. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95276. */
  95277. gamepadAngularSensibility: number;
  95278. /**
  95279. * Defines the gamepad move sensiblity.
  95280. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95281. */
  95282. gamepadMoveSensibility: number;
  95283. /**
  95284. * 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,
  95285. * which still works and will still be found in many Playgrounds.
  95286. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95287. * @param name Define the name of the camera in the scene
  95288. * @param position Define the start position of the camera in the scene
  95289. * @param scene Define the scene the camera belongs to
  95290. */
  95291. constructor(name: string, position: Vector3, scene: Scene);
  95292. /**
  95293. * Gets the current object class name.
  95294. * @return the class name
  95295. */
  95296. getClassName(): string;
  95297. }
  95298. }
  95299. declare module BABYLON {
  95300. /**
  95301. * This represents a FPS type of camera. This is only here for back compat purpose.
  95302. * Please use the UniversalCamera instead as both are identical.
  95303. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95304. */
  95305. export class GamepadCamera extends UniversalCamera {
  95306. /**
  95307. * Instantiates a new Gamepad Camera
  95308. * This represents a FPS type of camera. This is only here for back compat purpose.
  95309. * Please use the UniversalCamera instead as both are identical.
  95310. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  95311. * @param name Define the name of the camera in the scene
  95312. * @param position Define the start position of the camera in the scene
  95313. * @param scene Define the scene the camera belongs to
  95314. */
  95315. constructor(name: string, position: Vector3, scene: Scene);
  95316. /**
  95317. * Gets the current object class name.
  95318. * @return the class name
  95319. */
  95320. getClassName(): string;
  95321. }
  95322. }
  95323. declare module BABYLON {
  95324. /** @hidden */
  95325. export var passPixelShader: {
  95326. name: string;
  95327. shader: string;
  95328. };
  95329. }
  95330. declare module BABYLON {
  95331. /** @hidden */
  95332. export var passCubePixelShader: {
  95333. name: string;
  95334. shader: string;
  95335. };
  95336. }
  95337. declare module BABYLON {
  95338. /**
  95339. * PassPostProcess which produces an output the same as it's input
  95340. */
  95341. export class PassPostProcess extends PostProcess {
  95342. /**
  95343. * Creates the PassPostProcess
  95344. * @param name The name of the effect.
  95345. * @param options The required width/height ratio to downsize to before computing the render pass.
  95346. * @param camera The camera to apply the render pass to.
  95347. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  95348. * @param engine The engine which the post process will be applied. (default: current engine)
  95349. * @param reusable If the post process can be reused on the same frame. (default: false)
  95350. * @param textureType The type of texture to be used when performing the post processing.
  95351. * @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)
  95352. */
  95353. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  95354. }
  95355. /**
  95356. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  95357. */
  95358. export class PassCubePostProcess extends PostProcess {
  95359. private _face;
  95360. /**
  95361. * Gets or sets the cube face to display.
  95362. * * 0 is +X
  95363. * * 1 is -X
  95364. * * 2 is +Y
  95365. * * 3 is -Y
  95366. * * 4 is +Z
  95367. * * 5 is -Z
  95368. */
  95369. face: number;
  95370. /**
  95371. * Creates the PassCubePostProcess
  95372. * @param name The name of the effect.
  95373. * @param options The required width/height ratio to downsize to before computing the render pass.
  95374. * @param camera The camera to apply the render pass to.
  95375. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  95376. * @param engine The engine which the post process will be applied. (default: current engine)
  95377. * @param reusable If the post process can be reused on the same frame. (default: false)
  95378. * @param textureType The type of texture to be used when performing the post processing.
  95379. * @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)
  95380. */
  95381. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  95382. }
  95383. }
  95384. declare module BABYLON {
  95385. /** @hidden */
  95386. export var anaglyphPixelShader: {
  95387. name: string;
  95388. shader: string;
  95389. };
  95390. }
  95391. declare module BABYLON {
  95392. /**
  95393. * Postprocess used to generate anaglyphic rendering
  95394. */
  95395. export class AnaglyphPostProcess extends PostProcess {
  95396. private _passedProcess;
  95397. /**
  95398. * Creates a new AnaglyphPostProcess
  95399. * @param name defines postprocess name
  95400. * @param options defines creation options or target ratio scale
  95401. * @param rigCameras defines cameras using this postprocess
  95402. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  95403. * @param engine defines hosting engine
  95404. * @param reusable defines if the postprocess will be reused multiple times per frame
  95405. */
  95406. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  95407. }
  95408. }
  95409. declare module BABYLON {
  95410. /**
  95411. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  95412. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  95413. */
  95414. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  95415. /**
  95416. * Creates a new AnaglyphArcRotateCamera
  95417. * @param name defines camera name
  95418. * @param alpha defines alpha angle (in radians)
  95419. * @param beta defines beta angle (in radians)
  95420. * @param radius defines radius
  95421. * @param target defines camera target
  95422. * @param interaxialDistance defines distance between each color axis
  95423. * @param scene defines the hosting scene
  95424. */
  95425. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  95426. /**
  95427. * Gets camera class name
  95428. * @returns AnaglyphArcRotateCamera
  95429. */
  95430. getClassName(): string;
  95431. }
  95432. }
  95433. declare module BABYLON {
  95434. /**
  95435. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  95436. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  95437. */
  95438. export class AnaglyphFreeCamera extends FreeCamera {
  95439. /**
  95440. * Creates a new AnaglyphFreeCamera
  95441. * @param name defines camera name
  95442. * @param position defines initial position
  95443. * @param interaxialDistance defines distance between each color axis
  95444. * @param scene defines the hosting scene
  95445. */
  95446. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  95447. /**
  95448. * Gets camera class name
  95449. * @returns AnaglyphFreeCamera
  95450. */
  95451. getClassName(): string;
  95452. }
  95453. }
  95454. declare module BABYLON {
  95455. /**
  95456. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  95457. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  95458. */
  95459. export class AnaglyphGamepadCamera extends GamepadCamera {
  95460. /**
  95461. * Creates a new AnaglyphGamepadCamera
  95462. * @param name defines camera name
  95463. * @param position defines initial position
  95464. * @param interaxialDistance defines distance between each color axis
  95465. * @param scene defines the hosting scene
  95466. */
  95467. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  95468. /**
  95469. * Gets camera class name
  95470. * @returns AnaglyphGamepadCamera
  95471. */
  95472. getClassName(): string;
  95473. }
  95474. }
  95475. declare module BABYLON {
  95476. /**
  95477. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  95478. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  95479. */
  95480. export class AnaglyphUniversalCamera extends UniversalCamera {
  95481. /**
  95482. * Creates a new AnaglyphUniversalCamera
  95483. * @param name defines camera name
  95484. * @param position defines initial position
  95485. * @param interaxialDistance defines distance between each color axis
  95486. * @param scene defines the hosting scene
  95487. */
  95488. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  95489. /**
  95490. * Gets camera class name
  95491. * @returns AnaglyphUniversalCamera
  95492. */
  95493. getClassName(): string;
  95494. }
  95495. }
  95496. declare module BABYLON {
  95497. /** @hidden */
  95498. export var stereoscopicInterlacePixelShader: {
  95499. name: string;
  95500. shader: string;
  95501. };
  95502. }
  95503. declare module BABYLON {
  95504. /**
  95505. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  95506. */
  95507. export class StereoscopicInterlacePostProcess extends PostProcess {
  95508. private _stepSize;
  95509. private _passedProcess;
  95510. /**
  95511. * Initializes a StereoscopicInterlacePostProcess
  95512. * @param name The name of the effect.
  95513. * @param rigCameras The rig cameras to be appled to the post process
  95514. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  95515. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  95516. * @param engine The engine which the post process will be applied. (default: current engine)
  95517. * @param reusable If the post process can be reused on the same frame. (default: false)
  95518. */
  95519. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  95520. }
  95521. }
  95522. declare module BABYLON {
  95523. /**
  95524. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  95525. * @see http://doc.babylonjs.com/features/cameras
  95526. */
  95527. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  95528. /**
  95529. * Creates a new StereoscopicArcRotateCamera
  95530. * @param name defines camera name
  95531. * @param alpha defines alpha angle (in radians)
  95532. * @param beta defines beta angle (in radians)
  95533. * @param radius defines radius
  95534. * @param target defines camera target
  95535. * @param interaxialDistance defines distance between each color axis
  95536. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  95537. * @param scene defines the hosting scene
  95538. */
  95539. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  95540. /**
  95541. * Gets camera class name
  95542. * @returns StereoscopicArcRotateCamera
  95543. */
  95544. getClassName(): string;
  95545. }
  95546. }
  95547. declare module BABYLON {
  95548. /**
  95549. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  95550. * @see http://doc.babylonjs.com/features/cameras
  95551. */
  95552. export class StereoscopicFreeCamera extends FreeCamera {
  95553. /**
  95554. * Creates a new StereoscopicFreeCamera
  95555. * @param name defines camera name
  95556. * @param position defines initial position
  95557. * @param interaxialDistance defines distance between each color axis
  95558. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  95559. * @param scene defines the hosting scene
  95560. */
  95561. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  95562. /**
  95563. * Gets camera class name
  95564. * @returns StereoscopicFreeCamera
  95565. */
  95566. getClassName(): string;
  95567. }
  95568. }
  95569. declare module BABYLON {
  95570. /**
  95571. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  95572. * @see http://doc.babylonjs.com/features/cameras
  95573. */
  95574. export class StereoscopicGamepadCamera extends GamepadCamera {
  95575. /**
  95576. * Creates a new StereoscopicGamepadCamera
  95577. * @param name defines camera name
  95578. * @param position defines initial position
  95579. * @param interaxialDistance defines distance between each color axis
  95580. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  95581. * @param scene defines the hosting scene
  95582. */
  95583. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  95584. /**
  95585. * Gets camera class name
  95586. * @returns StereoscopicGamepadCamera
  95587. */
  95588. getClassName(): string;
  95589. }
  95590. }
  95591. declare module BABYLON {
  95592. /**
  95593. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  95594. * @see http://doc.babylonjs.com/features/cameras
  95595. */
  95596. export class StereoscopicUniversalCamera extends UniversalCamera {
  95597. /**
  95598. * Creates a new StereoscopicUniversalCamera
  95599. * @param name defines camera name
  95600. * @param position defines initial position
  95601. * @param interaxialDistance defines distance between each color axis
  95602. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  95603. * @param scene defines the hosting scene
  95604. */
  95605. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  95606. /**
  95607. * Gets camera class name
  95608. * @returns StereoscopicUniversalCamera
  95609. */
  95610. getClassName(): string;
  95611. }
  95612. }
  95613. declare module BABYLON {
  95614. /**
  95615. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  95616. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  95617. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  95618. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  95619. */
  95620. export class VirtualJoysticksCamera extends FreeCamera {
  95621. /**
  95622. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  95623. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  95624. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  95625. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  95626. * @param name Define the name of the camera in the scene
  95627. * @param position Define the start position of the camera in the scene
  95628. * @param scene Define the scene the camera belongs to
  95629. */
  95630. constructor(name: string, position: Vector3, scene: Scene);
  95631. /**
  95632. * Gets the current object class name.
  95633. * @return the class name
  95634. */
  95635. getClassName(): string;
  95636. }
  95637. }
  95638. declare module BABYLON {
  95639. /**
  95640. * This represents all the required metrics to create a VR camera.
  95641. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  95642. */
  95643. export class VRCameraMetrics {
  95644. /**
  95645. * Define the horizontal resolution off the screen.
  95646. */
  95647. hResolution: number;
  95648. /**
  95649. * Define the vertical resolution off the screen.
  95650. */
  95651. vResolution: number;
  95652. /**
  95653. * Define the horizontal screen size.
  95654. */
  95655. hScreenSize: number;
  95656. /**
  95657. * Define the vertical screen size.
  95658. */
  95659. vScreenSize: number;
  95660. /**
  95661. * Define the vertical screen center position.
  95662. */
  95663. vScreenCenter: number;
  95664. /**
  95665. * Define the distance of the eyes to the screen.
  95666. */
  95667. eyeToScreenDistance: number;
  95668. /**
  95669. * Define the distance between both lenses
  95670. */
  95671. lensSeparationDistance: number;
  95672. /**
  95673. * Define the distance between both viewer's eyes.
  95674. */
  95675. interpupillaryDistance: number;
  95676. /**
  95677. * Define the distortion factor of the VR postprocess.
  95678. * Please, touch with care.
  95679. */
  95680. distortionK: number[];
  95681. /**
  95682. * Define the chromatic aberration correction factors for the VR post process.
  95683. */
  95684. chromaAbCorrection: number[];
  95685. /**
  95686. * Define the scale factor of the post process.
  95687. * The smaller the better but the slower.
  95688. */
  95689. postProcessScaleFactor: number;
  95690. /**
  95691. * Define an offset for the lens center.
  95692. */
  95693. lensCenterOffset: number;
  95694. /**
  95695. * Define if the current vr camera should compensate the distortion of the lense or not.
  95696. */
  95697. compensateDistortion: boolean;
  95698. /**
  95699. * Gets the rendering aspect ratio based on the provided resolutions.
  95700. */
  95701. readonly aspectRatio: number;
  95702. /**
  95703. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  95704. */
  95705. readonly aspectRatioFov: number;
  95706. /**
  95707. * @hidden
  95708. */
  95709. readonly leftHMatrix: Matrix;
  95710. /**
  95711. * @hidden
  95712. */
  95713. readonly rightHMatrix: Matrix;
  95714. /**
  95715. * @hidden
  95716. */
  95717. readonly leftPreViewMatrix: Matrix;
  95718. /**
  95719. * @hidden
  95720. */
  95721. readonly rightPreViewMatrix: Matrix;
  95722. /**
  95723. * Get the default VRMetrics based on the most generic setup.
  95724. * @returns the default vr metrics
  95725. */
  95726. static GetDefault(): VRCameraMetrics;
  95727. }
  95728. }
  95729. declare module BABYLON {
  95730. /** @hidden */
  95731. export var vrDistortionCorrectionPixelShader: {
  95732. name: string;
  95733. shader: string;
  95734. };
  95735. }
  95736. declare module BABYLON {
  95737. /**
  95738. * VRDistortionCorrectionPostProcess used for mobile VR
  95739. */
  95740. export class VRDistortionCorrectionPostProcess extends PostProcess {
  95741. private _isRightEye;
  95742. private _distortionFactors;
  95743. private _postProcessScaleFactor;
  95744. private _lensCenterOffset;
  95745. private _scaleIn;
  95746. private _scaleFactor;
  95747. private _lensCenter;
  95748. /**
  95749. * Initializes the VRDistortionCorrectionPostProcess
  95750. * @param name The name of the effect.
  95751. * @param camera The camera to apply the render pass to.
  95752. * @param isRightEye If this is for the right eye distortion
  95753. * @param vrMetrics All the required metrics for the VR camera
  95754. */
  95755. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  95756. }
  95757. }
  95758. declare module BABYLON {
  95759. /**
  95760. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  95761. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  95762. */
  95763. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  95764. /**
  95765. * Creates a new VRDeviceOrientationArcRotateCamera
  95766. * @param name defines camera name
  95767. * @param alpha defines the camera rotation along the logitudinal axis
  95768. * @param beta defines the camera rotation along the latitudinal axis
  95769. * @param radius defines the camera distance from its target
  95770. * @param target defines the camera target
  95771. * @param scene defines the scene the camera belongs to
  95772. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  95773. * @param vrCameraMetrics defines the vr metrics associated to the camera
  95774. */
  95775. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  95776. /**
  95777. * Gets camera class name
  95778. * @returns VRDeviceOrientationArcRotateCamera
  95779. */
  95780. getClassName(): string;
  95781. }
  95782. }
  95783. declare module BABYLON {
  95784. /**
  95785. * Camera used to simulate VR rendering (based on FreeCamera)
  95786. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  95787. */
  95788. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  95789. /**
  95790. * Creates a new VRDeviceOrientationFreeCamera
  95791. * @param name defines camera name
  95792. * @param position defines the start position of the camera
  95793. * @param scene defines the scene the camera belongs to
  95794. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  95795. * @param vrCameraMetrics defines the vr metrics associated to the camera
  95796. */
  95797. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  95798. /**
  95799. * Gets camera class name
  95800. * @returns VRDeviceOrientationFreeCamera
  95801. */
  95802. getClassName(): string;
  95803. }
  95804. }
  95805. declare module BABYLON {
  95806. /**
  95807. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  95808. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  95809. */
  95810. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  95811. /**
  95812. * Creates a new VRDeviceOrientationGamepadCamera
  95813. * @param name defines camera name
  95814. * @param position defines the start position of the camera
  95815. * @param scene defines the scene the camera belongs to
  95816. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  95817. * @param vrCameraMetrics defines the vr metrics associated to the camera
  95818. */
  95819. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  95820. /**
  95821. * Gets camera class name
  95822. * @returns VRDeviceOrientationGamepadCamera
  95823. */
  95824. getClassName(): string;
  95825. }
  95826. }
  95827. declare module BABYLON {
  95828. /**
  95829. * Defines supported buttons for XBox360 compatible gamepads
  95830. */
  95831. export enum Xbox360Button {
  95832. /** A */
  95833. A = 0,
  95834. /** B */
  95835. B = 1,
  95836. /** X */
  95837. X = 2,
  95838. /** Y */
  95839. Y = 3,
  95840. /** Start */
  95841. Start = 4,
  95842. /** Back */
  95843. Back = 5,
  95844. /** Left button */
  95845. LB = 6,
  95846. /** Right button */
  95847. RB = 7,
  95848. /** Left stick */
  95849. LeftStick = 8,
  95850. /** Right stick */
  95851. RightStick = 9
  95852. }
  95853. /** Defines values for XBox360 DPad */
  95854. export enum Xbox360Dpad {
  95855. /** Up */
  95856. Up = 0,
  95857. /** Down */
  95858. Down = 1,
  95859. /** Left */
  95860. Left = 2,
  95861. /** Right */
  95862. Right = 3
  95863. }
  95864. /**
  95865. * Defines a XBox360 gamepad
  95866. */
  95867. export class Xbox360Pad extends Gamepad {
  95868. private _leftTrigger;
  95869. private _rightTrigger;
  95870. private _onlefttriggerchanged;
  95871. private _onrighttriggerchanged;
  95872. private _onbuttondown;
  95873. private _onbuttonup;
  95874. private _ondpaddown;
  95875. private _ondpadup;
  95876. /** Observable raised when a button is pressed */
  95877. onButtonDownObservable: Observable<Xbox360Button>;
  95878. /** Observable raised when a button is released */
  95879. onButtonUpObservable: Observable<Xbox360Button>;
  95880. /** Observable raised when a pad is pressed */
  95881. onPadDownObservable: Observable<Xbox360Dpad>;
  95882. /** Observable raised when a pad is released */
  95883. onPadUpObservable: Observable<Xbox360Dpad>;
  95884. private _buttonA;
  95885. private _buttonB;
  95886. private _buttonX;
  95887. private _buttonY;
  95888. private _buttonBack;
  95889. private _buttonStart;
  95890. private _buttonLB;
  95891. private _buttonRB;
  95892. private _buttonLeftStick;
  95893. private _buttonRightStick;
  95894. private _dPadUp;
  95895. private _dPadDown;
  95896. private _dPadLeft;
  95897. private _dPadRight;
  95898. private _isXboxOnePad;
  95899. /**
  95900. * Creates a new XBox360 gamepad object
  95901. * @param id defines the id of this gamepad
  95902. * @param index defines its index
  95903. * @param gamepad defines the internal HTML gamepad object
  95904. * @param xboxOne defines if it is a XBox One gamepad
  95905. */
  95906. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  95907. /**
  95908. * Defines the callback to call when left trigger is pressed
  95909. * @param callback defines the callback to use
  95910. */
  95911. onlefttriggerchanged(callback: (value: number) => void): void;
  95912. /**
  95913. * Defines the callback to call when right trigger is pressed
  95914. * @param callback defines the callback to use
  95915. */
  95916. onrighttriggerchanged(callback: (value: number) => void): void;
  95917. /**
  95918. * Gets the left trigger value
  95919. */
  95920. /**
  95921. * Sets the left trigger value
  95922. */
  95923. leftTrigger: number;
  95924. /**
  95925. * Gets the right trigger value
  95926. */
  95927. /**
  95928. * Sets the right trigger value
  95929. */
  95930. rightTrigger: number;
  95931. /**
  95932. * Defines the callback to call when a button is pressed
  95933. * @param callback defines the callback to use
  95934. */
  95935. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  95936. /**
  95937. * Defines the callback to call when a button is released
  95938. * @param callback defines the callback to use
  95939. */
  95940. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  95941. /**
  95942. * Defines the callback to call when a pad is pressed
  95943. * @param callback defines the callback to use
  95944. */
  95945. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  95946. /**
  95947. * Defines the callback to call when a pad is released
  95948. * @param callback defines the callback to use
  95949. */
  95950. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  95951. private _setButtonValue;
  95952. private _setDPadValue;
  95953. /**
  95954. * Gets the value of the `A` button
  95955. */
  95956. /**
  95957. * Sets the value of the `A` button
  95958. */
  95959. buttonA: number;
  95960. /**
  95961. * Gets the value of the `B` button
  95962. */
  95963. /**
  95964. * Sets the value of the `B` button
  95965. */
  95966. buttonB: number;
  95967. /**
  95968. * Gets the value of the `X` button
  95969. */
  95970. /**
  95971. * Sets the value of the `X` button
  95972. */
  95973. buttonX: number;
  95974. /**
  95975. * Gets the value of the `Y` button
  95976. */
  95977. /**
  95978. * Sets the value of the `Y` button
  95979. */
  95980. buttonY: number;
  95981. /**
  95982. * Gets the value of the `Start` button
  95983. */
  95984. /**
  95985. * Sets the value of the `Start` button
  95986. */
  95987. buttonStart: number;
  95988. /**
  95989. * Gets the value of the `Back` button
  95990. */
  95991. /**
  95992. * Sets the value of the `Back` button
  95993. */
  95994. buttonBack: number;
  95995. /**
  95996. * Gets the value of the `Left` button
  95997. */
  95998. /**
  95999. * Sets the value of the `Left` button
  96000. */
  96001. buttonLB: number;
  96002. /**
  96003. * Gets the value of the `Right` button
  96004. */
  96005. /**
  96006. * Sets the value of the `Right` button
  96007. */
  96008. buttonRB: number;
  96009. /**
  96010. * Gets the value of the Left joystick
  96011. */
  96012. /**
  96013. * Sets the value of the Left joystick
  96014. */
  96015. buttonLeftStick: number;
  96016. /**
  96017. * Gets the value of the Right joystick
  96018. */
  96019. /**
  96020. * Sets the value of the Right joystick
  96021. */
  96022. buttonRightStick: number;
  96023. /**
  96024. * Gets the value of D-pad up
  96025. */
  96026. /**
  96027. * Sets the value of D-pad up
  96028. */
  96029. dPadUp: number;
  96030. /**
  96031. * Gets the value of D-pad down
  96032. */
  96033. /**
  96034. * Sets the value of D-pad down
  96035. */
  96036. dPadDown: number;
  96037. /**
  96038. * Gets the value of D-pad left
  96039. */
  96040. /**
  96041. * Sets the value of D-pad left
  96042. */
  96043. dPadLeft: number;
  96044. /**
  96045. * Gets the value of D-pad right
  96046. */
  96047. /**
  96048. * Sets the value of D-pad right
  96049. */
  96050. dPadRight: number;
  96051. /**
  96052. * Force the gamepad to synchronize with device values
  96053. */
  96054. update(): void;
  96055. /**
  96056. * Disposes the gamepad
  96057. */
  96058. dispose(): void;
  96059. }
  96060. }
  96061. declare module BABYLON {
  96062. /**
  96063. * Base class of materials working in push mode in babylon JS
  96064. * @hidden
  96065. */
  96066. export class PushMaterial extends Material {
  96067. protected _activeEffect: Effect;
  96068. protected _normalMatrix: Matrix;
  96069. /**
  96070. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  96071. * This means that the material can keep using a previous shader while a new one is being compiled.
  96072. * This is mostly used when shader parallel compilation is supported (true by default)
  96073. */
  96074. allowShaderHotSwapping: boolean;
  96075. constructor(name: string, scene: Scene);
  96076. getEffect(): Effect;
  96077. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  96078. /**
  96079. * Binds the given world matrix to the active effect
  96080. *
  96081. * @param world the matrix to bind
  96082. */
  96083. bindOnlyWorldMatrix(world: Matrix): void;
  96084. /**
  96085. * Binds the given normal matrix to the active effect
  96086. *
  96087. * @param normalMatrix the matrix to bind
  96088. */
  96089. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  96090. bind(world: Matrix, mesh?: Mesh): void;
  96091. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  96092. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  96093. }
  96094. }
  96095. declare module BABYLON {
  96096. /**
  96097. * This groups all the flags used to control the materials channel.
  96098. */
  96099. export class MaterialFlags {
  96100. private static _DiffuseTextureEnabled;
  96101. /**
  96102. * Are diffuse textures enabled in the application.
  96103. */
  96104. static DiffuseTextureEnabled: boolean;
  96105. private static _AmbientTextureEnabled;
  96106. /**
  96107. * Are ambient textures enabled in the application.
  96108. */
  96109. static AmbientTextureEnabled: boolean;
  96110. private static _OpacityTextureEnabled;
  96111. /**
  96112. * Are opacity textures enabled in the application.
  96113. */
  96114. static OpacityTextureEnabled: boolean;
  96115. private static _ReflectionTextureEnabled;
  96116. /**
  96117. * Are reflection textures enabled in the application.
  96118. */
  96119. static ReflectionTextureEnabled: boolean;
  96120. private static _EmissiveTextureEnabled;
  96121. /**
  96122. * Are emissive textures enabled in the application.
  96123. */
  96124. static EmissiveTextureEnabled: boolean;
  96125. private static _SpecularTextureEnabled;
  96126. /**
  96127. * Are specular textures enabled in the application.
  96128. */
  96129. static SpecularTextureEnabled: boolean;
  96130. private static _BumpTextureEnabled;
  96131. /**
  96132. * Are bump textures enabled in the application.
  96133. */
  96134. static BumpTextureEnabled: boolean;
  96135. private static _LightmapTextureEnabled;
  96136. /**
  96137. * Are lightmap textures enabled in the application.
  96138. */
  96139. static LightmapTextureEnabled: boolean;
  96140. private static _RefractionTextureEnabled;
  96141. /**
  96142. * Are refraction textures enabled in the application.
  96143. */
  96144. static RefractionTextureEnabled: boolean;
  96145. private static _ColorGradingTextureEnabled;
  96146. /**
  96147. * Are color grading textures enabled in the application.
  96148. */
  96149. static ColorGradingTextureEnabled: boolean;
  96150. private static _FresnelEnabled;
  96151. /**
  96152. * Are fresnels enabled in the application.
  96153. */
  96154. static FresnelEnabled: boolean;
  96155. private static _ClearCoatTextureEnabled;
  96156. /**
  96157. * Are clear coat textures enabled in the application.
  96158. */
  96159. static ClearCoatTextureEnabled: boolean;
  96160. private static _ClearCoatBumpTextureEnabled;
  96161. /**
  96162. * Are clear coat bump textures enabled in the application.
  96163. */
  96164. static ClearCoatBumpTextureEnabled: boolean;
  96165. private static _ClearCoatTintTextureEnabled;
  96166. /**
  96167. * Are clear coat tint textures enabled in the application.
  96168. */
  96169. static ClearCoatTintTextureEnabled: boolean;
  96170. private static _SheenTextureEnabled;
  96171. /**
  96172. * Are sheen textures enabled in the application.
  96173. */
  96174. static SheenTextureEnabled: boolean;
  96175. private static _AnisotropicTextureEnabled;
  96176. /**
  96177. * Are anisotropic textures enabled in the application.
  96178. */
  96179. static AnisotropicTextureEnabled: boolean;
  96180. }
  96181. }
  96182. declare module BABYLON {
  96183. /** @hidden */
  96184. export var defaultFragmentDeclaration: {
  96185. name: string;
  96186. shader: string;
  96187. };
  96188. }
  96189. declare module BABYLON {
  96190. /** @hidden */
  96191. export var defaultUboDeclaration: {
  96192. name: string;
  96193. shader: string;
  96194. };
  96195. }
  96196. declare module BABYLON {
  96197. /** @hidden */
  96198. export var lightFragmentDeclaration: {
  96199. name: string;
  96200. shader: string;
  96201. };
  96202. }
  96203. declare module BABYLON {
  96204. /** @hidden */
  96205. export var lightUboDeclaration: {
  96206. name: string;
  96207. shader: string;
  96208. };
  96209. }
  96210. declare module BABYLON {
  96211. /** @hidden */
  96212. export var lightsFragmentFunctions: {
  96213. name: string;
  96214. shader: string;
  96215. };
  96216. }
  96217. declare module BABYLON {
  96218. /** @hidden */
  96219. export var shadowsFragmentFunctions: {
  96220. name: string;
  96221. shader: string;
  96222. };
  96223. }
  96224. declare module BABYLON {
  96225. /** @hidden */
  96226. export var fresnelFunction: {
  96227. name: string;
  96228. shader: string;
  96229. };
  96230. }
  96231. declare module BABYLON {
  96232. /** @hidden */
  96233. export var reflectionFunction: {
  96234. name: string;
  96235. shader: string;
  96236. };
  96237. }
  96238. declare module BABYLON {
  96239. /** @hidden */
  96240. export var bumpFragmentFunctions: {
  96241. name: string;
  96242. shader: string;
  96243. };
  96244. }
  96245. declare module BABYLON {
  96246. /** @hidden */
  96247. export var logDepthDeclaration: {
  96248. name: string;
  96249. shader: string;
  96250. };
  96251. }
  96252. declare module BABYLON {
  96253. /** @hidden */
  96254. export var bumpFragment: {
  96255. name: string;
  96256. shader: string;
  96257. };
  96258. }
  96259. declare module BABYLON {
  96260. /** @hidden */
  96261. export var depthPrePass: {
  96262. name: string;
  96263. shader: string;
  96264. };
  96265. }
  96266. declare module BABYLON {
  96267. /** @hidden */
  96268. export var lightFragment: {
  96269. name: string;
  96270. shader: string;
  96271. };
  96272. }
  96273. declare module BABYLON {
  96274. /** @hidden */
  96275. export var logDepthFragment: {
  96276. name: string;
  96277. shader: string;
  96278. };
  96279. }
  96280. declare module BABYLON {
  96281. /** @hidden */
  96282. export var defaultPixelShader: {
  96283. name: string;
  96284. shader: string;
  96285. };
  96286. }
  96287. declare module BABYLON {
  96288. /** @hidden */
  96289. export var defaultVertexDeclaration: {
  96290. name: string;
  96291. shader: string;
  96292. };
  96293. }
  96294. declare module BABYLON {
  96295. /** @hidden */
  96296. export var bumpVertexDeclaration: {
  96297. name: string;
  96298. shader: string;
  96299. };
  96300. }
  96301. declare module BABYLON {
  96302. /** @hidden */
  96303. export var bumpVertex: {
  96304. name: string;
  96305. shader: string;
  96306. };
  96307. }
  96308. declare module BABYLON {
  96309. /** @hidden */
  96310. export var fogVertex: {
  96311. name: string;
  96312. shader: string;
  96313. };
  96314. }
  96315. declare module BABYLON {
  96316. /** @hidden */
  96317. export var shadowsVertex: {
  96318. name: string;
  96319. shader: string;
  96320. };
  96321. }
  96322. declare module BABYLON {
  96323. /** @hidden */
  96324. export var pointCloudVertex: {
  96325. name: string;
  96326. shader: string;
  96327. };
  96328. }
  96329. declare module BABYLON {
  96330. /** @hidden */
  96331. export var logDepthVertex: {
  96332. name: string;
  96333. shader: string;
  96334. };
  96335. }
  96336. declare module BABYLON {
  96337. /** @hidden */
  96338. export var defaultVertexShader: {
  96339. name: string;
  96340. shader: string;
  96341. };
  96342. }
  96343. declare module BABYLON {
  96344. /** @hidden */
  96345. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  96346. MAINUV1: boolean;
  96347. MAINUV2: boolean;
  96348. DIFFUSE: boolean;
  96349. DIFFUSEDIRECTUV: number;
  96350. AMBIENT: boolean;
  96351. AMBIENTDIRECTUV: number;
  96352. OPACITY: boolean;
  96353. OPACITYDIRECTUV: number;
  96354. OPACITYRGB: boolean;
  96355. REFLECTION: boolean;
  96356. EMISSIVE: boolean;
  96357. EMISSIVEDIRECTUV: number;
  96358. SPECULAR: boolean;
  96359. SPECULARDIRECTUV: number;
  96360. BUMP: boolean;
  96361. BUMPDIRECTUV: number;
  96362. PARALLAX: boolean;
  96363. PARALLAXOCCLUSION: boolean;
  96364. SPECULAROVERALPHA: boolean;
  96365. CLIPPLANE: boolean;
  96366. CLIPPLANE2: boolean;
  96367. CLIPPLANE3: boolean;
  96368. CLIPPLANE4: boolean;
  96369. ALPHATEST: boolean;
  96370. DEPTHPREPASS: boolean;
  96371. ALPHAFROMDIFFUSE: boolean;
  96372. POINTSIZE: boolean;
  96373. FOG: boolean;
  96374. SPECULARTERM: boolean;
  96375. DIFFUSEFRESNEL: boolean;
  96376. OPACITYFRESNEL: boolean;
  96377. REFLECTIONFRESNEL: boolean;
  96378. REFRACTIONFRESNEL: boolean;
  96379. EMISSIVEFRESNEL: boolean;
  96380. FRESNEL: boolean;
  96381. NORMAL: boolean;
  96382. UV1: boolean;
  96383. UV2: boolean;
  96384. VERTEXCOLOR: boolean;
  96385. VERTEXALPHA: boolean;
  96386. NUM_BONE_INFLUENCERS: number;
  96387. BonesPerMesh: number;
  96388. BONETEXTURE: boolean;
  96389. INSTANCES: boolean;
  96390. GLOSSINESS: boolean;
  96391. ROUGHNESS: boolean;
  96392. EMISSIVEASILLUMINATION: boolean;
  96393. LINKEMISSIVEWITHDIFFUSE: boolean;
  96394. REFLECTIONFRESNELFROMSPECULAR: boolean;
  96395. LIGHTMAP: boolean;
  96396. LIGHTMAPDIRECTUV: number;
  96397. OBJECTSPACE_NORMALMAP: boolean;
  96398. USELIGHTMAPASSHADOWMAP: boolean;
  96399. REFLECTIONMAP_3D: boolean;
  96400. REFLECTIONMAP_SPHERICAL: boolean;
  96401. REFLECTIONMAP_PLANAR: boolean;
  96402. REFLECTIONMAP_CUBIC: boolean;
  96403. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  96404. REFLECTIONMAP_PROJECTION: boolean;
  96405. REFLECTIONMAP_SKYBOX: boolean;
  96406. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  96407. REFLECTIONMAP_EXPLICIT: boolean;
  96408. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  96409. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  96410. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  96411. INVERTCUBICMAP: boolean;
  96412. LOGARITHMICDEPTH: boolean;
  96413. REFRACTION: boolean;
  96414. REFRACTIONMAP_3D: boolean;
  96415. REFLECTIONOVERALPHA: boolean;
  96416. TWOSIDEDLIGHTING: boolean;
  96417. SHADOWFLOAT: boolean;
  96418. MORPHTARGETS: boolean;
  96419. MORPHTARGETS_NORMAL: boolean;
  96420. MORPHTARGETS_TANGENT: boolean;
  96421. NUM_MORPH_INFLUENCERS: number;
  96422. NONUNIFORMSCALING: boolean;
  96423. PREMULTIPLYALPHA: boolean;
  96424. IMAGEPROCESSING: boolean;
  96425. VIGNETTE: boolean;
  96426. VIGNETTEBLENDMODEMULTIPLY: boolean;
  96427. VIGNETTEBLENDMODEOPAQUE: boolean;
  96428. TONEMAPPING: boolean;
  96429. TONEMAPPING_ACES: boolean;
  96430. CONTRAST: boolean;
  96431. COLORCURVES: boolean;
  96432. COLORGRADING: boolean;
  96433. COLORGRADING3D: boolean;
  96434. SAMPLER3DGREENDEPTH: boolean;
  96435. SAMPLER3DBGRMAP: boolean;
  96436. IMAGEPROCESSINGPOSTPROCESS: boolean;
  96437. /**
  96438. * If the reflection texture on this material is in linear color space
  96439. * @hidden
  96440. */
  96441. IS_REFLECTION_LINEAR: boolean;
  96442. /**
  96443. * If the refraction texture on this material is in linear color space
  96444. * @hidden
  96445. */
  96446. IS_REFRACTION_LINEAR: boolean;
  96447. EXPOSURE: boolean;
  96448. constructor();
  96449. setReflectionMode(modeToEnable: string): void;
  96450. }
  96451. /**
  96452. * This is the default material used in Babylon. It is the best trade off between quality
  96453. * and performances.
  96454. * @see http://doc.babylonjs.com/babylon101/materials
  96455. */
  96456. export class StandardMaterial extends PushMaterial {
  96457. private _diffuseTexture;
  96458. /**
  96459. * The basic texture of the material as viewed under a light.
  96460. */
  96461. diffuseTexture: Nullable<BaseTexture>;
  96462. private _ambientTexture;
  96463. /**
  96464. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  96465. */
  96466. ambientTexture: Nullable<BaseTexture>;
  96467. private _opacityTexture;
  96468. /**
  96469. * Define the transparency of the material from a texture.
  96470. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  96471. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  96472. */
  96473. opacityTexture: Nullable<BaseTexture>;
  96474. private _reflectionTexture;
  96475. /**
  96476. * Define the texture used to display the reflection.
  96477. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96478. */
  96479. reflectionTexture: Nullable<BaseTexture>;
  96480. private _emissiveTexture;
  96481. /**
  96482. * Define texture of the material as if self lit.
  96483. * This will be mixed in the final result even in the absence of light.
  96484. */
  96485. emissiveTexture: Nullable<BaseTexture>;
  96486. private _specularTexture;
  96487. /**
  96488. * Define how the color and intensity of the highlight given by the light in the material.
  96489. */
  96490. specularTexture: Nullable<BaseTexture>;
  96491. private _bumpTexture;
  96492. /**
  96493. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  96494. * 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.
  96495. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  96496. */
  96497. bumpTexture: Nullable<BaseTexture>;
  96498. private _lightmapTexture;
  96499. /**
  96500. * Complex lighting can be computationally expensive to compute at runtime.
  96501. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  96502. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  96503. */
  96504. lightmapTexture: Nullable<BaseTexture>;
  96505. private _refractionTexture;
  96506. /**
  96507. * Define the texture used to display the refraction.
  96508. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96509. */
  96510. refractionTexture: Nullable<BaseTexture>;
  96511. /**
  96512. * The color of the material lit by the environmental background lighting.
  96513. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  96514. */
  96515. ambientColor: Color3;
  96516. /**
  96517. * The basic color of the material as viewed under a light.
  96518. */
  96519. diffuseColor: Color3;
  96520. /**
  96521. * Define how the color and intensity of the highlight given by the light in the material.
  96522. */
  96523. specularColor: Color3;
  96524. /**
  96525. * Define the color of the material as if self lit.
  96526. * This will be mixed in the final result even in the absence of light.
  96527. */
  96528. emissiveColor: Color3;
  96529. /**
  96530. * Defines how sharp are the highlights in the material.
  96531. * The bigger the value the sharper giving a more glossy feeling to the result.
  96532. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  96533. */
  96534. specularPower: number;
  96535. private _useAlphaFromDiffuseTexture;
  96536. /**
  96537. * Does the transparency come from the diffuse texture alpha channel.
  96538. */
  96539. useAlphaFromDiffuseTexture: boolean;
  96540. private _useEmissiveAsIllumination;
  96541. /**
  96542. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  96543. */
  96544. useEmissiveAsIllumination: boolean;
  96545. private _linkEmissiveWithDiffuse;
  96546. /**
  96547. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  96548. * the emissive level when the final color is close to one.
  96549. */
  96550. linkEmissiveWithDiffuse: boolean;
  96551. private _useSpecularOverAlpha;
  96552. /**
  96553. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  96554. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  96555. */
  96556. useSpecularOverAlpha: boolean;
  96557. private _useReflectionOverAlpha;
  96558. /**
  96559. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  96560. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  96561. */
  96562. useReflectionOverAlpha: boolean;
  96563. private _disableLighting;
  96564. /**
  96565. * Does lights from the scene impacts this material.
  96566. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  96567. */
  96568. disableLighting: boolean;
  96569. private _useObjectSpaceNormalMap;
  96570. /**
  96571. * Allows using an object space normal map (instead of tangent space).
  96572. */
  96573. useObjectSpaceNormalMap: boolean;
  96574. private _useParallax;
  96575. /**
  96576. * Is parallax enabled or not.
  96577. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96578. */
  96579. useParallax: boolean;
  96580. private _useParallaxOcclusion;
  96581. /**
  96582. * Is parallax occlusion enabled or not.
  96583. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  96584. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  96585. */
  96586. useParallaxOcclusion: boolean;
  96587. /**
  96588. * 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.
  96589. */
  96590. parallaxScaleBias: number;
  96591. private _roughness;
  96592. /**
  96593. * Helps to define how blurry the reflections should appears in the material.
  96594. */
  96595. roughness: number;
  96596. /**
  96597. * In case of refraction, define the value of the indice of refraction.
  96598. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96599. */
  96600. indexOfRefraction: number;
  96601. /**
  96602. * Invert the refraction texture alongside the y axis.
  96603. * It can be useful with procedural textures or probe for instance.
  96604. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  96605. */
  96606. invertRefractionY: boolean;
  96607. /**
  96608. * Defines the alpha limits in alpha test mode.
  96609. */
  96610. alphaCutOff: number;
  96611. private _useLightmapAsShadowmap;
  96612. /**
  96613. * In case of light mapping, define whether the map contains light or shadow informations.
  96614. */
  96615. useLightmapAsShadowmap: boolean;
  96616. private _diffuseFresnelParameters;
  96617. /**
  96618. * Define the diffuse fresnel parameters of the material.
  96619. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96620. */
  96621. diffuseFresnelParameters: FresnelParameters;
  96622. private _opacityFresnelParameters;
  96623. /**
  96624. * Define the opacity fresnel parameters of the material.
  96625. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96626. */
  96627. opacityFresnelParameters: FresnelParameters;
  96628. private _reflectionFresnelParameters;
  96629. /**
  96630. * Define the reflection fresnel parameters of the material.
  96631. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96632. */
  96633. reflectionFresnelParameters: FresnelParameters;
  96634. private _refractionFresnelParameters;
  96635. /**
  96636. * Define the refraction fresnel parameters of the material.
  96637. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96638. */
  96639. refractionFresnelParameters: FresnelParameters;
  96640. private _emissiveFresnelParameters;
  96641. /**
  96642. * Define the emissive fresnel parameters of the material.
  96643. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96644. */
  96645. emissiveFresnelParameters: FresnelParameters;
  96646. private _useReflectionFresnelFromSpecular;
  96647. /**
  96648. * If true automatically deducts the fresnels values from the material specularity.
  96649. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  96650. */
  96651. useReflectionFresnelFromSpecular: boolean;
  96652. private _useGlossinessFromSpecularMapAlpha;
  96653. /**
  96654. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  96655. */
  96656. useGlossinessFromSpecularMapAlpha: boolean;
  96657. private _maxSimultaneousLights;
  96658. /**
  96659. * Defines the maximum number of lights that can be used in the material
  96660. */
  96661. maxSimultaneousLights: number;
  96662. private _invertNormalMapX;
  96663. /**
  96664. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  96665. */
  96666. invertNormalMapX: boolean;
  96667. private _invertNormalMapY;
  96668. /**
  96669. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  96670. */
  96671. invertNormalMapY: boolean;
  96672. private _twoSidedLighting;
  96673. /**
  96674. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  96675. */
  96676. twoSidedLighting: boolean;
  96677. /**
  96678. * Default configuration related to image processing available in the standard Material.
  96679. */
  96680. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  96681. /**
  96682. * Gets the image processing configuration used either in this material.
  96683. */
  96684. /**
  96685. * Sets the Default image processing configuration used either in the this material.
  96686. *
  96687. * If sets to null, the scene one is in use.
  96688. */
  96689. imageProcessingConfiguration: ImageProcessingConfiguration;
  96690. /**
  96691. * Keep track of the image processing observer to allow dispose and replace.
  96692. */
  96693. private _imageProcessingObserver;
  96694. /**
  96695. * Attaches a new image processing configuration to the Standard Material.
  96696. * @param configuration
  96697. */
  96698. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  96699. /**
  96700. * Gets wether the color curves effect is enabled.
  96701. */
  96702. /**
  96703. * Sets wether the color curves effect is enabled.
  96704. */
  96705. cameraColorCurvesEnabled: boolean;
  96706. /**
  96707. * Gets wether the color grading effect is enabled.
  96708. */
  96709. /**
  96710. * Gets wether the color grading effect is enabled.
  96711. */
  96712. cameraColorGradingEnabled: boolean;
  96713. /**
  96714. * Gets wether tonemapping is enabled or not.
  96715. */
  96716. /**
  96717. * Sets wether tonemapping is enabled or not
  96718. */
  96719. cameraToneMappingEnabled: boolean;
  96720. /**
  96721. * The camera exposure used on this material.
  96722. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  96723. * This corresponds to a photographic exposure.
  96724. */
  96725. /**
  96726. * The camera exposure used on this material.
  96727. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  96728. * This corresponds to a photographic exposure.
  96729. */
  96730. cameraExposure: number;
  96731. /**
  96732. * Gets The camera contrast used on this material.
  96733. */
  96734. /**
  96735. * Sets The camera contrast used on this material.
  96736. */
  96737. cameraContrast: number;
  96738. /**
  96739. * Gets the Color Grading 2D Lookup Texture.
  96740. */
  96741. /**
  96742. * Sets the Color Grading 2D Lookup Texture.
  96743. */
  96744. cameraColorGradingTexture: Nullable<BaseTexture>;
  96745. /**
  96746. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  96747. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  96748. * 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;
  96749. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  96750. */
  96751. /**
  96752. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  96753. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  96754. * 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;
  96755. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  96756. */
  96757. cameraColorCurves: Nullable<ColorCurves>;
  96758. /**
  96759. * Custom callback helping to override the default shader used in the material.
  96760. */
  96761. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  96762. protected _renderTargets: SmartArray<RenderTargetTexture>;
  96763. protected _worldViewProjectionMatrix: Matrix;
  96764. protected _globalAmbientColor: Color3;
  96765. protected _useLogarithmicDepth: boolean;
  96766. /**
  96767. * Instantiates a new standard material.
  96768. * This is the default material used in Babylon. It is the best trade off between quality
  96769. * and performances.
  96770. * @see http://doc.babylonjs.com/babylon101/materials
  96771. * @param name Define the name of the material in the scene
  96772. * @param scene Define the scene the material belong to
  96773. */
  96774. constructor(name: string, scene: Scene);
  96775. /**
  96776. * Gets a boolean indicating that current material needs to register RTT
  96777. */
  96778. readonly hasRenderTargetTextures: boolean;
  96779. /**
  96780. * Gets the current class name of the material e.g. "StandardMaterial"
  96781. * Mainly use in serialization.
  96782. * @returns the class name
  96783. */
  96784. getClassName(): string;
  96785. /**
  96786. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  96787. * You can try switching to logarithmic depth.
  96788. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  96789. */
  96790. useLogarithmicDepth: boolean;
  96791. /**
  96792. * Specifies if the material will require alpha blending
  96793. * @returns a boolean specifying if alpha blending is needed
  96794. */
  96795. needAlphaBlending(): boolean;
  96796. /**
  96797. * Specifies if this material should be rendered in alpha test mode
  96798. * @returns a boolean specifying if an alpha test is needed.
  96799. */
  96800. needAlphaTesting(): boolean;
  96801. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  96802. /**
  96803. * Get the texture used for alpha test purpose.
  96804. * @returns the diffuse texture in case of the standard material.
  96805. */
  96806. getAlphaTestTexture(): Nullable<BaseTexture>;
  96807. /**
  96808. * Get if the submesh is ready to be used and all its information available.
  96809. * Child classes can use it to update shaders
  96810. * @param mesh defines the mesh to check
  96811. * @param subMesh defines which submesh to check
  96812. * @param useInstances specifies that instances should be used
  96813. * @returns a boolean indicating that the submesh is ready or not
  96814. */
  96815. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  96816. /**
  96817. * Builds the material UBO layouts.
  96818. * Used internally during the effect preparation.
  96819. */
  96820. buildUniformLayout(): void;
  96821. /**
  96822. * Unbinds the material from the mesh
  96823. */
  96824. unbind(): void;
  96825. /**
  96826. * Binds the submesh to this material by preparing the effect and shader to draw
  96827. * @param world defines the world transformation matrix
  96828. * @param mesh defines the mesh containing the submesh
  96829. * @param subMesh defines the submesh to bind the material to
  96830. */
  96831. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  96832. /**
  96833. * Get the list of animatables in the material.
  96834. * @returns the list of animatables object used in the material
  96835. */
  96836. getAnimatables(): IAnimatable[];
  96837. /**
  96838. * Gets the active textures from the material
  96839. * @returns an array of textures
  96840. */
  96841. getActiveTextures(): BaseTexture[];
  96842. /**
  96843. * Specifies if the material uses a texture
  96844. * @param texture defines the texture to check against the material
  96845. * @returns a boolean specifying if the material uses the texture
  96846. */
  96847. hasTexture(texture: BaseTexture): boolean;
  96848. /**
  96849. * Disposes the material
  96850. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  96851. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  96852. */
  96853. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  96854. /**
  96855. * Makes a duplicate of the material, and gives it a new name
  96856. * @param name defines the new name for the duplicated material
  96857. * @returns the cloned material
  96858. */
  96859. clone(name: string): StandardMaterial;
  96860. /**
  96861. * Serializes this material in a JSON representation
  96862. * @returns the serialized material object
  96863. */
  96864. serialize(): any;
  96865. /**
  96866. * Creates a standard material from parsed material data
  96867. * @param source defines the JSON representation of the material
  96868. * @param scene defines the hosting scene
  96869. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  96870. * @returns a new standard material
  96871. */
  96872. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  96873. /**
  96874. * Are diffuse textures enabled in the application.
  96875. */
  96876. static DiffuseTextureEnabled: boolean;
  96877. /**
  96878. * Are ambient textures enabled in the application.
  96879. */
  96880. static AmbientTextureEnabled: boolean;
  96881. /**
  96882. * Are opacity textures enabled in the application.
  96883. */
  96884. static OpacityTextureEnabled: boolean;
  96885. /**
  96886. * Are reflection textures enabled in the application.
  96887. */
  96888. static ReflectionTextureEnabled: boolean;
  96889. /**
  96890. * Are emissive textures enabled in the application.
  96891. */
  96892. static EmissiveTextureEnabled: boolean;
  96893. /**
  96894. * Are specular textures enabled in the application.
  96895. */
  96896. static SpecularTextureEnabled: boolean;
  96897. /**
  96898. * Are bump textures enabled in the application.
  96899. */
  96900. static BumpTextureEnabled: boolean;
  96901. /**
  96902. * Are lightmap textures enabled in the application.
  96903. */
  96904. static LightmapTextureEnabled: boolean;
  96905. /**
  96906. * Are refraction textures enabled in the application.
  96907. */
  96908. static RefractionTextureEnabled: boolean;
  96909. /**
  96910. * Are color grading textures enabled in the application.
  96911. */
  96912. static ColorGradingTextureEnabled: boolean;
  96913. /**
  96914. * Are fresnels enabled in the application.
  96915. */
  96916. static FresnelEnabled: boolean;
  96917. }
  96918. }
  96919. declare module BABYLON {
  96920. /**
  96921. * A class extending Texture allowing drawing on a texture
  96922. * @see http://doc.babylonjs.com/how_to/dynamictexture
  96923. */
  96924. export class DynamicTexture extends Texture {
  96925. private _generateMipMaps;
  96926. private _canvas;
  96927. private _context;
  96928. private _engine;
  96929. /**
  96930. * Creates a DynamicTexture
  96931. * @param name defines the name of the texture
  96932. * @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
  96933. * @param scene defines the scene where you want the texture
  96934. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  96935. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  96936. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  96937. */
  96938. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  96939. /**
  96940. * Get the current class name of the texture useful for serialization or dynamic coding.
  96941. * @returns "DynamicTexture"
  96942. */
  96943. getClassName(): string;
  96944. /**
  96945. * Gets the current state of canRescale
  96946. */
  96947. readonly canRescale: boolean;
  96948. private _recreate;
  96949. /**
  96950. * Scales the texture
  96951. * @param ratio the scale factor to apply to both width and height
  96952. */
  96953. scale(ratio: number): void;
  96954. /**
  96955. * Resizes the texture
  96956. * @param width the new width
  96957. * @param height the new height
  96958. */
  96959. scaleTo(width: number, height: number): void;
  96960. /**
  96961. * Gets the context of the canvas used by the texture
  96962. * @returns the canvas context of the dynamic texture
  96963. */
  96964. getContext(): CanvasRenderingContext2D;
  96965. /**
  96966. * Clears the texture
  96967. */
  96968. clear(): void;
  96969. /**
  96970. * Updates the texture
  96971. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  96972. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  96973. */
  96974. update(invertY?: boolean, premulAlpha?: boolean): void;
  96975. /**
  96976. * Draws text onto the texture
  96977. * @param text defines the text to be drawn
  96978. * @param x defines the placement of the text from the left
  96979. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  96980. * @param font defines the font to be used with font-style, font-size, font-name
  96981. * @param color defines the color used for the text
  96982. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  96983. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  96984. * @param update defines whether texture is immediately update (default is true)
  96985. */
  96986. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  96987. /**
  96988. * Clones the texture
  96989. * @returns the clone of the texture.
  96990. */
  96991. clone(): DynamicTexture;
  96992. /**
  96993. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  96994. * @returns a serialized dynamic texture object
  96995. */
  96996. serialize(): any;
  96997. /** @hidden */
  96998. _rebuild(): void;
  96999. }
  97000. }
  97001. declare module BABYLON {
  97002. /** @hidden */
  97003. export var imageProcessingPixelShader: {
  97004. name: string;
  97005. shader: string;
  97006. };
  97007. }
  97008. declare module BABYLON {
  97009. /**
  97010. * ImageProcessingPostProcess
  97011. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  97012. */
  97013. export class ImageProcessingPostProcess extends PostProcess {
  97014. /**
  97015. * Default configuration related to image processing available in the PBR Material.
  97016. */
  97017. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97018. /**
  97019. * Gets the image processing configuration used either in this material.
  97020. */
  97021. /**
  97022. * Sets the Default image processing configuration used either in the this material.
  97023. *
  97024. * If sets to null, the scene one is in use.
  97025. */
  97026. imageProcessingConfiguration: ImageProcessingConfiguration;
  97027. /**
  97028. * Keep track of the image processing observer to allow dispose and replace.
  97029. */
  97030. private _imageProcessingObserver;
  97031. /**
  97032. * Attaches a new image processing configuration to the PBR Material.
  97033. * @param configuration
  97034. */
  97035. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  97036. /**
  97037. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  97038. */
  97039. /**
  97040. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  97041. */
  97042. colorCurves: Nullable<ColorCurves>;
  97043. /**
  97044. * Gets wether the color curves effect is enabled.
  97045. */
  97046. /**
  97047. * Sets wether the color curves effect is enabled.
  97048. */
  97049. colorCurvesEnabled: boolean;
  97050. /**
  97051. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  97052. */
  97053. /**
  97054. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  97055. */
  97056. colorGradingTexture: Nullable<BaseTexture>;
  97057. /**
  97058. * Gets wether the color grading effect is enabled.
  97059. */
  97060. /**
  97061. * Gets wether the color grading effect is enabled.
  97062. */
  97063. colorGradingEnabled: boolean;
  97064. /**
  97065. * Gets exposure used in the effect.
  97066. */
  97067. /**
  97068. * Sets exposure used in the effect.
  97069. */
  97070. exposure: number;
  97071. /**
  97072. * Gets wether tonemapping is enabled or not.
  97073. */
  97074. /**
  97075. * Sets wether tonemapping is enabled or not
  97076. */
  97077. toneMappingEnabled: boolean;
  97078. /**
  97079. * Gets the type of tone mapping effect.
  97080. */
  97081. /**
  97082. * Sets the type of tone mapping effect.
  97083. */
  97084. toneMappingType: number;
  97085. /**
  97086. * Gets contrast used in the effect.
  97087. */
  97088. /**
  97089. * Sets contrast used in the effect.
  97090. */
  97091. contrast: number;
  97092. /**
  97093. * Gets Vignette stretch size.
  97094. */
  97095. /**
  97096. * Sets Vignette stretch size.
  97097. */
  97098. vignetteStretch: number;
  97099. /**
  97100. * Gets Vignette centre X Offset.
  97101. */
  97102. /**
  97103. * Sets Vignette centre X Offset.
  97104. */
  97105. vignetteCentreX: number;
  97106. /**
  97107. * Gets Vignette centre Y Offset.
  97108. */
  97109. /**
  97110. * Sets Vignette centre Y Offset.
  97111. */
  97112. vignetteCentreY: number;
  97113. /**
  97114. * Gets Vignette weight or intensity of the vignette effect.
  97115. */
  97116. /**
  97117. * Sets Vignette weight or intensity of the vignette effect.
  97118. */
  97119. vignetteWeight: number;
  97120. /**
  97121. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  97122. * if vignetteEnabled is set to true.
  97123. */
  97124. /**
  97125. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  97126. * if vignetteEnabled is set to true.
  97127. */
  97128. vignetteColor: Color4;
  97129. /**
  97130. * Gets Camera field of view used by the Vignette effect.
  97131. */
  97132. /**
  97133. * Sets Camera field of view used by the Vignette effect.
  97134. */
  97135. vignetteCameraFov: number;
  97136. /**
  97137. * Gets the vignette blend mode allowing different kind of effect.
  97138. */
  97139. /**
  97140. * Sets the vignette blend mode allowing different kind of effect.
  97141. */
  97142. vignetteBlendMode: number;
  97143. /**
  97144. * Gets wether the vignette effect is enabled.
  97145. */
  97146. /**
  97147. * Sets wether the vignette effect is enabled.
  97148. */
  97149. vignetteEnabled: boolean;
  97150. private _fromLinearSpace;
  97151. /**
  97152. * Gets wether the input of the processing is in Gamma or Linear Space.
  97153. */
  97154. /**
  97155. * Sets wether the input of the processing is in Gamma or Linear Space.
  97156. */
  97157. fromLinearSpace: boolean;
  97158. /**
  97159. * Defines cache preventing GC.
  97160. */
  97161. private _defines;
  97162. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  97163. /**
  97164. * "ImageProcessingPostProcess"
  97165. * @returns "ImageProcessingPostProcess"
  97166. */
  97167. getClassName(): string;
  97168. protected _updateParameters(): void;
  97169. dispose(camera?: Camera): void;
  97170. }
  97171. }
  97172. declare module BABYLON {
  97173. /**
  97174. * Class containing static functions to help procedurally build meshes
  97175. */
  97176. export class GroundBuilder {
  97177. /**
  97178. * Creates a ground mesh
  97179. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  97180. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  97181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97182. * @param name defines the name of the mesh
  97183. * @param options defines the options used to create the mesh
  97184. * @param scene defines the hosting scene
  97185. * @returns the ground mesh
  97186. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  97187. */
  97188. static CreateGround(name: string, options: {
  97189. width?: number;
  97190. height?: number;
  97191. subdivisions?: number;
  97192. subdivisionsX?: number;
  97193. subdivisionsY?: number;
  97194. updatable?: boolean;
  97195. }, scene: any): Mesh;
  97196. /**
  97197. * Creates a tiled ground mesh
  97198. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  97199. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  97200. * * 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
  97201. * * 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
  97202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97203. * @param name defines the name of the mesh
  97204. * @param options defines the options used to create the mesh
  97205. * @param scene defines the hosting scene
  97206. * @returns the tiled ground mesh
  97207. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  97208. */
  97209. static CreateTiledGround(name: string, options: {
  97210. xmin: number;
  97211. zmin: number;
  97212. xmax: number;
  97213. zmax: number;
  97214. subdivisions?: {
  97215. w: number;
  97216. h: number;
  97217. };
  97218. precision?: {
  97219. w: number;
  97220. h: number;
  97221. };
  97222. updatable?: boolean;
  97223. }, scene: Scene): Mesh;
  97224. /**
  97225. * Creates a ground mesh from a height map
  97226. * * The parameter `url` sets the URL of the height map image resource.
  97227. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  97228. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  97229. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  97230. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  97231. * * 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.
  97232. * * 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).
  97233. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  97234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97235. * @param name defines the name of the mesh
  97236. * @param url defines the url to the height map
  97237. * @param options defines the options used to create the mesh
  97238. * @param scene defines the hosting scene
  97239. * @returns the ground mesh
  97240. * @see https://doc.babylonjs.com/babylon101/height_map
  97241. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  97242. */
  97243. static CreateGroundFromHeightMap(name: string, url: string, options: {
  97244. width?: number;
  97245. height?: number;
  97246. subdivisions?: number;
  97247. minHeight?: number;
  97248. maxHeight?: number;
  97249. colorFilter?: Color3;
  97250. alphaFilter?: number;
  97251. updatable?: boolean;
  97252. onReady?: (mesh: GroundMesh) => void;
  97253. }, scene: Scene): GroundMesh;
  97254. }
  97255. }
  97256. declare module BABYLON {
  97257. /**
  97258. * Class containing static functions to help procedurally build meshes
  97259. */
  97260. export class TorusBuilder {
  97261. /**
  97262. * Creates a torus mesh
  97263. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  97264. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  97265. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  97266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97267. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97269. * @param name defines the name of the mesh
  97270. * @param options defines the options used to create the mesh
  97271. * @param scene defines the hosting scene
  97272. * @returns the torus mesh
  97273. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  97274. */
  97275. static CreateTorus(name: string, options: {
  97276. diameter?: number;
  97277. thickness?: number;
  97278. tessellation?: number;
  97279. updatable?: boolean;
  97280. sideOrientation?: number;
  97281. frontUVs?: Vector4;
  97282. backUVs?: Vector4;
  97283. }, scene: any): Mesh;
  97284. }
  97285. }
  97286. declare module BABYLON {
  97287. /**
  97288. * Class containing static functions to help procedurally build meshes
  97289. */
  97290. export class CylinderBuilder {
  97291. /**
  97292. * Creates a cylinder or a cone mesh
  97293. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  97294. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  97295. * * 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.
  97296. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  97297. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  97298. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  97299. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  97300. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  97301. * * 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).
  97302. * * 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
  97303. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  97304. * * 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
  97305. * * 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.
  97306. * * If `enclose` is false, a ring surface is one element.
  97307. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  97308. * * 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
  97309. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97310. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  97312. * @param name defines the name of the mesh
  97313. * @param options defines the options used to create the mesh
  97314. * @param scene defines the hosting scene
  97315. * @returns the cylinder mesh
  97316. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  97317. */
  97318. static CreateCylinder(name: string, options: {
  97319. height?: number;
  97320. diameterTop?: number;
  97321. diameterBottom?: number;
  97322. diameter?: number;
  97323. tessellation?: number;
  97324. subdivisions?: number;
  97325. arc?: number;
  97326. faceColors?: Color4[];
  97327. faceUV?: Vector4[];
  97328. updatable?: boolean;
  97329. hasRings?: boolean;
  97330. enclose?: boolean;
  97331. sideOrientation?: number;
  97332. frontUVs?: Vector4;
  97333. backUVs?: Vector4;
  97334. }, scene: any): Mesh;
  97335. }
  97336. }
  97337. declare module BABYLON {
  97338. /**
  97339. * Manager for handling gamepads
  97340. */
  97341. export class GamepadManager {
  97342. private _scene?;
  97343. private _babylonGamepads;
  97344. private _oneGamepadConnected;
  97345. /** @hidden */
  97346. _isMonitoring: boolean;
  97347. private _gamepadEventSupported;
  97348. private _gamepadSupport;
  97349. /**
  97350. * observable to be triggered when the gamepad controller has been connected
  97351. */
  97352. onGamepadConnectedObservable: Observable<Gamepad>;
  97353. /**
  97354. * observable to be triggered when the gamepad controller has been disconnected
  97355. */
  97356. onGamepadDisconnectedObservable: Observable<Gamepad>;
  97357. private _onGamepadConnectedEvent;
  97358. private _onGamepadDisconnectedEvent;
  97359. /**
  97360. * Initializes the gamepad manager
  97361. * @param _scene BabylonJS scene
  97362. */
  97363. constructor(_scene?: Scene | undefined);
  97364. /**
  97365. * The gamepads in the game pad manager
  97366. */
  97367. readonly gamepads: Gamepad[];
  97368. /**
  97369. * Get the gamepad controllers based on type
  97370. * @param type The type of gamepad controller
  97371. * @returns Nullable gamepad
  97372. */
  97373. getGamepadByType(type?: number): Nullable<Gamepad>;
  97374. /**
  97375. * Disposes the gamepad manager
  97376. */
  97377. dispose(): void;
  97378. private _addNewGamepad;
  97379. private _startMonitoringGamepads;
  97380. private _stopMonitoringGamepads;
  97381. /** @hidden */
  97382. _checkGamepadsStatus(): void;
  97383. private _updateGamepadObjects;
  97384. }
  97385. }
  97386. declare module BABYLON {
  97387. interface Scene {
  97388. /** @hidden */
  97389. _gamepadManager: Nullable<GamepadManager>;
  97390. /**
  97391. * Gets the gamepad manager associated with the scene
  97392. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  97393. */
  97394. gamepadManager: GamepadManager;
  97395. }
  97396. /**
  97397. * Interface representing a free camera inputs manager
  97398. */
  97399. interface FreeCameraInputsManager {
  97400. /**
  97401. * Adds gamepad input support to the FreeCameraInputsManager.
  97402. * @returns the FreeCameraInputsManager
  97403. */
  97404. addGamepad(): FreeCameraInputsManager;
  97405. }
  97406. /**
  97407. * Interface representing an arc rotate camera inputs manager
  97408. */
  97409. interface ArcRotateCameraInputsManager {
  97410. /**
  97411. * Adds gamepad input support to the ArcRotateCamera InputManager.
  97412. * @returns the camera inputs manager
  97413. */
  97414. addGamepad(): ArcRotateCameraInputsManager;
  97415. }
  97416. /**
  97417. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  97418. */
  97419. export class GamepadSystemSceneComponent implements ISceneComponent {
  97420. /**
  97421. * The component name helpfull to identify the component in the list of scene components.
  97422. */
  97423. readonly name: string;
  97424. /**
  97425. * The scene the component belongs to.
  97426. */
  97427. scene: Scene;
  97428. /**
  97429. * Creates a new instance of the component for the given scene
  97430. * @param scene Defines the scene to register the component in
  97431. */
  97432. constructor(scene: Scene);
  97433. /**
  97434. * Registers the component in a given scene
  97435. */
  97436. register(): void;
  97437. /**
  97438. * Rebuilds the elements related to this component in case of
  97439. * context lost for instance.
  97440. */
  97441. rebuild(): void;
  97442. /**
  97443. * Disposes the component and the associated ressources
  97444. */
  97445. dispose(): void;
  97446. private _beforeCameraUpdate;
  97447. }
  97448. }
  97449. declare module BABYLON {
  97450. /**
  97451. * Options to modify the vr teleportation behavior.
  97452. */
  97453. export interface VRTeleportationOptions {
  97454. /**
  97455. * The name of the mesh which should be used as the teleportation floor. (default: null)
  97456. */
  97457. floorMeshName?: string;
  97458. /**
  97459. * A list of meshes to be used as the teleportation floor. (default: empty)
  97460. */
  97461. floorMeshes?: Mesh[];
  97462. }
  97463. /**
  97464. * Options to modify the vr experience helper's behavior.
  97465. */
  97466. export interface VRExperienceHelperOptions extends WebVROptions {
  97467. /**
  97468. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  97469. */
  97470. createDeviceOrientationCamera?: boolean;
  97471. /**
  97472. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  97473. */
  97474. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  97475. /**
  97476. * Uses the main button on the controller to toggle the laser casted. (default: true)
  97477. */
  97478. laserToggle?: boolean;
  97479. /**
  97480. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  97481. */
  97482. floorMeshes?: Mesh[];
  97483. /**
  97484. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  97485. */
  97486. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  97487. }
  97488. /**
  97489. * Event containing information after VR has been entered
  97490. */
  97491. export class OnAfterEnteringVRObservableEvent {
  97492. /**
  97493. * If entering vr was successful
  97494. */
  97495. success: boolean;
  97496. }
  97497. /**
  97498. * Helps to quickly add VR support to an existing scene.
  97499. * See http://doc.babylonjs.com/how_to/webvr_helper
  97500. */
  97501. export class VRExperienceHelper {
  97502. /** Options to modify the vr experience helper's behavior. */
  97503. webVROptions: VRExperienceHelperOptions;
  97504. private _scene;
  97505. private _position;
  97506. private _btnVR;
  97507. private _btnVRDisplayed;
  97508. private _webVRsupported;
  97509. private _webVRready;
  97510. private _webVRrequesting;
  97511. private _webVRpresenting;
  97512. private _hasEnteredVR;
  97513. private _fullscreenVRpresenting;
  97514. private _canvas;
  97515. private _webVRCamera;
  97516. private _vrDeviceOrientationCamera;
  97517. private _deviceOrientationCamera;
  97518. private _existingCamera;
  97519. private _onKeyDown;
  97520. private _onVrDisplayPresentChange;
  97521. private _onVRDisplayChanged;
  97522. private _onVRRequestPresentStart;
  97523. private _onVRRequestPresentComplete;
  97524. /**
  97525. * Observable raised right before entering VR.
  97526. */
  97527. onEnteringVRObservable: Observable<VRExperienceHelper>;
  97528. /**
  97529. * Observable raised when entering VR has completed.
  97530. */
  97531. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  97532. /**
  97533. * Observable raised when exiting VR.
  97534. */
  97535. onExitingVRObservable: Observable<VRExperienceHelper>;
  97536. /**
  97537. * Observable raised when controller mesh is loaded.
  97538. */
  97539. onControllerMeshLoadedObservable: Observable<WebVRController>;
  97540. /** Return this.onEnteringVRObservable
  97541. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  97542. */
  97543. readonly onEnteringVR: Observable<VRExperienceHelper>;
  97544. /** Return this.onExitingVRObservable
  97545. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  97546. */
  97547. readonly onExitingVR: Observable<VRExperienceHelper>;
  97548. /** Return this.onControllerMeshLoadedObservable
  97549. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  97550. */
  97551. readonly onControllerMeshLoaded: Observable<WebVRController>;
  97552. private _rayLength;
  97553. private _useCustomVRButton;
  97554. private _teleportationRequested;
  97555. private _teleportActive;
  97556. private _floorMeshName;
  97557. private _floorMeshesCollection;
  97558. private _rotationAllowed;
  97559. private _teleportBackwardsVector;
  97560. private _teleportationTarget;
  97561. private _isDefaultTeleportationTarget;
  97562. private _postProcessMove;
  97563. private _teleportationFillColor;
  97564. private _teleportationBorderColor;
  97565. private _rotationAngle;
  97566. private _haloCenter;
  97567. private _cameraGazer;
  97568. private _padSensibilityUp;
  97569. private _padSensibilityDown;
  97570. private _leftController;
  97571. private _rightController;
  97572. /**
  97573. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  97574. */
  97575. onNewMeshSelected: Observable<AbstractMesh>;
  97576. /**
  97577. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  97578. */
  97579. onNewMeshPicked: Observable<PickingInfo>;
  97580. private _circleEase;
  97581. /**
  97582. * Observable raised before camera teleportation
  97583. */
  97584. onBeforeCameraTeleport: Observable<Vector3>;
  97585. /**
  97586. * Observable raised after camera teleportation
  97587. */
  97588. onAfterCameraTeleport: Observable<Vector3>;
  97589. /**
  97590. * Observable raised when current selected mesh gets unselected
  97591. */
  97592. onSelectedMeshUnselected: Observable<AbstractMesh>;
  97593. private _raySelectionPredicate;
  97594. /**
  97595. * To be optionaly changed by user to define custom ray selection
  97596. */
  97597. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  97598. /**
  97599. * To be optionaly changed by user to define custom selection logic (after ray selection)
  97600. */
  97601. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  97602. /**
  97603. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  97604. */
  97605. teleportationEnabled: boolean;
  97606. private _defaultHeight;
  97607. private _teleportationInitialized;
  97608. private _interactionsEnabled;
  97609. private _interactionsRequested;
  97610. private _displayGaze;
  97611. private _displayLaserPointer;
  97612. /**
  97613. * The mesh used to display where the user is going to teleport.
  97614. */
  97615. /**
  97616. * Sets the mesh to be used to display where the user is going to teleport.
  97617. */
  97618. teleportationTarget: Mesh;
  97619. /**
  97620. * 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
  97621. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  97622. * See http://doc.babylonjs.com/resources/baking_transformations
  97623. */
  97624. gazeTrackerMesh: Mesh;
  97625. /**
  97626. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  97627. */
  97628. updateGazeTrackerScale: boolean;
  97629. /**
  97630. * If the gaze trackers color should be updated when selecting meshes
  97631. */
  97632. updateGazeTrackerColor: boolean;
  97633. /**
  97634. * The gaze tracking mesh corresponding to the left controller
  97635. */
  97636. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  97637. /**
  97638. * The gaze tracking mesh corresponding to the right controller
  97639. */
  97640. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  97641. /**
  97642. * If the ray of the gaze should be displayed.
  97643. */
  97644. /**
  97645. * Sets if the ray of the gaze should be displayed.
  97646. */
  97647. displayGaze: boolean;
  97648. /**
  97649. * If the ray of the LaserPointer should be displayed.
  97650. */
  97651. /**
  97652. * Sets if the ray of the LaserPointer should be displayed.
  97653. */
  97654. displayLaserPointer: boolean;
  97655. /**
  97656. * The deviceOrientationCamera used as the camera when not in VR.
  97657. */
  97658. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  97659. /**
  97660. * Based on the current WebVR support, returns the current VR camera used.
  97661. */
  97662. readonly currentVRCamera: Nullable<Camera>;
  97663. /**
  97664. * The webVRCamera which is used when in VR.
  97665. */
  97666. readonly webVRCamera: WebVRFreeCamera;
  97667. /**
  97668. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  97669. */
  97670. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  97671. private readonly _teleportationRequestInitiated;
  97672. /**
  97673. * Defines wether or not Pointer lock should be requested when switching to
  97674. * full screen.
  97675. */
  97676. requestPointerLockOnFullScreen: boolean;
  97677. /**
  97678. * Instantiates a VRExperienceHelper.
  97679. * Helps to quickly add VR support to an existing scene.
  97680. * @param scene The scene the VRExperienceHelper belongs to.
  97681. * @param webVROptions Options to modify the vr experience helper's behavior.
  97682. */
  97683. constructor(scene: Scene,
  97684. /** Options to modify the vr experience helper's behavior. */
  97685. webVROptions?: VRExperienceHelperOptions);
  97686. private _onDefaultMeshLoaded;
  97687. private _onResize;
  97688. private _onFullscreenChange;
  97689. /**
  97690. * Gets a value indicating if we are currently in VR mode.
  97691. */
  97692. readonly isInVRMode: boolean;
  97693. private onVrDisplayPresentChange;
  97694. private onVRDisplayChanged;
  97695. private moveButtonToBottomRight;
  97696. private displayVRButton;
  97697. private updateButtonVisibility;
  97698. private _cachedAngularSensibility;
  97699. /**
  97700. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  97701. * Otherwise, will use the fullscreen API.
  97702. */
  97703. enterVR(): void;
  97704. /**
  97705. * Attempt to exit VR, or fullscreen.
  97706. */
  97707. exitVR(): void;
  97708. /**
  97709. * The position of the vr experience helper.
  97710. */
  97711. /**
  97712. * Sets the position of the vr experience helper.
  97713. */
  97714. position: Vector3;
  97715. /**
  97716. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  97717. */
  97718. enableInteractions(): void;
  97719. private readonly _noControllerIsActive;
  97720. private beforeRender;
  97721. private _isTeleportationFloor;
  97722. /**
  97723. * Adds a floor mesh to be used for teleportation.
  97724. * @param floorMesh the mesh to be used for teleportation.
  97725. */
  97726. addFloorMesh(floorMesh: Mesh): void;
  97727. /**
  97728. * Removes a floor mesh from being used for teleportation.
  97729. * @param floorMesh the mesh to be removed.
  97730. */
  97731. removeFloorMesh(floorMesh: Mesh): void;
  97732. /**
  97733. * Enables interactions and teleportation using the VR controllers and gaze.
  97734. * @param vrTeleportationOptions options to modify teleportation behavior.
  97735. */
  97736. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  97737. private _onNewGamepadConnected;
  97738. private _tryEnableInteractionOnController;
  97739. private _onNewGamepadDisconnected;
  97740. private _enableInteractionOnController;
  97741. private _checkTeleportWithRay;
  97742. private _checkRotate;
  97743. private _checkTeleportBackwards;
  97744. private _enableTeleportationOnController;
  97745. private _createTeleportationCircles;
  97746. private _displayTeleportationTarget;
  97747. private _hideTeleportationTarget;
  97748. private _rotateCamera;
  97749. private _moveTeleportationSelectorTo;
  97750. private _workingVector;
  97751. private _workingQuaternion;
  97752. private _workingMatrix;
  97753. /**
  97754. * Teleports the users feet to the desired location
  97755. * @param location The location where the user's feet should be placed
  97756. */
  97757. teleportCamera(location: Vector3): void;
  97758. private _convertNormalToDirectionOfRay;
  97759. private _castRayAndSelectObject;
  97760. private _notifySelectedMeshUnselected;
  97761. /**
  97762. * Sets the color of the laser ray from the vr controllers.
  97763. * @param color new color for the ray.
  97764. */
  97765. changeLaserColor(color: Color3): void;
  97766. /**
  97767. * Sets the color of the ray from the vr headsets gaze.
  97768. * @param color new color for the ray.
  97769. */
  97770. changeGazeColor(color: Color3): void;
  97771. /**
  97772. * Exits VR and disposes of the vr experience helper
  97773. */
  97774. dispose(): void;
  97775. /**
  97776. * Gets the name of the VRExperienceHelper class
  97777. * @returns "VRExperienceHelper"
  97778. */
  97779. getClassName(): string;
  97780. }
  97781. }
  97782. declare module BABYLON {
  97783. /**
  97784. * Manages an XRSession
  97785. * @see https://doc.babylonjs.com/how_to/webxr
  97786. */
  97787. export class WebXRSessionManager implements IDisposable {
  97788. private scene;
  97789. /**
  97790. * Fires every time a new xrFrame arrives which can be used to update the camera
  97791. */
  97792. onXRFrameObservable: Observable<any>;
  97793. /**
  97794. * Fires when the xr session is ended either by the device or manually done
  97795. */
  97796. onXRSessionEnded: Observable<any>;
  97797. /** @hidden */
  97798. _xrSession: XRSession;
  97799. /** @hidden */
  97800. _frameOfReference: XRFrameOfReference;
  97801. /** @hidden */
  97802. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  97803. /** @hidden */
  97804. _currentXRFrame: Nullable<XRFrame>;
  97805. private _xrNavigator;
  97806. private _xrDevice;
  97807. private _tmpMatrix;
  97808. /**
  97809. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  97810. * @param scene The scene which the session should be created for
  97811. */
  97812. constructor(scene: Scene);
  97813. /**
  97814. * Initializes the manager
  97815. * After initialization enterXR can be called to start an XR session
  97816. * @returns Promise which resolves after it is initialized
  97817. */
  97818. initializeAsync(): Promise<void>;
  97819. /**
  97820. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  97821. * @param sessionCreationOptions xr options to create the session with
  97822. * @param frameOfReferenceType option to configure how the xr pose is expressed
  97823. * @returns Promise which resolves after it enters XR
  97824. */
  97825. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  97826. /**
  97827. * Stops the xrSession and restores the renderloop
  97828. * @returns Promise which resolves after it exits XR
  97829. */
  97830. exitXRAsync(): Promise<void>;
  97831. /**
  97832. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  97833. * @param ray ray to cast into the environment
  97834. * @returns Promise which resolves with a collision point in the environment if it exists
  97835. */
  97836. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  97837. /**
  97838. * Checks if a session would be supported for the creation options specified
  97839. * @param options creation options to check if they are supported
  97840. * @returns true if supported
  97841. */
  97842. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  97843. /**
  97844. * @hidden
  97845. * Converts the render layer of xrSession to a render target
  97846. * @param session session to create render target for
  97847. * @param scene scene the new render target should be created for
  97848. */
  97849. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  97850. /**
  97851. * Disposes of the session manager
  97852. */
  97853. dispose(): void;
  97854. }
  97855. }
  97856. declare module BABYLON {
  97857. /**
  97858. * WebXR Camera which holds the views for the xrSession
  97859. * @see https://doc.babylonjs.com/how_to/webxr
  97860. */
  97861. export class WebXRCamera extends FreeCamera {
  97862. private static _TmpMatrix;
  97863. /**
  97864. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  97865. * @param name the name of the camera
  97866. * @param scene the scene to add the camera to
  97867. */
  97868. constructor(name: string, scene: Scene);
  97869. private _updateNumberOfRigCameras;
  97870. /** @hidden */
  97871. _updateForDualEyeDebugging(pupilDistance?: number): void;
  97872. /**
  97873. * Updates the cameras position from the current pose information of the XR session
  97874. * @param xrSessionManager the session containing pose information
  97875. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  97876. */
  97877. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  97878. }
  97879. }
  97880. declare module BABYLON {
  97881. /**
  97882. * States of the webXR experience
  97883. */
  97884. export enum WebXRState {
  97885. /**
  97886. * Transitioning to being in XR mode
  97887. */
  97888. ENTERING_XR = 0,
  97889. /**
  97890. * Transitioning to non XR mode
  97891. */
  97892. EXITING_XR = 1,
  97893. /**
  97894. * In XR mode and presenting
  97895. */
  97896. IN_XR = 2,
  97897. /**
  97898. * Not entered XR mode
  97899. */
  97900. NOT_IN_XR = 3
  97901. }
  97902. /**
  97903. * Helper class used to enable XR
  97904. * @see https://doc.babylonjs.com/how_to/webxr
  97905. */
  97906. export class WebXRExperienceHelper implements IDisposable {
  97907. private scene;
  97908. /**
  97909. * 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
  97910. */
  97911. container: AbstractMesh;
  97912. /**
  97913. * Camera used to render xr content
  97914. */
  97915. camera: WebXRCamera;
  97916. /**
  97917. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  97918. */
  97919. state: WebXRState;
  97920. private _setState;
  97921. private static _TmpVector;
  97922. /**
  97923. * Fires when the state of the experience helper has changed
  97924. */
  97925. onStateChangedObservable: Observable<WebXRState>;
  97926. /** @hidden */
  97927. _sessionManager: WebXRSessionManager;
  97928. private _nonVRCamera;
  97929. private _originalSceneAutoClear;
  97930. private _supported;
  97931. /**
  97932. * Creates the experience helper
  97933. * @param scene the scene to attach the experience helper to
  97934. * @returns a promise for the experience helper
  97935. */
  97936. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  97937. /**
  97938. * Creates a WebXRExperienceHelper
  97939. * @param scene The scene the helper should be created in
  97940. */
  97941. private constructor();
  97942. /**
  97943. * Exits XR mode and returns the scene to its original state
  97944. * @returns promise that resolves after xr mode has exited
  97945. */
  97946. exitXRAsync(): Promise<void>;
  97947. /**
  97948. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  97949. * @param sessionCreationOptions options for the XR session
  97950. * @param frameOfReference frame of reference of the XR session
  97951. * @returns promise that resolves after xr mode has entered
  97952. */
  97953. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  97954. /**
  97955. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  97956. * @param ray ray to cast into the environment
  97957. * @returns Promise which resolves with a collision point in the environment if it exists
  97958. */
  97959. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  97960. /**
  97961. * Updates the global position of the camera by moving the camera's container
  97962. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  97963. * @param position The desired global position of the camera
  97964. */
  97965. setPositionOfCameraUsingContainer(position: Vector3): void;
  97966. /**
  97967. * Rotates the xr camera by rotating the camera's container around the camera's position
  97968. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  97969. * @param rotation the desired quaternion rotation to apply to the camera
  97970. */
  97971. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  97972. /**
  97973. * Checks if the creation options are supported by the xr session
  97974. * @param options creation options
  97975. * @returns true if supported
  97976. */
  97977. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  97978. /**
  97979. * Disposes of the experience helper
  97980. */
  97981. dispose(): void;
  97982. }
  97983. }
  97984. declare module BABYLON {
  97985. /**
  97986. * Button which can be used to enter a different mode of XR
  97987. */
  97988. export class WebXREnterExitUIButton {
  97989. /** button element */
  97990. element: HTMLElement;
  97991. /** XR initialization options for the button */
  97992. initializationOptions: XRSessionCreationOptions;
  97993. /**
  97994. * Creates a WebXREnterExitUIButton
  97995. * @param element button element
  97996. * @param initializationOptions XR initialization options for the button
  97997. */
  97998. constructor(
  97999. /** button element */
  98000. element: HTMLElement,
  98001. /** XR initialization options for the button */
  98002. initializationOptions: XRSessionCreationOptions);
  98003. /**
  98004. * Overwritable function which can be used to update the button's visuals when the state changes
  98005. * @param activeButton the current active button in the UI
  98006. */
  98007. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  98008. }
  98009. /**
  98010. * Options to create the webXR UI
  98011. */
  98012. export class WebXREnterExitUIOptions {
  98013. /**
  98014. * Context to enter xr with
  98015. */
  98016. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  98017. /**
  98018. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  98019. */
  98020. customButtons?: Array<WebXREnterExitUIButton>;
  98021. }
  98022. /**
  98023. * UI to allow the user to enter/exit XR mode
  98024. */
  98025. export class WebXREnterExitUI implements IDisposable {
  98026. private scene;
  98027. private _overlay;
  98028. private _buttons;
  98029. private _activeButton;
  98030. /**
  98031. * Fired every time the active button is changed.
  98032. *
  98033. * When xr is entered via a button that launches xr that button will be the callback parameter
  98034. *
  98035. * When exiting xr the callback parameter will be null)
  98036. */
  98037. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  98038. /**
  98039. * Creates UI to allow the user to enter/exit XR mode
  98040. * @param scene the scene to add the ui to
  98041. * @param helper the xr experience helper to enter/exit xr with
  98042. * @param options options to configure the UI
  98043. * @returns the created ui
  98044. */
  98045. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  98046. private constructor();
  98047. private _updateButtons;
  98048. /**
  98049. * Disposes of the object
  98050. */
  98051. dispose(): void;
  98052. }
  98053. }
  98054. declare module BABYLON {
  98055. /**
  98056. * Represents an XR input
  98057. */
  98058. export class WebXRController {
  98059. /**
  98060. * 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
  98061. */
  98062. grip?: AbstractMesh;
  98063. /**
  98064. * Pointer which can be used to select objects or attach a visible laser to
  98065. */
  98066. pointer: AbstractMesh;
  98067. /**
  98068. * Creates the controller
  98069. * @see https://doc.babylonjs.com/how_to/webxr
  98070. * @param scene the scene which the controller should be associated to
  98071. */
  98072. constructor(scene: Scene);
  98073. /**
  98074. * Disposes of the object
  98075. */
  98076. dispose(): void;
  98077. }
  98078. /**
  98079. * XR input used to track XR inputs such as controllers/rays
  98080. */
  98081. export class WebXRInput implements IDisposable {
  98082. private helper;
  98083. /**
  98084. * XR controllers being tracked
  98085. */
  98086. controllers: Array<WebXRController>;
  98087. private _tmpMatrix;
  98088. private _frameObserver;
  98089. /**
  98090. * Initializes the WebXRInput
  98091. * @param helper experience helper which the input should be created for
  98092. */
  98093. constructor(helper: WebXRExperienceHelper);
  98094. /**
  98095. * Disposes of the object
  98096. */
  98097. dispose(): void;
  98098. }
  98099. }
  98100. declare module BABYLON {
  98101. /**
  98102. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  98103. */
  98104. export class WebXRManagedOutputCanvas implements IDisposable {
  98105. private _canvas;
  98106. /**
  98107. * xrpresent context of the canvas which can be used to display/mirror xr content
  98108. */
  98109. canvasContext: Nullable<WebGLRenderingContext>;
  98110. /**
  98111. * Initializes the canvas to be added/removed upon entering/exiting xr
  98112. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  98113. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  98114. */
  98115. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  98116. /**
  98117. * Disposes of the object
  98118. */
  98119. dispose(): void;
  98120. private _setManagedOutputCanvas;
  98121. private _addCanvas;
  98122. private _removeCanvas;
  98123. }
  98124. }
  98125. declare module BABYLON {
  98126. /**
  98127. * Contains an array of blocks representing the octree
  98128. */
  98129. export interface IOctreeContainer<T> {
  98130. /**
  98131. * Blocks within the octree
  98132. */
  98133. blocks: Array<OctreeBlock<T>>;
  98134. }
  98135. /**
  98136. * Class used to store a cell in an octree
  98137. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98138. */
  98139. export class OctreeBlock<T> {
  98140. /**
  98141. * Gets the content of the current block
  98142. */
  98143. entries: T[];
  98144. /**
  98145. * Gets the list of block children
  98146. */
  98147. blocks: Array<OctreeBlock<T>>;
  98148. private _depth;
  98149. private _maxDepth;
  98150. private _capacity;
  98151. private _minPoint;
  98152. private _maxPoint;
  98153. private _boundingVectors;
  98154. private _creationFunc;
  98155. /**
  98156. * Creates a new block
  98157. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  98158. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  98159. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  98160. * @param depth defines the current depth of this block in the octree
  98161. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  98162. * @param creationFunc defines a callback to call when an element is added to the block
  98163. */
  98164. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  98165. /**
  98166. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  98167. */
  98168. readonly capacity: number;
  98169. /**
  98170. * Gets the minimum vector (in world space) of the block's bounding box
  98171. */
  98172. readonly minPoint: Vector3;
  98173. /**
  98174. * Gets the maximum vector (in world space) of the block's bounding box
  98175. */
  98176. readonly maxPoint: Vector3;
  98177. /**
  98178. * Add a new element to this block
  98179. * @param entry defines the element to add
  98180. */
  98181. addEntry(entry: T): void;
  98182. /**
  98183. * Remove an element from this block
  98184. * @param entry defines the element to remove
  98185. */
  98186. removeEntry(entry: T): void;
  98187. /**
  98188. * Add an array of elements to this block
  98189. * @param entries defines the array of elements to add
  98190. */
  98191. addEntries(entries: T[]): void;
  98192. /**
  98193. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  98194. * @param frustumPlanes defines the frustum planes to test
  98195. * @param selection defines the array to store current content if selection is positive
  98196. * @param allowDuplicate defines if the selection array can contains duplicated entries
  98197. */
  98198. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  98199. /**
  98200. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  98201. * @param sphereCenter defines the bounding sphere center
  98202. * @param sphereRadius defines the bounding sphere radius
  98203. * @param selection defines the array to store current content if selection is positive
  98204. * @param allowDuplicate defines if the selection array can contains duplicated entries
  98205. */
  98206. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  98207. /**
  98208. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  98209. * @param ray defines the ray to test with
  98210. * @param selection defines the array to store current content if selection is positive
  98211. */
  98212. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  98213. /**
  98214. * Subdivide the content into child blocks (this block will then be empty)
  98215. */
  98216. createInnerBlocks(): void;
  98217. /**
  98218. * @hidden
  98219. */
  98220. 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;
  98221. }
  98222. }
  98223. declare module BABYLON {
  98224. /**
  98225. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  98226. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98227. */
  98228. export class Octree<T> {
  98229. /** 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.) */
  98230. maxDepth: number;
  98231. /**
  98232. * Blocks within the octree containing objects
  98233. */
  98234. blocks: Array<OctreeBlock<T>>;
  98235. /**
  98236. * Content stored in the octree
  98237. */
  98238. dynamicContent: T[];
  98239. private _maxBlockCapacity;
  98240. private _selectionContent;
  98241. private _creationFunc;
  98242. /**
  98243. * Creates a octree
  98244. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98245. * @param creationFunc function to be used to instatiate the octree
  98246. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  98247. * @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.)
  98248. */
  98249. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  98250. /** 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.) */
  98251. maxDepth?: number);
  98252. /**
  98253. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  98254. * @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);
  98255. * @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);
  98256. * @param entries meshes to be added to the octree blocks
  98257. */
  98258. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  98259. /**
  98260. * Adds a mesh to the octree
  98261. * @param entry Mesh to add to the octree
  98262. */
  98263. addMesh(entry: T): void;
  98264. /**
  98265. * Remove an element from the octree
  98266. * @param entry defines the element to remove
  98267. */
  98268. removeMesh(entry: T): void;
  98269. /**
  98270. * Selects an array of meshes within the frustum
  98271. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  98272. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  98273. * @returns array of meshes within the frustum
  98274. */
  98275. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  98276. /**
  98277. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  98278. * @param sphereCenter defines the bounding sphere center
  98279. * @param sphereRadius defines the bounding sphere radius
  98280. * @param allowDuplicate defines if the selection array can contains duplicated entries
  98281. * @returns an array of objects that intersect the sphere
  98282. */
  98283. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  98284. /**
  98285. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  98286. * @param ray defines the ray to test with
  98287. * @returns array of intersected objects
  98288. */
  98289. intersectsRay(ray: Ray): SmartArray<T>;
  98290. /**
  98291. * Adds a mesh into the octree block if it intersects the block
  98292. */
  98293. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  98294. /**
  98295. * Adds a submesh into the octree block if it intersects the block
  98296. */
  98297. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  98298. }
  98299. }
  98300. declare module BABYLON {
  98301. interface Scene {
  98302. /**
  98303. * @hidden
  98304. * Backing Filed
  98305. */
  98306. _selectionOctree: Octree<AbstractMesh>;
  98307. /**
  98308. * Gets the octree used to boost mesh selection (picking)
  98309. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98310. */
  98311. selectionOctree: Octree<AbstractMesh>;
  98312. /**
  98313. * Creates or updates the octree used to boost selection (picking)
  98314. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98315. * @param maxCapacity defines the maximum capacity per leaf
  98316. * @param maxDepth defines the maximum depth of the octree
  98317. * @returns an octree of AbstractMesh
  98318. */
  98319. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  98320. }
  98321. interface AbstractMesh {
  98322. /**
  98323. * @hidden
  98324. * Backing Field
  98325. */
  98326. _submeshesOctree: Octree<SubMesh>;
  98327. /**
  98328. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  98329. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  98330. * @param maxCapacity defines the maximum size of each block (64 by default)
  98331. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  98332. * @returns the new octree
  98333. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  98334. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  98335. */
  98336. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  98337. }
  98338. /**
  98339. * Defines the octree scene component responsible to manage any octrees
  98340. * in a given scene.
  98341. */
  98342. export class OctreeSceneComponent {
  98343. /**
  98344. * The component name helpfull to identify the component in the list of scene components.
  98345. */
  98346. readonly name: string;
  98347. /**
  98348. * The scene the component belongs to.
  98349. */
  98350. scene: Scene;
  98351. /**
  98352. * Indicates if the meshes have been checked to make sure they are isEnabled()
  98353. */
  98354. readonly checksIsEnabled: boolean;
  98355. /**
  98356. * Creates a new instance of the component for the given scene
  98357. * @param scene Defines the scene to register the component in
  98358. */
  98359. constructor(scene: Scene);
  98360. /**
  98361. * Registers the component in a given scene
  98362. */
  98363. register(): void;
  98364. /**
  98365. * Return the list of active meshes
  98366. * @returns the list of active meshes
  98367. */
  98368. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  98369. /**
  98370. * Return the list of active sub meshes
  98371. * @param mesh The mesh to get the candidates sub meshes from
  98372. * @returns the list of active sub meshes
  98373. */
  98374. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  98375. private _tempRay;
  98376. /**
  98377. * Return the list of sub meshes intersecting with a given local ray
  98378. * @param mesh defines the mesh to find the submesh for
  98379. * @param localRay defines the ray in local space
  98380. * @returns the list of intersecting sub meshes
  98381. */
  98382. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  98383. /**
  98384. * Return the list of sub meshes colliding with a collider
  98385. * @param mesh defines the mesh to find the submesh for
  98386. * @param collider defines the collider to evaluate the collision against
  98387. * @returns the list of colliding sub meshes
  98388. */
  98389. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  98390. /**
  98391. * Rebuilds the elements related to this component in case of
  98392. * context lost for instance.
  98393. */
  98394. rebuild(): void;
  98395. /**
  98396. * Disposes the component and the associated ressources.
  98397. */
  98398. dispose(): void;
  98399. }
  98400. }
  98401. declare module BABYLON {
  98402. /**
  98403. * Class containing static functions to help procedurally build meshes
  98404. */
  98405. export class LinesBuilder {
  98406. /**
  98407. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  98408. * * 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
  98409. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  98410. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  98411. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  98412. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  98413. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  98414. * * 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
  98415. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  98416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98417. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  98418. * @param name defines the name of the new line system
  98419. * @param options defines the options used to create the line system
  98420. * @param scene defines the hosting scene
  98421. * @returns a new line system mesh
  98422. */
  98423. static CreateLineSystem(name: string, options: {
  98424. lines: Vector3[][];
  98425. updatable?: boolean;
  98426. instance?: Nullable<LinesMesh>;
  98427. colors?: Nullable<Color4[][]>;
  98428. useVertexAlpha?: boolean;
  98429. }, scene: Nullable<Scene>): LinesMesh;
  98430. /**
  98431. * Creates a line mesh
  98432. * 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
  98433. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  98434. * * The parameter `points` is an array successive Vector3
  98435. * * 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
  98436. * * The optional parameter `colors` is an array of successive Color4, one per line point
  98437. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  98438. * * When updating an instance, remember that only point positions can change, not the number of points
  98439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98440. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  98441. * @param name defines the name of the new line system
  98442. * @param options defines the options used to create the line system
  98443. * @param scene defines the hosting scene
  98444. * @returns a new line mesh
  98445. */
  98446. static CreateLines(name: string, options: {
  98447. points: Vector3[];
  98448. updatable?: boolean;
  98449. instance?: Nullable<LinesMesh>;
  98450. colors?: Color4[];
  98451. useVertexAlpha?: boolean;
  98452. }, scene?: Nullable<Scene>): LinesMesh;
  98453. /**
  98454. * Creates a dashed line mesh
  98455. * * 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
  98456. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  98457. * * The parameter `points` is an array successive Vector3
  98458. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  98459. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  98460. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98461. * * 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
  98462. * * When updating an instance, remember that only point positions can change, not the number of points
  98463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98464. * @param name defines the name of the mesh
  98465. * @param options defines the options used to create the mesh
  98466. * @param scene defines the hosting scene
  98467. * @returns the dashed line mesh
  98468. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  98469. */
  98470. static CreateDashedLines(name: string, options: {
  98471. points: Vector3[];
  98472. dashSize?: number;
  98473. gapSize?: number;
  98474. dashNb?: number;
  98475. updatable?: boolean;
  98476. instance?: LinesMesh;
  98477. }, scene?: Nullable<Scene>): LinesMesh;
  98478. }
  98479. }
  98480. declare module BABYLON {
  98481. /**
  98482. * Renders a layer on top of an existing scene
  98483. */
  98484. export class UtilityLayerRenderer implements IDisposable {
  98485. /** the original scene that will be rendered on top of */
  98486. originalScene: Scene;
  98487. private _pointerCaptures;
  98488. private _lastPointerEvents;
  98489. private static _DefaultUtilityLayer;
  98490. private static _DefaultKeepDepthUtilityLayer;
  98491. /**
  98492. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  98493. */
  98494. pickUtilitySceneFirst: boolean;
  98495. /**
  98496. * 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)
  98497. */
  98498. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  98499. /**
  98500. * 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)
  98501. */
  98502. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  98503. /**
  98504. * The scene that is rendered on top of the original scene
  98505. */
  98506. utilityLayerScene: Scene;
  98507. /**
  98508. * If the utility layer should automatically be rendered on top of existing scene
  98509. */
  98510. shouldRender: boolean;
  98511. /**
  98512. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  98513. */
  98514. onlyCheckPointerDownEvents: boolean;
  98515. /**
  98516. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  98517. */
  98518. processAllEvents: boolean;
  98519. /**
  98520. * Observable raised when the pointer move from the utility layer scene to the main scene
  98521. */
  98522. onPointerOutObservable: Observable<number>;
  98523. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  98524. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  98525. private _afterRenderObserver;
  98526. private _sceneDisposeObserver;
  98527. private _originalPointerObserver;
  98528. /**
  98529. * Instantiates a UtilityLayerRenderer
  98530. * @param originalScene the original scene that will be rendered on top of
  98531. * @param handleEvents boolean indicating if the utility layer should handle events
  98532. */
  98533. constructor(
  98534. /** the original scene that will be rendered on top of */
  98535. originalScene: Scene, handleEvents?: boolean);
  98536. private _notifyObservers;
  98537. /**
  98538. * Renders the utility layers scene on top of the original scene
  98539. */
  98540. render(): void;
  98541. /**
  98542. * Disposes of the renderer
  98543. */
  98544. dispose(): void;
  98545. private _updateCamera;
  98546. }
  98547. }
  98548. declare module BABYLON {
  98549. /**
  98550. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  98551. */
  98552. export class Gizmo implements IDisposable {
  98553. /** The utility layer the gizmo will be added to */
  98554. gizmoLayer: UtilityLayerRenderer;
  98555. /**
  98556. * The root mesh of the gizmo
  98557. */
  98558. _rootMesh: Mesh;
  98559. private _attachedMesh;
  98560. /**
  98561. * Ratio for the scale of the gizmo (Default: 1)
  98562. */
  98563. scaleRatio: number;
  98564. private _tmpMatrix;
  98565. /**
  98566. * If a custom mesh has been set (Default: false)
  98567. */
  98568. protected _customMeshSet: boolean;
  98569. /**
  98570. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  98571. * * When set, interactions will be enabled
  98572. */
  98573. attachedMesh: Nullable<AbstractMesh>;
  98574. /**
  98575. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  98576. * @param mesh The mesh to replace the default mesh of the gizmo
  98577. */
  98578. setCustomMesh(mesh: Mesh): void;
  98579. /**
  98580. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  98581. */
  98582. updateGizmoRotationToMatchAttachedMesh: boolean;
  98583. /**
  98584. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  98585. */
  98586. updateGizmoPositionToMatchAttachedMesh: boolean;
  98587. /**
  98588. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  98589. */
  98590. protected _updateScale: boolean;
  98591. protected _interactionsEnabled: boolean;
  98592. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98593. private _beforeRenderObserver;
  98594. /**
  98595. * Creates a gizmo
  98596. * @param gizmoLayer The utility layer the gizmo will be added to
  98597. */
  98598. constructor(
  98599. /** The utility layer the gizmo will be added to */
  98600. gizmoLayer?: UtilityLayerRenderer);
  98601. private _tempVector;
  98602. /**
  98603. * @hidden
  98604. * Updates the gizmo to match the attached mesh's position/rotation
  98605. */
  98606. protected _update(): void;
  98607. /**
  98608. * Disposes of the gizmo
  98609. */
  98610. dispose(): void;
  98611. }
  98612. }
  98613. declare module BABYLON {
  98614. /**
  98615. * Single axis drag gizmo
  98616. */
  98617. export class AxisDragGizmo extends Gizmo {
  98618. /**
  98619. * Drag behavior responsible for the gizmos dragging interactions
  98620. */
  98621. dragBehavior: PointerDragBehavior;
  98622. private _pointerObserver;
  98623. /**
  98624. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  98625. */
  98626. snapDistance: number;
  98627. /**
  98628. * Event that fires each time the gizmo snaps to a new location.
  98629. * * snapDistance is the the change in distance
  98630. */
  98631. onSnapObservable: Observable<{
  98632. snapDistance: number;
  98633. }>;
  98634. /** @hidden */
  98635. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  98636. /** @hidden */
  98637. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  98638. /**
  98639. * Creates an AxisDragGizmo
  98640. * @param gizmoLayer The utility layer the gizmo will be added to
  98641. * @param dragAxis The axis which the gizmo will be able to drag on
  98642. * @param color The color of the gizmo
  98643. */
  98644. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  98645. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  98646. /**
  98647. * Disposes of the gizmo
  98648. */
  98649. dispose(): void;
  98650. }
  98651. }
  98652. declare module BABYLON.Debug {
  98653. /**
  98654. * The Axes viewer will show 3 axes in a specific point in space
  98655. */
  98656. export class AxesViewer {
  98657. private _xAxis;
  98658. private _yAxis;
  98659. private _zAxis;
  98660. private _scaleLinesFactor;
  98661. private _instanced;
  98662. /**
  98663. * Gets the hosting scene
  98664. */
  98665. scene: Scene;
  98666. /**
  98667. * Gets or sets a number used to scale line length
  98668. */
  98669. scaleLines: number;
  98670. /** Gets the node hierarchy used to render x-axis */
  98671. readonly xAxis: TransformNode;
  98672. /** Gets the node hierarchy used to render y-axis */
  98673. readonly yAxis: TransformNode;
  98674. /** Gets the node hierarchy used to render z-axis */
  98675. readonly zAxis: TransformNode;
  98676. /**
  98677. * Creates a new AxesViewer
  98678. * @param scene defines the hosting scene
  98679. * @param scaleLines defines a number used to scale line length (1 by default)
  98680. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  98681. * @param xAxis defines the node hierarchy used to render the x-axis
  98682. * @param yAxis defines the node hierarchy used to render the y-axis
  98683. * @param zAxis defines the node hierarchy used to render the z-axis
  98684. */
  98685. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  98686. /**
  98687. * Force the viewer to update
  98688. * @param position defines the position of the viewer
  98689. * @param xaxis defines the x axis of the viewer
  98690. * @param yaxis defines the y axis of the viewer
  98691. * @param zaxis defines the z axis of the viewer
  98692. */
  98693. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  98694. /**
  98695. * Creates an instance of this axes viewer.
  98696. * @returns a new axes viewer with instanced meshes
  98697. */
  98698. createInstance(): AxesViewer;
  98699. /** Releases resources */
  98700. dispose(): void;
  98701. private static _SetRenderingGroupId;
  98702. }
  98703. }
  98704. declare module BABYLON.Debug {
  98705. /**
  98706. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  98707. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  98708. */
  98709. export class BoneAxesViewer extends AxesViewer {
  98710. /**
  98711. * Gets or sets the target mesh where to display the axes viewer
  98712. */
  98713. mesh: Nullable<Mesh>;
  98714. /**
  98715. * Gets or sets the target bone where to display the axes viewer
  98716. */
  98717. bone: Nullable<Bone>;
  98718. /** Gets current position */
  98719. pos: Vector3;
  98720. /** Gets direction of X axis */
  98721. xaxis: Vector3;
  98722. /** Gets direction of Y axis */
  98723. yaxis: Vector3;
  98724. /** Gets direction of Z axis */
  98725. zaxis: Vector3;
  98726. /**
  98727. * Creates a new BoneAxesViewer
  98728. * @param scene defines the hosting scene
  98729. * @param bone defines the target bone
  98730. * @param mesh defines the target mesh
  98731. * @param scaleLines defines a scaling factor for line length (1 by default)
  98732. */
  98733. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  98734. /**
  98735. * Force the viewer to update
  98736. */
  98737. update(): void;
  98738. /** Releases resources */
  98739. dispose(): void;
  98740. }
  98741. }
  98742. declare module BABYLON {
  98743. /**
  98744. * Interface used to define scene explorer extensibility option
  98745. */
  98746. export interface IExplorerExtensibilityOption {
  98747. /**
  98748. * Define the option label
  98749. */
  98750. label: string;
  98751. /**
  98752. * Defines the action to execute on click
  98753. */
  98754. action: (entity: any) => void;
  98755. }
  98756. /**
  98757. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  98758. */
  98759. export interface IExplorerExtensibilityGroup {
  98760. /**
  98761. * Defines a predicate to test if a given type mut be extended
  98762. */
  98763. predicate: (entity: any) => boolean;
  98764. /**
  98765. * Gets the list of options added to a type
  98766. */
  98767. entries: IExplorerExtensibilityOption[];
  98768. }
  98769. /**
  98770. * Interface used to define the options to use to create the Inspector
  98771. */
  98772. export interface IInspectorOptions {
  98773. /**
  98774. * Display in overlay mode (default: false)
  98775. */
  98776. overlay?: boolean;
  98777. /**
  98778. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  98779. */
  98780. globalRoot?: HTMLElement;
  98781. /**
  98782. * Display the Scene explorer
  98783. */
  98784. showExplorer?: boolean;
  98785. /**
  98786. * Display the property inspector
  98787. */
  98788. showInspector?: boolean;
  98789. /**
  98790. * Display in embed mode (both panes on the right)
  98791. */
  98792. embedMode?: boolean;
  98793. /**
  98794. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  98795. */
  98796. handleResize?: boolean;
  98797. /**
  98798. * Allow the panes to popup (default: true)
  98799. */
  98800. enablePopup?: boolean;
  98801. /**
  98802. * Allow the panes to be closed by users (default: true)
  98803. */
  98804. enableClose?: boolean;
  98805. /**
  98806. * Optional list of extensibility entries
  98807. */
  98808. explorerExtensibility?: IExplorerExtensibilityGroup[];
  98809. /**
  98810. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  98811. */
  98812. inspectorURL?: string;
  98813. }
  98814. interface Scene {
  98815. /**
  98816. * @hidden
  98817. * Backing field
  98818. */
  98819. _debugLayer: DebugLayer;
  98820. /**
  98821. * Gets the debug layer (aka Inspector) associated with the scene
  98822. * @see http://doc.babylonjs.com/features/playground_debuglayer
  98823. */
  98824. debugLayer: DebugLayer;
  98825. }
  98826. /**
  98827. * The debug layer (aka Inspector) is the go to tool in order to better understand
  98828. * what is happening in your scene
  98829. * @see http://doc.babylonjs.com/features/playground_debuglayer
  98830. */
  98831. export class DebugLayer {
  98832. /**
  98833. * Define the url to get the inspector script from.
  98834. * By default it uses the babylonjs CDN.
  98835. * @ignoreNaming
  98836. */
  98837. static InspectorURL: string;
  98838. private _scene;
  98839. private BJSINSPECTOR;
  98840. /**
  98841. * Observable triggered when a property is changed through the inspector.
  98842. */
  98843. onPropertyChangedObservable: Observable<{
  98844. object: any;
  98845. property: string;
  98846. value: any;
  98847. initialValue: any;
  98848. }>;
  98849. /**
  98850. * Instantiates a new debug layer.
  98851. * The debug layer (aka Inspector) is the go to tool in order to better understand
  98852. * what is happening in your scene
  98853. * @see http://doc.babylonjs.com/features/playground_debuglayer
  98854. * @param scene Defines the scene to inspect
  98855. */
  98856. constructor(scene: Scene);
  98857. /** Creates the inspector window. */
  98858. private _createInspector;
  98859. /**
  98860. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  98861. * @param entity defines the entity to select
  98862. * @param lineContainerTitle defines the specific block to highlight
  98863. */
  98864. select(entity: any, lineContainerTitle?: string): void;
  98865. /** Get the inspector from bundle or global */
  98866. private _getGlobalInspector;
  98867. /**
  98868. * Get if the inspector is visible or not.
  98869. * @returns true if visible otherwise, false
  98870. */
  98871. isVisible(): boolean;
  98872. /**
  98873. * Hide the inspector and close its window.
  98874. */
  98875. hide(): void;
  98876. /**
  98877. * Launch the debugLayer.
  98878. * @param config Define the configuration of the inspector
  98879. * @return a promise fulfilled when the debug layer is visible
  98880. */
  98881. show(config?: IInspectorOptions): Promise<DebugLayer>;
  98882. }
  98883. }
  98884. declare module BABYLON {
  98885. /**
  98886. * Class containing static functions to help procedurally build meshes
  98887. */
  98888. export class BoxBuilder {
  98889. /**
  98890. * Creates a box mesh
  98891. * * The parameter `size` sets the size (float) of each box side (default 1)
  98892. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  98893. * * 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)
  98894. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  98895. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98896. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98898. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  98899. * @param name defines the name of the mesh
  98900. * @param options defines the options used to create the mesh
  98901. * @param scene defines the hosting scene
  98902. * @returns the box mesh
  98903. */
  98904. static CreateBox(name: string, options: {
  98905. size?: number;
  98906. width?: number;
  98907. height?: number;
  98908. depth?: number;
  98909. faceUV?: Vector4[];
  98910. faceColors?: Color4[];
  98911. sideOrientation?: number;
  98912. frontUVs?: Vector4;
  98913. backUVs?: Vector4;
  98914. updatable?: boolean;
  98915. }, scene?: Nullable<Scene>): Mesh;
  98916. }
  98917. }
  98918. declare module BABYLON {
  98919. /**
  98920. * Class containing static functions to help procedurally build meshes
  98921. */
  98922. export class SphereBuilder {
  98923. /**
  98924. * Creates a sphere mesh
  98925. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  98926. * * 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`)
  98927. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  98928. * * 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
  98929. * * 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)
  98930. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98931. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98933. * @param name defines the name of the mesh
  98934. * @param options defines the options used to create the mesh
  98935. * @param scene defines the hosting scene
  98936. * @returns the sphere mesh
  98937. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  98938. */
  98939. static CreateSphere(name: string, options: {
  98940. segments?: number;
  98941. diameter?: number;
  98942. diameterX?: number;
  98943. diameterY?: number;
  98944. diameterZ?: number;
  98945. arc?: number;
  98946. slice?: number;
  98947. sideOrientation?: number;
  98948. frontUVs?: Vector4;
  98949. backUVs?: Vector4;
  98950. updatable?: boolean;
  98951. }, scene: any): Mesh;
  98952. }
  98953. }
  98954. declare module BABYLON.Debug {
  98955. /**
  98956. * Used to show the physics impostor around the specific mesh
  98957. */
  98958. export class PhysicsViewer {
  98959. /** @hidden */
  98960. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  98961. /** @hidden */
  98962. protected _meshes: Array<Nullable<AbstractMesh>>;
  98963. /** @hidden */
  98964. protected _scene: Nullable<Scene>;
  98965. /** @hidden */
  98966. protected _numMeshes: number;
  98967. /** @hidden */
  98968. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  98969. private _renderFunction;
  98970. private _utilityLayer;
  98971. private _debugBoxMesh;
  98972. private _debugSphereMesh;
  98973. private _debugMaterial;
  98974. /**
  98975. * Creates a new PhysicsViewer
  98976. * @param scene defines the hosting scene
  98977. */
  98978. constructor(scene: Scene);
  98979. /** @hidden */
  98980. protected _updateDebugMeshes(): void;
  98981. /**
  98982. * Renders a specified physic impostor
  98983. * @param impostor defines the impostor to render
  98984. * @returns the new debug mesh used to render the impostor
  98985. */
  98986. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  98987. /**
  98988. * Hides a specified physic impostor
  98989. * @param impostor defines the impostor to hide
  98990. */
  98991. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  98992. private _getDebugMaterial;
  98993. private _getDebugBoxMesh;
  98994. private _getDebugSphereMesh;
  98995. private _getDebugMesh;
  98996. /** Releases all resources */
  98997. dispose(): void;
  98998. }
  98999. }
  99000. declare module BABYLON {
  99001. /**
  99002. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  99003. * in order to better appreciate the issue one might have.
  99004. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  99005. */
  99006. export class RayHelper {
  99007. /**
  99008. * Defines the ray we are currently tryin to visualize.
  99009. */
  99010. ray: Nullable<Ray>;
  99011. private _renderPoints;
  99012. private _renderLine;
  99013. private _renderFunction;
  99014. private _scene;
  99015. private _updateToMeshFunction;
  99016. private _attachedToMesh;
  99017. private _meshSpaceDirection;
  99018. private _meshSpaceOrigin;
  99019. /**
  99020. * Helper function to create a colored helper in a scene in one line.
  99021. * @param ray Defines the ray we are currently tryin to visualize
  99022. * @param scene Defines the scene the ray is used in
  99023. * @param color Defines the color we want to see the ray in
  99024. * @returns The newly created ray helper.
  99025. */
  99026. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  99027. /**
  99028. * Instantiate a new ray helper.
  99029. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  99030. * in order to better appreciate the issue one might have.
  99031. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  99032. * @param ray Defines the ray we are currently tryin to visualize
  99033. */
  99034. constructor(ray: Ray);
  99035. /**
  99036. * Shows the ray we are willing to debug.
  99037. * @param scene Defines the scene the ray needs to be rendered in
  99038. * @param color Defines the color the ray needs to be rendered in
  99039. */
  99040. show(scene: Scene, color?: Color3): void;
  99041. /**
  99042. * Hides the ray we are debugging.
  99043. */
  99044. hide(): void;
  99045. private _render;
  99046. /**
  99047. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  99048. * @param mesh Defines the mesh we want the helper attached to
  99049. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  99050. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  99051. * @param length Defines the length of the ray
  99052. */
  99053. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  99054. /**
  99055. * Detach the ray helper from the mesh it has previously been attached to.
  99056. */
  99057. detachFromMesh(): void;
  99058. private _updateToMesh;
  99059. /**
  99060. * Dispose the helper and release its associated resources.
  99061. */
  99062. dispose(): void;
  99063. }
  99064. }
  99065. declare module BABYLON.Debug {
  99066. /**
  99067. * Class used to render a debug view of a given skeleton
  99068. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  99069. */
  99070. export class SkeletonViewer {
  99071. /** defines the skeleton to render */
  99072. skeleton: Skeleton;
  99073. /** defines the mesh attached to the skeleton */
  99074. mesh: AbstractMesh;
  99075. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  99076. autoUpdateBonesMatrices: boolean;
  99077. /** defines the rendering group id to use with the viewer */
  99078. renderingGroupId: number;
  99079. /** Gets or sets the color used to render the skeleton */
  99080. color: Color3;
  99081. private _scene;
  99082. private _debugLines;
  99083. private _debugMesh;
  99084. private _isEnabled;
  99085. private _renderFunction;
  99086. private _utilityLayer;
  99087. /**
  99088. * Returns the mesh used to render the bones
  99089. */
  99090. readonly debugMesh: Nullable<LinesMesh>;
  99091. /**
  99092. * Creates a new SkeletonViewer
  99093. * @param skeleton defines the skeleton to render
  99094. * @param mesh defines the mesh attached to the skeleton
  99095. * @param scene defines the hosting scene
  99096. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  99097. * @param renderingGroupId defines the rendering group id to use with the viewer
  99098. */
  99099. constructor(
  99100. /** defines the skeleton to render */
  99101. skeleton: Skeleton,
  99102. /** defines the mesh attached to the skeleton */
  99103. mesh: AbstractMesh, scene: Scene,
  99104. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  99105. autoUpdateBonesMatrices?: boolean,
  99106. /** defines the rendering group id to use with the viewer */
  99107. renderingGroupId?: number);
  99108. /** Gets or sets a boolean indicating if the viewer is enabled */
  99109. isEnabled: boolean;
  99110. private _getBonePosition;
  99111. private _getLinesForBonesWithLength;
  99112. private _getLinesForBonesNoLength;
  99113. /** Update the viewer to sync with current skeleton state */
  99114. update(): void;
  99115. /** Release associated resources */
  99116. dispose(): void;
  99117. }
  99118. }
  99119. declare module BABYLON {
  99120. /**
  99121. * Options to create the null engine
  99122. */
  99123. export class NullEngineOptions {
  99124. /**
  99125. * Render width (Default: 512)
  99126. */
  99127. renderWidth: number;
  99128. /**
  99129. * Render height (Default: 256)
  99130. */
  99131. renderHeight: number;
  99132. /**
  99133. * Texture size (Default: 512)
  99134. */
  99135. textureSize: number;
  99136. /**
  99137. * If delta time between frames should be constant
  99138. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99139. */
  99140. deterministicLockstep: boolean;
  99141. /**
  99142. * Maximum about of steps between frames (Default: 4)
  99143. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99144. */
  99145. lockstepMaxSteps: number;
  99146. }
  99147. /**
  99148. * The null engine class provides support for headless version of babylon.js.
  99149. * This can be used in server side scenario or for testing purposes
  99150. */
  99151. export class NullEngine extends Engine {
  99152. private _options;
  99153. /**
  99154. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99155. */
  99156. isDeterministicLockStep(): boolean;
  99157. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  99158. getLockstepMaxSteps(): number;
  99159. /**
  99160. * Sets hardware scaling, used to save performance if needed
  99161. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  99162. */
  99163. getHardwareScalingLevel(): number;
  99164. constructor(options?: NullEngineOptions);
  99165. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  99166. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  99167. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  99168. getRenderWidth(useScreen?: boolean): number;
  99169. getRenderHeight(useScreen?: boolean): number;
  99170. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  99171. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  99172. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  99173. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  99174. bindSamplers(effect: Effect): void;
  99175. enableEffect(effect: Effect): void;
  99176. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  99177. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  99178. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  99179. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  99180. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  99181. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  99182. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  99183. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  99184. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  99185. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  99186. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  99187. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  99188. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  99189. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  99190. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  99191. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  99192. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  99193. setFloat(uniform: WebGLUniformLocation, value: number): void;
  99194. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  99195. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  99196. setBool(uniform: WebGLUniformLocation, bool: number): void;
  99197. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  99198. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  99199. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  99200. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  99201. bindBuffers(vertexBuffers: {
  99202. [key: string]: VertexBuffer;
  99203. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  99204. wipeCaches(bruteForce?: boolean): void;
  99205. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  99206. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  99207. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  99208. /** @hidden */
  99209. _createTexture(): WebGLTexture;
  99210. /** @hidden */
  99211. _releaseTexture(texture: InternalTexture): void;
  99212. 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;
  99213. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  99214. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  99215. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  99216. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  99217. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  99218. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  99219. areAllEffectsReady(): boolean;
  99220. /**
  99221. * @hidden
  99222. * Get the current error code of the webGL context
  99223. * @returns the error code
  99224. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  99225. */
  99226. getError(): number;
  99227. /** @hidden */
  99228. _getUnpackAlignement(): number;
  99229. /** @hidden */
  99230. _unpackFlipY(value: boolean): void;
  99231. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  99232. /**
  99233. * Updates a dynamic vertex buffer.
  99234. * @param vertexBuffer the vertex buffer to update
  99235. * @param data the data used to update the vertex buffer
  99236. * @param byteOffset the byte offset of the data (optional)
  99237. * @param byteLength the byte length of the data (optional)
  99238. */
  99239. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  99240. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  99241. /** @hidden */
  99242. _bindTexture(channel: number, texture: InternalTexture): void;
  99243. /** @hidden */
  99244. _releaseBuffer(buffer: WebGLBuffer): boolean;
  99245. releaseEffects(): void;
  99246. displayLoadingUI(): void;
  99247. hideLoadingUI(): void;
  99248. /** @hidden */
  99249. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  99250. /** @hidden */
  99251. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  99252. /** @hidden */
  99253. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  99254. /** @hidden */
  99255. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  99256. }
  99257. }
  99258. declare module BABYLON {
  99259. /** @hidden */
  99260. export class _OcclusionDataStorage {
  99261. /** @hidden */
  99262. occlusionInternalRetryCounter: number;
  99263. /** @hidden */
  99264. isOcclusionQueryInProgress: boolean;
  99265. /** @hidden */
  99266. isOccluded: boolean;
  99267. /** @hidden */
  99268. occlusionRetryCount: number;
  99269. /** @hidden */
  99270. occlusionType: number;
  99271. /** @hidden */
  99272. occlusionQueryAlgorithmType: number;
  99273. }
  99274. interface Engine {
  99275. /**
  99276. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  99277. * @return the new query
  99278. */
  99279. createQuery(): WebGLQuery;
  99280. /**
  99281. * Delete and release a webGL query
  99282. * @param query defines the query to delete
  99283. * @return the current engine
  99284. */
  99285. deleteQuery(query: WebGLQuery): Engine;
  99286. /**
  99287. * Check if a given query has resolved and got its value
  99288. * @param query defines the query to check
  99289. * @returns true if the query got its value
  99290. */
  99291. isQueryResultAvailable(query: WebGLQuery): boolean;
  99292. /**
  99293. * Gets the value of a given query
  99294. * @param query defines the query to check
  99295. * @returns the value of the query
  99296. */
  99297. getQueryResult(query: WebGLQuery): number;
  99298. /**
  99299. * Initiates an occlusion query
  99300. * @param algorithmType defines the algorithm to use
  99301. * @param query defines the query to use
  99302. * @returns the current engine
  99303. * @see http://doc.babylonjs.com/features/occlusionquery
  99304. */
  99305. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  99306. /**
  99307. * Ends an occlusion query
  99308. * @see http://doc.babylonjs.com/features/occlusionquery
  99309. * @param algorithmType defines the algorithm to use
  99310. * @returns the current engine
  99311. */
  99312. endOcclusionQuery(algorithmType: number): Engine;
  99313. /**
  99314. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  99315. * Please note that only one query can be issued at a time
  99316. * @returns a time token used to track the time span
  99317. */
  99318. startTimeQuery(): Nullable<_TimeToken>;
  99319. /**
  99320. * Ends a time query
  99321. * @param token defines the token used to measure the time span
  99322. * @returns the time spent (in ns)
  99323. */
  99324. endTimeQuery(token: _TimeToken): int;
  99325. /** @hidden */
  99326. _currentNonTimestampToken: Nullable<_TimeToken>;
  99327. /** @hidden */
  99328. _createTimeQuery(): WebGLQuery;
  99329. /** @hidden */
  99330. _deleteTimeQuery(query: WebGLQuery): void;
  99331. /** @hidden */
  99332. _getGlAlgorithmType(algorithmType: number): number;
  99333. /** @hidden */
  99334. _getTimeQueryResult(query: WebGLQuery): any;
  99335. /** @hidden */
  99336. _getTimeQueryAvailability(query: WebGLQuery): any;
  99337. }
  99338. interface AbstractMesh {
  99339. /**
  99340. * Backing filed
  99341. * @hidden
  99342. */
  99343. __occlusionDataStorage: _OcclusionDataStorage;
  99344. /**
  99345. * Access property
  99346. * @hidden
  99347. */
  99348. _occlusionDataStorage: _OcclusionDataStorage;
  99349. /**
  99350. * 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.
  99351. * The default value is -1 which means don't break the query and wait till the result
  99352. * @see http://doc.babylonjs.com/features/occlusionquery
  99353. */
  99354. occlusionRetryCount: number;
  99355. /**
  99356. * 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:
  99357. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  99358. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  99359. * * 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.
  99360. * @see http://doc.babylonjs.com/features/occlusionquery
  99361. */
  99362. occlusionType: number;
  99363. /**
  99364. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  99365. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  99366. * * 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.
  99367. * @see http://doc.babylonjs.com/features/occlusionquery
  99368. */
  99369. occlusionQueryAlgorithmType: number;
  99370. /**
  99371. * 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
  99372. * @see http://doc.babylonjs.com/features/occlusionquery
  99373. */
  99374. isOccluded: boolean;
  99375. /**
  99376. * Flag to check the progress status of the query
  99377. * @see http://doc.babylonjs.com/features/occlusionquery
  99378. */
  99379. isOcclusionQueryInProgress: boolean;
  99380. }
  99381. }
  99382. declare module BABYLON {
  99383. /** @hidden */
  99384. export var _forceTransformFeedbackToBundle: boolean;
  99385. interface Engine {
  99386. /**
  99387. * Creates a webGL transform feedback object
  99388. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  99389. * @returns the webGL transform feedback object
  99390. */
  99391. createTransformFeedback(): WebGLTransformFeedback;
  99392. /**
  99393. * Delete a webGL transform feedback object
  99394. * @param value defines the webGL transform feedback object to delete
  99395. */
  99396. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  99397. /**
  99398. * Bind a webGL transform feedback object to the webgl context
  99399. * @param value defines the webGL transform feedback object to bind
  99400. */
  99401. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  99402. /**
  99403. * Begins a transform feedback operation
  99404. * @param usePoints defines if points or triangles must be used
  99405. */
  99406. beginTransformFeedback(usePoints: boolean): void;
  99407. /**
  99408. * Ends a transform feedback operation
  99409. */
  99410. endTransformFeedback(): void;
  99411. /**
  99412. * Specify the varyings to use with transform feedback
  99413. * @param program defines the associated webGL program
  99414. * @param value defines the list of strings representing the varying names
  99415. */
  99416. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  99417. /**
  99418. * Bind a webGL buffer for a transform feedback operation
  99419. * @param value defines the webGL buffer to bind
  99420. */
  99421. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  99422. }
  99423. }
  99424. declare module BABYLON {
  99425. /**
  99426. * Gather the list of clipboard event types as constants.
  99427. */
  99428. export class ClipboardEventTypes {
  99429. /**
  99430. * The clipboard event is fired when a copy command is active (pressed).
  99431. */
  99432. static readonly COPY: number;
  99433. /**
  99434. * The clipboard event is fired when a cut command is active (pressed).
  99435. */
  99436. static readonly CUT: number;
  99437. /**
  99438. * The clipboard event is fired when a paste command is active (pressed).
  99439. */
  99440. static readonly PASTE: number;
  99441. }
  99442. /**
  99443. * This class is used to store clipboard related info for the onClipboardObservable event.
  99444. */
  99445. export class ClipboardInfo {
  99446. /**
  99447. * Defines the type of event (BABYLON.ClipboardEventTypes)
  99448. */
  99449. type: number;
  99450. /**
  99451. * Defines the related dom event
  99452. */
  99453. event: ClipboardEvent;
  99454. /**
  99455. *Creates an instance of ClipboardInfo.
  99456. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  99457. * @param event Defines the related dom event
  99458. */
  99459. constructor(
  99460. /**
  99461. * Defines the type of event (BABYLON.ClipboardEventTypes)
  99462. */
  99463. type: number,
  99464. /**
  99465. * Defines the related dom event
  99466. */
  99467. event: ClipboardEvent);
  99468. /**
  99469. * Get the clipboard event's type from the keycode.
  99470. * @param keyCode Defines the keyCode for the current keyboard event.
  99471. * @return {number}
  99472. */
  99473. static GetTypeFromCharacter(keyCode: number): number;
  99474. }
  99475. }
  99476. declare module BABYLON {
  99477. /**
  99478. * Class used to represent data loading progression
  99479. */
  99480. export class SceneLoaderProgressEvent {
  99481. /** defines if data length to load can be evaluated */
  99482. readonly lengthComputable: boolean;
  99483. /** defines the loaded data length */
  99484. readonly loaded: number;
  99485. /** defines the data length to load */
  99486. readonly total: number;
  99487. /**
  99488. * Create a new progress event
  99489. * @param lengthComputable defines if data length to load can be evaluated
  99490. * @param loaded defines the loaded data length
  99491. * @param total defines the data length to load
  99492. */
  99493. constructor(
  99494. /** defines if data length to load can be evaluated */
  99495. lengthComputable: boolean,
  99496. /** defines the loaded data length */
  99497. loaded: number,
  99498. /** defines the data length to load */
  99499. total: number);
  99500. /**
  99501. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  99502. * @param event defines the source event
  99503. * @returns a new SceneLoaderProgressEvent
  99504. */
  99505. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  99506. }
  99507. /**
  99508. * Interface used by SceneLoader plugins to define supported file extensions
  99509. */
  99510. export interface ISceneLoaderPluginExtensions {
  99511. /**
  99512. * Defines the list of supported extensions
  99513. */
  99514. [extension: string]: {
  99515. isBinary: boolean;
  99516. };
  99517. }
  99518. /**
  99519. * Interface used by SceneLoader plugin factory
  99520. */
  99521. export interface ISceneLoaderPluginFactory {
  99522. /**
  99523. * Defines the name of the factory
  99524. */
  99525. name: string;
  99526. /**
  99527. * Function called to create a new plugin
  99528. * @return the new plugin
  99529. */
  99530. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  99531. /**
  99532. * Boolean indicating if the plugin can direct load specific data
  99533. */
  99534. canDirectLoad?: (data: string) => boolean;
  99535. }
  99536. /**
  99537. * Interface used to define a SceneLoader plugin
  99538. */
  99539. export interface ISceneLoaderPlugin {
  99540. /**
  99541. * The friendly name of this plugin.
  99542. */
  99543. name: string;
  99544. /**
  99545. * The file extensions supported by this plugin.
  99546. */
  99547. extensions: string | ISceneLoaderPluginExtensions;
  99548. /**
  99549. * Import meshes into a scene.
  99550. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  99551. * @param scene The scene to import into
  99552. * @param data The data to import
  99553. * @param rootUrl The root url for scene and resources
  99554. * @param meshes The meshes array to import into
  99555. * @param particleSystems The particle systems array to import into
  99556. * @param skeletons The skeletons array to import into
  99557. * @param onError The callback when import fails
  99558. * @returns True if successful or false otherwise
  99559. */
  99560. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  99561. /**
  99562. * Load into a scene.
  99563. * @param scene The scene to load into
  99564. * @param data The data to import
  99565. * @param rootUrl The root url for scene and resources
  99566. * @param onError The callback when import fails
  99567. * @returns true if successful or false otherwise
  99568. */
  99569. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  99570. /**
  99571. * The callback that returns true if the data can be directly loaded.
  99572. */
  99573. canDirectLoad?: (data: string) => boolean;
  99574. /**
  99575. * The callback that allows custom handling of the root url based on the response url.
  99576. */
  99577. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  99578. /**
  99579. * Load into an asset container.
  99580. * @param scene The scene to load into
  99581. * @param data The data to import
  99582. * @param rootUrl The root url for scene and resources
  99583. * @param onError The callback when import fails
  99584. * @returns The loaded asset container
  99585. */
  99586. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  99587. }
  99588. /**
  99589. * Interface used to define an async SceneLoader plugin
  99590. */
  99591. export interface ISceneLoaderPluginAsync {
  99592. /**
  99593. * The friendly name of this plugin.
  99594. */
  99595. name: string;
  99596. /**
  99597. * The file extensions supported by this plugin.
  99598. */
  99599. extensions: string | ISceneLoaderPluginExtensions;
  99600. /**
  99601. * Import meshes into a scene.
  99602. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  99603. * @param scene The scene to import into
  99604. * @param data The data to import
  99605. * @param rootUrl The root url for scene and resources
  99606. * @param onProgress The callback when the load progresses
  99607. * @param fileName Defines the name of the file to load
  99608. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  99609. */
  99610. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  99611. meshes: AbstractMesh[];
  99612. particleSystems: IParticleSystem[];
  99613. skeletons: Skeleton[];
  99614. animationGroups: AnimationGroup[];
  99615. }>;
  99616. /**
  99617. * Load into a scene.
  99618. * @param scene The scene to load into
  99619. * @param data The data to import
  99620. * @param rootUrl The root url for scene and resources
  99621. * @param onProgress The callback when the load progresses
  99622. * @param fileName Defines the name of the file to load
  99623. * @returns Nothing
  99624. */
  99625. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  99626. /**
  99627. * The callback that returns true if the data can be directly loaded.
  99628. */
  99629. canDirectLoad?: (data: string) => boolean;
  99630. /**
  99631. * The callback that allows custom handling of the root url based on the response url.
  99632. */
  99633. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  99634. /**
  99635. * Load into an asset container.
  99636. * @param scene The scene to load into
  99637. * @param data The data to import
  99638. * @param rootUrl The root url for scene and resources
  99639. * @param onProgress The callback when the load progresses
  99640. * @param fileName Defines the name of the file to load
  99641. * @returns The loaded asset container
  99642. */
  99643. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  99644. }
  99645. /**
  99646. * Class used to load scene from various file formats using registered plugins
  99647. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  99648. */
  99649. export class SceneLoader {
  99650. /**
  99651. * No logging while loading
  99652. */
  99653. static readonly NO_LOGGING: number;
  99654. /**
  99655. * Minimal logging while loading
  99656. */
  99657. static readonly MINIMAL_LOGGING: number;
  99658. /**
  99659. * Summary logging while loading
  99660. */
  99661. static readonly SUMMARY_LOGGING: number;
  99662. /**
  99663. * Detailled logging while loading
  99664. */
  99665. static readonly DETAILED_LOGGING: number;
  99666. /**
  99667. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  99668. */
  99669. static ForceFullSceneLoadingForIncremental: boolean;
  99670. /**
  99671. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  99672. */
  99673. static ShowLoadingScreen: boolean;
  99674. /**
  99675. * Defines the current logging level (while loading the scene)
  99676. * @ignorenaming
  99677. */
  99678. static loggingLevel: number;
  99679. /**
  99680. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  99681. */
  99682. static CleanBoneMatrixWeights: boolean;
  99683. /**
  99684. * Event raised when a plugin is used to load a scene
  99685. */
  99686. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  99687. private static _registeredPlugins;
  99688. private static _getDefaultPlugin;
  99689. private static _getPluginForExtension;
  99690. private static _getPluginForDirectLoad;
  99691. private static _getPluginForFilename;
  99692. private static _getDirectLoad;
  99693. private static _loadData;
  99694. private static _getFileInfo;
  99695. /**
  99696. * Gets a plugin that can load the given extension
  99697. * @param extension defines the extension to load
  99698. * @returns a plugin or null if none works
  99699. */
  99700. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  99701. /**
  99702. * Gets a boolean indicating that the given extension can be loaded
  99703. * @param extension defines the extension to load
  99704. * @returns true if the extension is supported
  99705. */
  99706. static IsPluginForExtensionAvailable(extension: string): boolean;
  99707. /**
  99708. * Adds a new plugin to the list of registered plugins
  99709. * @param plugin defines the plugin to add
  99710. */
  99711. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  99712. /**
  99713. * Import meshes into a scene
  99714. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  99715. * @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)
  99716. * @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)
  99717. * @param scene the instance of BABYLON.Scene to append to
  99718. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  99719. * @param onProgress a callback with a progress event for each file being loaded
  99720. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  99721. * @param pluginExtension the extension used to determine the plugin
  99722. * @returns The loaded plugin
  99723. */
  99724. 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>;
  99725. /**
  99726. * Import meshes into a scene
  99727. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  99728. * @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)
  99729. * @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)
  99730. * @param scene the instance of BABYLON.Scene to append to
  99731. * @param onProgress a callback with a progress event for each file being loaded
  99732. * @param pluginExtension the extension used to determine the plugin
  99733. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  99734. */
  99735. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  99736. meshes: AbstractMesh[];
  99737. particleSystems: IParticleSystem[];
  99738. skeletons: Skeleton[];
  99739. animationGroups: AnimationGroup[];
  99740. }>;
  99741. /**
  99742. * Load a scene
  99743. * @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)
  99744. * @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)
  99745. * @param engine is the instance of BABYLON.Engine to use to create the scene
  99746. * @param onSuccess a callback with the scene when import succeeds
  99747. * @param onProgress a callback with a progress event for each file being loaded
  99748. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  99749. * @param pluginExtension the extension used to determine the plugin
  99750. * @returns The loaded plugin
  99751. */
  99752. 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>;
  99753. /**
  99754. * Load a scene
  99755. * @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)
  99756. * @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)
  99757. * @param engine is the instance of BABYLON.Engine to use to create the scene
  99758. * @param onProgress a callback with a progress event for each file being loaded
  99759. * @param pluginExtension the extension used to determine the plugin
  99760. * @returns The loaded scene
  99761. */
  99762. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  99763. /**
  99764. * Append a scene
  99765. * @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)
  99766. * @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)
  99767. * @param scene is the instance of BABYLON.Scene to append to
  99768. * @param onSuccess a callback with the scene when import succeeds
  99769. * @param onProgress a callback with a progress event for each file being loaded
  99770. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  99771. * @param pluginExtension the extension used to determine the plugin
  99772. * @returns The loaded plugin
  99773. */
  99774. 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>;
  99775. /**
  99776. * Append a scene
  99777. * @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)
  99778. * @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)
  99779. * @param scene is the instance of BABYLON.Scene to append to
  99780. * @param onProgress a callback with a progress event for each file being loaded
  99781. * @param pluginExtension the extension used to determine the plugin
  99782. * @returns The given scene
  99783. */
  99784. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  99785. /**
  99786. * Load a scene into an asset container
  99787. * @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)
  99788. * @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)
  99789. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  99790. * @param onSuccess a callback with the scene when import succeeds
  99791. * @param onProgress a callback with a progress event for each file being loaded
  99792. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  99793. * @param pluginExtension the extension used to determine the plugin
  99794. * @returns The loaded plugin
  99795. */
  99796. 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>;
  99797. /**
  99798. * Load a scene into an asset container
  99799. * @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)
  99800. * @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)
  99801. * @param scene is the instance of Scene to append to
  99802. * @param onProgress a callback with a progress event for each file being loaded
  99803. * @param pluginExtension the extension used to determine the plugin
  99804. * @returns The loaded asset container
  99805. */
  99806. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  99807. }
  99808. }
  99809. declare module BABYLON {
  99810. /**
  99811. * Google Daydream controller
  99812. */
  99813. export class DaydreamController extends WebVRController {
  99814. /**
  99815. * Base Url for the controller model.
  99816. */
  99817. static MODEL_BASE_URL: string;
  99818. /**
  99819. * File name for the controller model.
  99820. */
  99821. static MODEL_FILENAME: string;
  99822. /**
  99823. * Gamepad Id prefix used to identify Daydream Controller.
  99824. */
  99825. static readonly GAMEPAD_ID_PREFIX: string;
  99826. /**
  99827. * Creates a new DaydreamController from a gamepad
  99828. * @param vrGamepad the gamepad that the controller should be created from
  99829. */
  99830. constructor(vrGamepad: any);
  99831. /**
  99832. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99833. * @param scene scene in which to add meshes
  99834. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99835. */
  99836. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99837. /**
  99838. * Called once for each button that changed state since the last frame
  99839. * @param buttonIdx Which button index changed
  99840. * @param state New state of the button
  99841. * @param changes Which properties on the state changed since last frame
  99842. */
  99843. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99844. }
  99845. }
  99846. declare module BABYLON {
  99847. /**
  99848. * Gear VR Controller
  99849. */
  99850. export class GearVRController extends WebVRController {
  99851. /**
  99852. * Base Url for the controller model.
  99853. */
  99854. static MODEL_BASE_URL: string;
  99855. /**
  99856. * File name for the controller model.
  99857. */
  99858. static MODEL_FILENAME: string;
  99859. /**
  99860. * Gamepad Id prefix used to identify this controller.
  99861. */
  99862. static readonly GAMEPAD_ID_PREFIX: string;
  99863. private readonly _buttonIndexToObservableNameMap;
  99864. /**
  99865. * Creates a new GearVRController from a gamepad
  99866. * @param vrGamepad the gamepad that the controller should be created from
  99867. */
  99868. constructor(vrGamepad: any);
  99869. /**
  99870. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99871. * @param scene scene in which to add meshes
  99872. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99873. */
  99874. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99875. /**
  99876. * Called once for each button that changed state since the last frame
  99877. * @param buttonIdx Which button index changed
  99878. * @param state New state of the button
  99879. * @param changes Which properties on the state changed since last frame
  99880. */
  99881. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99882. }
  99883. }
  99884. declare module BABYLON {
  99885. /**
  99886. * Generic Controller
  99887. */
  99888. export class GenericController extends WebVRController {
  99889. /**
  99890. * Base Url for the controller model.
  99891. */
  99892. static readonly MODEL_BASE_URL: string;
  99893. /**
  99894. * File name for the controller model.
  99895. */
  99896. static readonly MODEL_FILENAME: string;
  99897. /**
  99898. * Creates a new GenericController from a gamepad
  99899. * @param vrGamepad the gamepad that the controller should be created from
  99900. */
  99901. constructor(vrGamepad: any);
  99902. /**
  99903. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99904. * @param scene scene in which to add meshes
  99905. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99906. */
  99907. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99908. /**
  99909. * Called once for each button that changed state since the last frame
  99910. * @param buttonIdx Which button index changed
  99911. * @param state New state of the button
  99912. * @param changes Which properties on the state changed since last frame
  99913. */
  99914. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99915. }
  99916. }
  99917. declare module BABYLON {
  99918. /**
  99919. * Oculus Touch Controller
  99920. */
  99921. export class OculusTouchController extends WebVRController {
  99922. /**
  99923. * Base Url for the controller model.
  99924. */
  99925. static MODEL_BASE_URL: string;
  99926. /**
  99927. * File name for the left controller model.
  99928. */
  99929. static MODEL_LEFT_FILENAME: string;
  99930. /**
  99931. * File name for the right controller model.
  99932. */
  99933. static MODEL_RIGHT_FILENAME: string;
  99934. /**
  99935. * Fired when the secondary trigger on this controller is modified
  99936. */
  99937. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  99938. /**
  99939. * Fired when the thumb rest on this controller is modified
  99940. */
  99941. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  99942. /**
  99943. * Creates a new OculusTouchController from a gamepad
  99944. * @param vrGamepad the gamepad that the controller should be created from
  99945. */
  99946. constructor(vrGamepad: any);
  99947. /**
  99948. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  99949. * @param scene scene in which to add meshes
  99950. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  99951. */
  99952. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99953. /**
  99954. * Fired when the A button on this controller is modified
  99955. */
  99956. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99957. /**
  99958. * Fired when the B button on this controller is modified
  99959. */
  99960. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99961. /**
  99962. * Fired when the X button on this controller is modified
  99963. */
  99964. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99965. /**
  99966. * Fired when the Y button on this controller is modified
  99967. */
  99968. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99969. /**
  99970. * Called once for each button that changed state since the last frame
  99971. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  99972. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  99973. * 2) secondary trigger (same)
  99974. * 3) A (right) X (left), touch, pressed = value
  99975. * 4) B / Y
  99976. * 5) thumb rest
  99977. * @param buttonIdx Which button index changed
  99978. * @param state New state of the button
  99979. * @param changes Which properties on the state changed since last frame
  99980. */
  99981. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99982. }
  99983. }
  99984. declare module BABYLON {
  99985. /**
  99986. * Vive Controller
  99987. */
  99988. export class ViveController extends WebVRController {
  99989. /**
  99990. * Base Url for the controller model.
  99991. */
  99992. static MODEL_BASE_URL: string;
  99993. /**
  99994. * File name for the controller model.
  99995. */
  99996. static MODEL_FILENAME: string;
  99997. /**
  99998. * Creates a new ViveController from a gamepad
  99999. * @param vrGamepad the gamepad that the controller should be created from
  100000. */
  100001. constructor(vrGamepad: any);
  100002. /**
  100003. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100004. * @param scene scene in which to add meshes
  100005. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100006. */
  100007. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100008. /**
  100009. * Fired when the left button on this controller is modified
  100010. */
  100011. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100012. /**
  100013. * Fired when the right button on this controller is modified
  100014. */
  100015. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100016. /**
  100017. * Fired when the menu button on this controller is modified
  100018. */
  100019. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100020. /**
  100021. * Called once for each button that changed state since the last frame
  100022. * Vive mapping:
  100023. * 0: touchpad
  100024. * 1: trigger
  100025. * 2: left AND right buttons
  100026. * 3: menu button
  100027. * @param buttonIdx Which button index changed
  100028. * @param state New state of the button
  100029. * @param changes Which properties on the state changed since last frame
  100030. */
  100031. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100032. }
  100033. }
  100034. declare module BABYLON {
  100035. /**
  100036. * Defines the WindowsMotionController object that the state of the windows motion controller
  100037. */
  100038. export class WindowsMotionController extends WebVRController {
  100039. /**
  100040. * The base url used to load the left and right controller models
  100041. */
  100042. static MODEL_BASE_URL: string;
  100043. /**
  100044. * The name of the left controller model file
  100045. */
  100046. static MODEL_LEFT_FILENAME: string;
  100047. /**
  100048. * The name of the right controller model file
  100049. */
  100050. static MODEL_RIGHT_FILENAME: string;
  100051. /**
  100052. * The controller name prefix for this controller type
  100053. */
  100054. static readonly GAMEPAD_ID_PREFIX: string;
  100055. /**
  100056. * The controller id pattern for this controller type
  100057. */
  100058. private static readonly GAMEPAD_ID_PATTERN;
  100059. private _loadedMeshInfo;
  100060. private readonly _mapping;
  100061. /**
  100062. * Fired when the trackpad on this controller is clicked
  100063. */
  100064. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  100065. /**
  100066. * Fired when the trackpad on this controller is modified
  100067. */
  100068. onTrackpadValuesChangedObservable: Observable<StickValues>;
  100069. /**
  100070. * The current x and y values of this controller's trackpad
  100071. */
  100072. trackpad: StickValues;
  100073. /**
  100074. * Creates a new WindowsMotionController from a gamepad
  100075. * @param vrGamepad the gamepad that the controller should be created from
  100076. */
  100077. constructor(vrGamepad: any);
  100078. /**
  100079. * Fired when the trigger on this controller is modified
  100080. */
  100081. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100082. /**
  100083. * Fired when the menu button on this controller is modified
  100084. */
  100085. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100086. /**
  100087. * Fired when the grip button on this controller is modified
  100088. */
  100089. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100090. /**
  100091. * Fired when the thumbstick button on this controller is modified
  100092. */
  100093. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100094. /**
  100095. * Fired when the touchpad button on this controller is modified
  100096. */
  100097. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100098. /**
  100099. * Fired when the touchpad values on this controller are modified
  100100. */
  100101. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  100102. private _updateTrackpad;
  100103. /**
  100104. * Called once per frame by the engine.
  100105. */
  100106. update(): void;
  100107. /**
  100108. * Called once for each button that changed state since the last frame
  100109. * @param buttonIdx Which button index changed
  100110. * @param state New state of the button
  100111. * @param changes Which properties on the state changed since last frame
  100112. */
  100113. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100114. /**
  100115. * Moves the buttons on the controller mesh based on their current state
  100116. * @param buttonName the name of the button to move
  100117. * @param buttonValue the value of the button which determines the buttons new position
  100118. */
  100119. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  100120. /**
  100121. * Moves the axis on the controller mesh based on its current state
  100122. * @param axis the index of the axis
  100123. * @param axisValue the value of the axis which determines the meshes new position
  100124. * @hidden
  100125. */
  100126. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  100127. /**
  100128. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  100129. * @param scene scene in which to add meshes
  100130. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  100131. */
  100132. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  100133. /**
  100134. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  100135. * can be transformed by button presses and axes values, based on this._mapping.
  100136. *
  100137. * @param scene scene in which the meshes exist
  100138. * @param meshes list of meshes that make up the controller model to process
  100139. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  100140. */
  100141. private processModel;
  100142. private createMeshInfo;
  100143. /**
  100144. * Gets the ray of the controller in the direction the controller is pointing
  100145. * @param length the length the resulting ray should be
  100146. * @returns a ray in the direction the controller is pointing
  100147. */
  100148. getForwardRay(length?: number): Ray;
  100149. /**
  100150. * Disposes of the controller
  100151. */
  100152. dispose(): void;
  100153. }
  100154. }
  100155. declare module BABYLON {
  100156. /**
  100157. * Single axis scale gizmo
  100158. */
  100159. export class AxisScaleGizmo extends Gizmo {
  100160. private _coloredMaterial;
  100161. /**
  100162. * Drag behavior responsible for the gizmos dragging interactions
  100163. */
  100164. dragBehavior: PointerDragBehavior;
  100165. private _pointerObserver;
  100166. /**
  100167. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100168. */
  100169. snapDistance: number;
  100170. /**
  100171. * Event that fires each time the gizmo snaps to a new location.
  100172. * * snapDistance is the the change in distance
  100173. */
  100174. onSnapObservable: Observable<{
  100175. snapDistance: number;
  100176. }>;
  100177. /**
  100178. * If the scaling operation should be done on all axis (default: false)
  100179. */
  100180. uniformScaling: boolean;
  100181. /**
  100182. * Creates an AxisScaleGizmo
  100183. * @param gizmoLayer The utility layer the gizmo will be added to
  100184. * @param dragAxis The axis which the gizmo will be able to scale on
  100185. * @param color The color of the gizmo
  100186. */
  100187. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100188. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100189. /**
  100190. * Disposes of the gizmo
  100191. */
  100192. dispose(): void;
  100193. /**
  100194. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  100195. * @param mesh The mesh to replace the default mesh of the gizmo
  100196. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  100197. */
  100198. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  100199. }
  100200. }
  100201. declare module BABYLON {
  100202. /**
  100203. * Bounding box gizmo
  100204. */
  100205. export class BoundingBoxGizmo extends Gizmo {
  100206. private _lineBoundingBox;
  100207. private _rotateSpheresParent;
  100208. private _scaleBoxesParent;
  100209. private _boundingDimensions;
  100210. private _renderObserver;
  100211. private _pointerObserver;
  100212. private _scaleDragSpeed;
  100213. private _tmpQuaternion;
  100214. private _tmpVector;
  100215. private _tmpRotationMatrix;
  100216. /**
  100217. * 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)
  100218. */
  100219. ignoreChildren: boolean;
  100220. /**
  100221. * 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)
  100222. */
  100223. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  100224. /**
  100225. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  100226. */
  100227. rotationSphereSize: number;
  100228. /**
  100229. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  100230. */
  100231. scaleBoxSize: number;
  100232. /**
  100233. * 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)
  100234. */
  100235. fixedDragMeshScreenSize: boolean;
  100236. /**
  100237. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  100238. */
  100239. fixedDragMeshScreenSizeDistanceFactor: number;
  100240. /**
  100241. * Fired when a rotation sphere or scale box is dragged
  100242. */
  100243. onDragStartObservable: Observable<{}>;
  100244. /**
  100245. * Fired when a scale box is dragged
  100246. */
  100247. onScaleBoxDragObservable: Observable<{}>;
  100248. /**
  100249. * Fired when a scale box drag is ended
  100250. */
  100251. onScaleBoxDragEndObservable: Observable<{}>;
  100252. /**
  100253. * Fired when a rotation sphere is dragged
  100254. */
  100255. onRotationSphereDragObservable: Observable<{}>;
  100256. /**
  100257. * Fired when a rotation sphere drag is ended
  100258. */
  100259. onRotationSphereDragEndObservable: Observable<{}>;
  100260. /**
  100261. * 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)
  100262. */
  100263. scalePivot: Nullable<Vector3>;
  100264. private _anchorMesh;
  100265. private _existingMeshScale;
  100266. private _dragMesh;
  100267. private pointerDragBehavior;
  100268. private coloredMaterial;
  100269. private hoverColoredMaterial;
  100270. /**
  100271. * Sets the color of the bounding box gizmo
  100272. * @param color the color to set
  100273. */
  100274. setColor(color: Color3): void;
  100275. /**
  100276. * Creates an BoundingBoxGizmo
  100277. * @param gizmoLayer The utility layer the gizmo will be added to
  100278. * @param color The color of the gizmo
  100279. */
  100280. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100281. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100282. private _selectNode;
  100283. /**
  100284. * Updates the bounding box information for the Gizmo
  100285. */
  100286. updateBoundingBox(): void;
  100287. private _updateRotationSpheres;
  100288. private _updateScaleBoxes;
  100289. /**
  100290. * Enables rotation on the specified axis and disables rotation on the others
  100291. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  100292. */
  100293. setEnabledRotationAxis(axis: string): void;
  100294. /**
  100295. * Enables/disables scaling
  100296. * @param enable if scaling should be enabled
  100297. */
  100298. setEnabledScaling(enable: boolean): void;
  100299. private _updateDummy;
  100300. /**
  100301. * Enables a pointer drag behavior on the bounding box of the gizmo
  100302. */
  100303. enableDragBehavior(): void;
  100304. /**
  100305. * Disposes of the gizmo
  100306. */
  100307. dispose(): void;
  100308. /**
  100309. * 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)
  100310. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  100311. * @returns the bounding box mesh with the passed in mesh as a child
  100312. */
  100313. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  100314. /**
  100315. * CustomMeshes are not supported by this gizmo
  100316. * @param mesh The mesh to replace the default mesh of the gizmo
  100317. */
  100318. setCustomMesh(mesh: Mesh): void;
  100319. }
  100320. }
  100321. declare module BABYLON {
  100322. /**
  100323. * Single plane rotation gizmo
  100324. */
  100325. export class PlaneRotationGizmo extends Gizmo {
  100326. /**
  100327. * Drag behavior responsible for the gizmos dragging interactions
  100328. */
  100329. dragBehavior: PointerDragBehavior;
  100330. private _pointerObserver;
  100331. /**
  100332. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  100333. */
  100334. snapDistance: number;
  100335. /**
  100336. * Event that fires each time the gizmo snaps to a new location.
  100337. * * snapDistance is the the change in distance
  100338. */
  100339. onSnapObservable: Observable<{
  100340. snapDistance: number;
  100341. }>;
  100342. /**
  100343. * Creates a PlaneRotationGizmo
  100344. * @param gizmoLayer The utility layer the gizmo will be added to
  100345. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  100346. * @param color The color of the gizmo
  100347. * @param tessellation Amount of tessellation to be used when creating rotation circles
  100348. */
  100349. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  100350. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100351. /**
  100352. * Disposes of the gizmo
  100353. */
  100354. dispose(): void;
  100355. }
  100356. }
  100357. declare module BABYLON {
  100358. /**
  100359. * Gizmo that enables rotating a mesh along 3 axis
  100360. */
  100361. export class RotationGizmo extends Gizmo {
  100362. /**
  100363. * Internal gizmo used for interactions on the x axis
  100364. */
  100365. xGizmo: PlaneRotationGizmo;
  100366. /**
  100367. * Internal gizmo used for interactions on the y axis
  100368. */
  100369. yGizmo: PlaneRotationGizmo;
  100370. /**
  100371. * Internal gizmo used for interactions on the z axis
  100372. */
  100373. zGizmo: PlaneRotationGizmo;
  100374. /** Fires an event when any of it's sub gizmos are dragged */
  100375. onDragStartObservable: Observable<{}>;
  100376. /** Fires an event when any of it's sub gizmos are released from dragging */
  100377. onDragEndObservable: Observable<{}>;
  100378. attachedMesh: Nullable<AbstractMesh>;
  100379. /**
  100380. * Creates a RotationGizmo
  100381. * @param gizmoLayer The utility layer the gizmo will be added to
  100382. * @param tessellation Amount of tessellation to be used when creating rotation circles
  100383. */
  100384. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  100385. updateGizmoRotationToMatchAttachedMesh: boolean;
  100386. /**
  100387. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100388. */
  100389. snapDistance: number;
  100390. /**
  100391. * Ratio for the scale of the gizmo (Default: 1)
  100392. */
  100393. scaleRatio: number;
  100394. /**
  100395. * Disposes of the gizmo
  100396. */
  100397. dispose(): void;
  100398. /**
  100399. * CustomMeshes are not supported by this gizmo
  100400. * @param mesh The mesh to replace the default mesh of the gizmo
  100401. */
  100402. setCustomMesh(mesh: Mesh): void;
  100403. }
  100404. }
  100405. declare module BABYLON {
  100406. /**
  100407. * Gizmo that enables dragging a mesh along 3 axis
  100408. */
  100409. export class PositionGizmo extends Gizmo {
  100410. /**
  100411. * Internal gizmo used for interactions on the x axis
  100412. */
  100413. xGizmo: AxisDragGizmo;
  100414. /**
  100415. * Internal gizmo used for interactions on the y axis
  100416. */
  100417. yGizmo: AxisDragGizmo;
  100418. /**
  100419. * Internal gizmo used for interactions on the z axis
  100420. */
  100421. zGizmo: AxisDragGizmo;
  100422. /** Fires an event when any of it's sub gizmos are dragged */
  100423. onDragStartObservable: Observable<{}>;
  100424. /** Fires an event when any of it's sub gizmos are released from dragging */
  100425. onDragEndObservable: Observable<{}>;
  100426. attachedMesh: Nullable<AbstractMesh>;
  100427. /**
  100428. * Creates a PositionGizmo
  100429. * @param gizmoLayer The utility layer the gizmo will be added to
  100430. */
  100431. constructor(gizmoLayer?: UtilityLayerRenderer);
  100432. updateGizmoRotationToMatchAttachedMesh: boolean;
  100433. /**
  100434. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100435. */
  100436. snapDistance: number;
  100437. /**
  100438. * Ratio for the scale of the gizmo (Default: 1)
  100439. */
  100440. scaleRatio: number;
  100441. /**
  100442. * Disposes of the gizmo
  100443. */
  100444. dispose(): void;
  100445. /**
  100446. * CustomMeshes are not supported by this gizmo
  100447. * @param mesh The mesh to replace the default mesh of the gizmo
  100448. */
  100449. setCustomMesh(mesh: Mesh): void;
  100450. }
  100451. }
  100452. declare module BABYLON {
  100453. /**
  100454. * Class containing static functions to help procedurally build meshes
  100455. */
  100456. export class PolyhedronBuilder {
  100457. /**
  100458. * Creates a polyhedron mesh
  100459. * * 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
  100460. * * The parameter `size` (positive float, default 1) sets the polygon size
  100461. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  100462. * * 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`
  100463. * * 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
  100464. * * 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)`)
  100465. * * 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
  100466. * * 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
  100467. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100468. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100470. * @param name defines the name of the mesh
  100471. * @param options defines the options used to create the mesh
  100472. * @param scene defines the hosting scene
  100473. * @returns the polyhedron mesh
  100474. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  100475. */
  100476. static CreatePolyhedron(name: string, options: {
  100477. type?: number;
  100478. size?: number;
  100479. sizeX?: number;
  100480. sizeY?: number;
  100481. sizeZ?: number;
  100482. custom?: any;
  100483. faceUV?: Vector4[];
  100484. faceColors?: Color4[];
  100485. flat?: boolean;
  100486. updatable?: boolean;
  100487. sideOrientation?: number;
  100488. frontUVs?: Vector4;
  100489. backUVs?: Vector4;
  100490. }, scene: Scene): Mesh;
  100491. }
  100492. }
  100493. declare module BABYLON {
  100494. /**
  100495. * Gizmo that enables scaling a mesh along 3 axis
  100496. */
  100497. export class ScaleGizmo extends Gizmo {
  100498. /**
  100499. * Internal gizmo used for interactions on the x axis
  100500. */
  100501. xGizmo: AxisScaleGizmo;
  100502. /**
  100503. * Internal gizmo used for interactions on the y axis
  100504. */
  100505. yGizmo: AxisScaleGizmo;
  100506. /**
  100507. * Internal gizmo used for interactions on the z axis
  100508. */
  100509. zGizmo: AxisScaleGizmo;
  100510. /**
  100511. * Internal gizmo used to scale all axis equally
  100512. */
  100513. uniformScaleGizmo: AxisScaleGizmo;
  100514. /** Fires an event when any of it's sub gizmos are dragged */
  100515. onDragStartObservable: Observable<{}>;
  100516. /** Fires an event when any of it's sub gizmos are released from dragging */
  100517. onDragEndObservable: Observable<{}>;
  100518. attachedMesh: Nullable<AbstractMesh>;
  100519. /**
  100520. * Creates a ScaleGizmo
  100521. * @param gizmoLayer The utility layer the gizmo will be added to
  100522. */
  100523. constructor(gizmoLayer?: UtilityLayerRenderer);
  100524. updateGizmoRotationToMatchAttachedMesh: boolean;
  100525. /**
  100526. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100527. */
  100528. snapDistance: number;
  100529. /**
  100530. * Ratio for the scale of the gizmo (Default: 1)
  100531. */
  100532. scaleRatio: number;
  100533. /**
  100534. * Disposes of the gizmo
  100535. */
  100536. dispose(): void;
  100537. }
  100538. }
  100539. declare module BABYLON {
  100540. /**
  100541. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  100542. */
  100543. export class GizmoManager implements IDisposable {
  100544. private scene;
  100545. /**
  100546. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  100547. */
  100548. gizmos: {
  100549. positionGizmo: Nullable<PositionGizmo>;
  100550. rotationGizmo: Nullable<RotationGizmo>;
  100551. scaleGizmo: Nullable<ScaleGizmo>;
  100552. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  100553. };
  100554. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  100555. clearGizmoOnEmptyPointerEvent: boolean;
  100556. /** Fires an event when the manager is attached to a mesh */
  100557. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  100558. private _gizmosEnabled;
  100559. private _pointerObserver;
  100560. private _attachedMesh;
  100561. private _boundingBoxColor;
  100562. private _defaultUtilityLayer;
  100563. private _defaultKeepDepthUtilityLayer;
  100564. /**
  100565. * When bounding box gizmo is enabled, this can be used to track drag/end events
  100566. */
  100567. boundingBoxDragBehavior: SixDofDragBehavior;
  100568. /**
  100569. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  100570. */
  100571. attachableMeshes: Nullable<Array<AbstractMesh>>;
  100572. /**
  100573. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  100574. */
  100575. usePointerToAttachGizmos: boolean;
  100576. /**
  100577. * Instatiates a gizmo manager
  100578. * @param scene the scene to overlay the gizmos on top of
  100579. */
  100580. constructor(scene: Scene);
  100581. /**
  100582. * Attaches a set of gizmos to the specified mesh
  100583. * @param mesh The mesh the gizmo's should be attached to
  100584. */
  100585. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  100586. /**
  100587. * If the position gizmo is enabled
  100588. */
  100589. positionGizmoEnabled: boolean;
  100590. /**
  100591. * If the rotation gizmo is enabled
  100592. */
  100593. rotationGizmoEnabled: boolean;
  100594. /**
  100595. * If the scale gizmo is enabled
  100596. */
  100597. scaleGizmoEnabled: boolean;
  100598. /**
  100599. * If the boundingBox gizmo is enabled
  100600. */
  100601. boundingBoxGizmoEnabled: boolean;
  100602. /**
  100603. * Disposes of the gizmo manager
  100604. */
  100605. dispose(): void;
  100606. }
  100607. }
  100608. declare module BABYLON {
  100609. /**
  100610. * Gizmo that enables viewing a light
  100611. */
  100612. export class LightGizmo extends Gizmo {
  100613. private _box;
  100614. /**
  100615. * Creates a LightGizmo
  100616. * @param gizmoLayer The utility layer the gizmo will be added to
  100617. */
  100618. constructor(gizmoLayer?: UtilityLayerRenderer);
  100619. private _light;
  100620. /**
  100621. * The light that the gizmo is attached to
  100622. */
  100623. light: Nullable<Light>;
  100624. /**
  100625. * @hidden
  100626. * Updates the gizmo to match the attached mesh's position/rotation
  100627. */
  100628. protected _update(): void;
  100629. }
  100630. }
  100631. declare module BABYLON {
  100632. /** @hidden */
  100633. export var backgroundFragmentDeclaration: {
  100634. name: string;
  100635. shader: string;
  100636. };
  100637. }
  100638. declare module BABYLON {
  100639. /** @hidden */
  100640. export var backgroundUboDeclaration: {
  100641. name: string;
  100642. shader: string;
  100643. };
  100644. }
  100645. declare module BABYLON {
  100646. /** @hidden */
  100647. export var backgroundPixelShader: {
  100648. name: string;
  100649. shader: string;
  100650. };
  100651. }
  100652. declare module BABYLON {
  100653. /** @hidden */
  100654. export var backgroundVertexDeclaration: {
  100655. name: string;
  100656. shader: string;
  100657. };
  100658. }
  100659. declare module BABYLON {
  100660. /** @hidden */
  100661. export var backgroundVertexShader: {
  100662. name: string;
  100663. shader: string;
  100664. };
  100665. }
  100666. declare module BABYLON {
  100667. /**
  100668. * Background material used to create an efficient environement around your scene.
  100669. */
  100670. export class BackgroundMaterial extends PushMaterial {
  100671. /**
  100672. * Standard reflectance value at parallel view angle.
  100673. */
  100674. static StandardReflectance0: number;
  100675. /**
  100676. * Standard reflectance value at grazing angle.
  100677. */
  100678. static StandardReflectance90: number;
  100679. protected _primaryColor: Color3;
  100680. /**
  100681. * Key light Color (multiply against the environement texture)
  100682. */
  100683. primaryColor: Color3;
  100684. protected __perceptualColor: Nullable<Color3>;
  100685. /**
  100686. * Experimental Internal Use Only.
  100687. *
  100688. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  100689. * This acts as a helper to set the primary color to a more "human friendly" value.
  100690. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  100691. * output color as close as possible from the chosen value.
  100692. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  100693. * part of lighting setup.)
  100694. */
  100695. _perceptualColor: Nullable<Color3>;
  100696. protected _primaryColorShadowLevel: float;
  100697. /**
  100698. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  100699. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  100700. */
  100701. primaryColorShadowLevel: float;
  100702. protected _primaryColorHighlightLevel: float;
  100703. /**
  100704. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  100705. * The primary color is used at the level chosen to define what the white area would look.
  100706. */
  100707. primaryColorHighlightLevel: float;
  100708. protected _reflectionTexture: Nullable<BaseTexture>;
  100709. /**
  100710. * Reflection Texture used in the material.
  100711. * Should be author in a specific way for the best result (refer to the documentation).
  100712. */
  100713. reflectionTexture: Nullable<BaseTexture>;
  100714. protected _reflectionBlur: float;
  100715. /**
  100716. * Reflection Texture level of blur.
  100717. *
  100718. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  100719. * texture twice.
  100720. */
  100721. reflectionBlur: float;
  100722. protected _diffuseTexture: Nullable<BaseTexture>;
  100723. /**
  100724. * Diffuse Texture used in the material.
  100725. * Should be author in a specific way for the best result (refer to the documentation).
  100726. */
  100727. diffuseTexture: Nullable<BaseTexture>;
  100728. protected _shadowLights: Nullable<IShadowLight[]>;
  100729. /**
  100730. * Specify the list of lights casting shadow on the material.
  100731. * All scene shadow lights will be included if null.
  100732. */
  100733. shadowLights: Nullable<IShadowLight[]>;
  100734. protected _shadowLevel: float;
  100735. /**
  100736. * Helps adjusting the shadow to a softer level if required.
  100737. * 0 means black shadows and 1 means no shadows.
  100738. */
  100739. shadowLevel: float;
  100740. protected _sceneCenter: Vector3;
  100741. /**
  100742. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  100743. * It is usually zero but might be interesting to modify according to your setup.
  100744. */
  100745. sceneCenter: Vector3;
  100746. protected _opacityFresnel: boolean;
  100747. /**
  100748. * This helps specifying that the material is falling off to the sky box at grazing angle.
  100749. * This helps ensuring a nice transition when the camera goes under the ground.
  100750. */
  100751. opacityFresnel: boolean;
  100752. protected _reflectionFresnel: boolean;
  100753. /**
  100754. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  100755. * This helps adding a mirror texture on the ground.
  100756. */
  100757. reflectionFresnel: boolean;
  100758. protected _reflectionFalloffDistance: number;
  100759. /**
  100760. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  100761. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  100762. */
  100763. reflectionFalloffDistance: number;
  100764. protected _reflectionAmount: number;
  100765. /**
  100766. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  100767. */
  100768. reflectionAmount: number;
  100769. protected _reflectionReflectance0: number;
  100770. /**
  100771. * This specifies the weight of the reflection at grazing angle.
  100772. */
  100773. reflectionReflectance0: number;
  100774. protected _reflectionReflectance90: number;
  100775. /**
  100776. * This specifies the weight of the reflection at a perpendicular point of view.
  100777. */
  100778. reflectionReflectance90: number;
  100779. /**
  100780. * Sets the reflection reflectance fresnel values according to the default standard
  100781. * empirically know to work well :-)
  100782. */
  100783. reflectionStandardFresnelWeight: number;
  100784. protected _useRGBColor: boolean;
  100785. /**
  100786. * Helps to directly use the maps channels instead of their level.
  100787. */
  100788. useRGBColor: boolean;
  100789. protected _enableNoise: boolean;
  100790. /**
  100791. * This helps reducing the banding effect that could occur on the background.
  100792. */
  100793. enableNoise: boolean;
  100794. /**
  100795. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  100796. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  100797. * Recommended to be keep at 1.0 except for special cases.
  100798. */
  100799. fovMultiplier: number;
  100800. private _fovMultiplier;
  100801. /**
  100802. * Enable the FOV adjustment feature controlled by fovMultiplier.
  100803. */
  100804. useEquirectangularFOV: boolean;
  100805. private _maxSimultaneousLights;
  100806. /**
  100807. * Number of Simultaneous lights allowed on the material.
  100808. */
  100809. maxSimultaneousLights: int;
  100810. /**
  100811. * Default configuration related to image processing available in the Background Material.
  100812. */
  100813. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100814. /**
  100815. * Keep track of the image processing observer to allow dispose and replace.
  100816. */
  100817. private _imageProcessingObserver;
  100818. /**
  100819. * Attaches a new image processing configuration to the PBR Material.
  100820. * @param configuration (if null the scene configuration will be use)
  100821. */
  100822. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100823. /**
  100824. * Gets the image processing configuration used either in this material.
  100825. */
  100826. /**
  100827. * Sets the Default image processing configuration used either in the this material.
  100828. *
  100829. * If sets to null, the scene one is in use.
  100830. */
  100831. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  100832. /**
  100833. * Gets wether the color curves effect is enabled.
  100834. */
  100835. /**
  100836. * Sets wether the color curves effect is enabled.
  100837. */
  100838. cameraColorCurvesEnabled: boolean;
  100839. /**
  100840. * Gets wether the color grading effect is enabled.
  100841. */
  100842. /**
  100843. * Gets wether the color grading effect is enabled.
  100844. */
  100845. cameraColorGradingEnabled: boolean;
  100846. /**
  100847. * Gets wether tonemapping is enabled or not.
  100848. */
  100849. /**
  100850. * Sets wether tonemapping is enabled or not
  100851. */
  100852. cameraToneMappingEnabled: boolean;
  100853. /**
  100854. * The camera exposure used on this material.
  100855. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100856. * This corresponds to a photographic exposure.
  100857. */
  100858. /**
  100859. * The camera exposure used on this material.
  100860. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100861. * This corresponds to a photographic exposure.
  100862. */
  100863. cameraExposure: float;
  100864. /**
  100865. * Gets The camera contrast used on this material.
  100866. */
  100867. /**
  100868. * Sets The camera contrast used on this material.
  100869. */
  100870. cameraContrast: float;
  100871. /**
  100872. * Gets the Color Grading 2D Lookup Texture.
  100873. */
  100874. /**
  100875. * Sets the Color Grading 2D Lookup Texture.
  100876. */
  100877. cameraColorGradingTexture: Nullable<BaseTexture>;
  100878. /**
  100879. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100880. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100881. * 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;
  100882. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100883. */
  100884. /**
  100885. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100886. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100887. * 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;
  100888. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100889. */
  100890. cameraColorCurves: Nullable<ColorCurves>;
  100891. /**
  100892. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  100893. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  100894. */
  100895. switchToBGR: boolean;
  100896. private _renderTargets;
  100897. private _reflectionControls;
  100898. private _white;
  100899. private _primaryShadowColor;
  100900. private _primaryHighlightColor;
  100901. /**
  100902. * Instantiates a Background Material in the given scene
  100903. * @param name The friendly name of the material
  100904. * @param scene The scene to add the material to
  100905. */
  100906. constructor(name: string, scene: Scene);
  100907. /**
  100908. * Gets a boolean indicating that current material needs to register RTT
  100909. */
  100910. readonly hasRenderTargetTextures: boolean;
  100911. /**
  100912. * The entire material has been created in order to prevent overdraw.
  100913. * @returns false
  100914. */
  100915. needAlphaTesting(): boolean;
  100916. /**
  100917. * The entire material has been created in order to prevent overdraw.
  100918. * @returns true if blending is enable
  100919. */
  100920. needAlphaBlending(): boolean;
  100921. /**
  100922. * Checks wether the material is ready to be rendered for a given mesh.
  100923. * @param mesh The mesh to render
  100924. * @param subMesh The submesh to check against
  100925. * @param useInstances Specify wether or not the material is used with instances
  100926. * @returns true if all the dependencies are ready (Textures, Effects...)
  100927. */
  100928. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100929. /**
  100930. * Compute the primary color according to the chosen perceptual color.
  100931. */
  100932. private _computePrimaryColorFromPerceptualColor;
  100933. /**
  100934. * Compute the highlights and shadow colors according to their chosen levels.
  100935. */
  100936. private _computePrimaryColors;
  100937. /**
  100938. * Build the uniform buffer used in the material.
  100939. */
  100940. buildUniformLayout(): void;
  100941. /**
  100942. * Unbind the material.
  100943. */
  100944. unbind(): void;
  100945. /**
  100946. * Bind only the world matrix to the material.
  100947. * @param world The world matrix to bind.
  100948. */
  100949. bindOnlyWorldMatrix(world: Matrix): void;
  100950. /**
  100951. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  100952. * @param world The world matrix to bind.
  100953. * @param subMesh The submesh to bind for.
  100954. */
  100955. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100956. /**
  100957. * Dispose the material.
  100958. * @param forceDisposeEffect Force disposal of the associated effect.
  100959. * @param forceDisposeTextures Force disposal of the associated textures.
  100960. */
  100961. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100962. /**
  100963. * Clones the material.
  100964. * @param name The cloned name.
  100965. * @returns The cloned material.
  100966. */
  100967. clone(name: string): BackgroundMaterial;
  100968. /**
  100969. * Serializes the current material to its JSON representation.
  100970. * @returns The JSON representation.
  100971. */
  100972. serialize(): any;
  100973. /**
  100974. * Gets the class name of the material
  100975. * @returns "BackgroundMaterial"
  100976. */
  100977. getClassName(): string;
  100978. /**
  100979. * Parse a JSON input to create back a background material.
  100980. * @param source The JSON data to parse
  100981. * @param scene The scene to create the parsed material in
  100982. * @param rootUrl The root url of the assets the material depends upon
  100983. * @returns the instantiated BackgroundMaterial.
  100984. */
  100985. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  100986. }
  100987. }
  100988. declare module BABYLON {
  100989. /**
  100990. * Represents the different options available during the creation of
  100991. * a Environment helper.
  100992. *
  100993. * This can control the default ground, skybox and image processing setup of your scene.
  100994. */
  100995. export interface IEnvironmentHelperOptions {
  100996. /**
  100997. * Specifies wether or not to create a ground.
  100998. * True by default.
  100999. */
  101000. createGround: boolean;
  101001. /**
  101002. * Specifies the ground size.
  101003. * 15 by default.
  101004. */
  101005. groundSize: number;
  101006. /**
  101007. * The texture used on the ground for the main color.
  101008. * Comes from the BabylonJS CDN by default.
  101009. *
  101010. * Remarks: Can be either a texture or a url.
  101011. */
  101012. groundTexture: string | BaseTexture;
  101013. /**
  101014. * The color mixed in the ground texture by default.
  101015. * BabylonJS clearColor by default.
  101016. */
  101017. groundColor: Color3;
  101018. /**
  101019. * Specifies the ground opacity.
  101020. * 1 by default.
  101021. */
  101022. groundOpacity: number;
  101023. /**
  101024. * Enables the ground to receive shadows.
  101025. * True by default.
  101026. */
  101027. enableGroundShadow: boolean;
  101028. /**
  101029. * Helps preventing the shadow to be fully black on the ground.
  101030. * 0.5 by default.
  101031. */
  101032. groundShadowLevel: number;
  101033. /**
  101034. * Creates a mirror texture attach to the ground.
  101035. * false by default.
  101036. */
  101037. enableGroundMirror: boolean;
  101038. /**
  101039. * Specifies the ground mirror size ratio.
  101040. * 0.3 by default as the default kernel is 64.
  101041. */
  101042. groundMirrorSizeRatio: number;
  101043. /**
  101044. * Specifies the ground mirror blur kernel size.
  101045. * 64 by default.
  101046. */
  101047. groundMirrorBlurKernel: number;
  101048. /**
  101049. * Specifies the ground mirror visibility amount.
  101050. * 1 by default
  101051. */
  101052. groundMirrorAmount: number;
  101053. /**
  101054. * Specifies the ground mirror reflectance weight.
  101055. * This uses the standard weight of the background material to setup the fresnel effect
  101056. * of the mirror.
  101057. * 1 by default.
  101058. */
  101059. groundMirrorFresnelWeight: number;
  101060. /**
  101061. * Specifies the ground mirror Falloff distance.
  101062. * This can helps reducing the size of the reflection.
  101063. * 0 by Default.
  101064. */
  101065. groundMirrorFallOffDistance: number;
  101066. /**
  101067. * Specifies the ground mirror texture type.
  101068. * Unsigned Int by Default.
  101069. */
  101070. groundMirrorTextureType: number;
  101071. /**
  101072. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  101073. * the shown objects.
  101074. */
  101075. groundYBias: number;
  101076. /**
  101077. * Specifies wether or not to create a skybox.
  101078. * True by default.
  101079. */
  101080. createSkybox: boolean;
  101081. /**
  101082. * Specifies the skybox size.
  101083. * 20 by default.
  101084. */
  101085. skyboxSize: number;
  101086. /**
  101087. * The texture used on the skybox for the main color.
  101088. * Comes from the BabylonJS CDN by default.
  101089. *
  101090. * Remarks: Can be either a texture or a url.
  101091. */
  101092. skyboxTexture: string | BaseTexture;
  101093. /**
  101094. * The color mixed in the skybox texture by default.
  101095. * BabylonJS clearColor by default.
  101096. */
  101097. skyboxColor: Color3;
  101098. /**
  101099. * The background rotation around the Y axis of the scene.
  101100. * This helps aligning the key lights of your scene with the background.
  101101. * 0 by default.
  101102. */
  101103. backgroundYRotation: number;
  101104. /**
  101105. * Compute automatically the size of the elements to best fit with the scene.
  101106. */
  101107. sizeAuto: boolean;
  101108. /**
  101109. * Default position of the rootMesh if autoSize is not true.
  101110. */
  101111. rootPosition: Vector3;
  101112. /**
  101113. * Sets up the image processing in the scene.
  101114. * true by default.
  101115. */
  101116. setupImageProcessing: boolean;
  101117. /**
  101118. * The texture used as your environment texture in the scene.
  101119. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  101120. *
  101121. * Remarks: Can be either a texture or a url.
  101122. */
  101123. environmentTexture: string | BaseTexture;
  101124. /**
  101125. * The value of the exposure to apply to the scene.
  101126. * 0.6 by default if setupImageProcessing is true.
  101127. */
  101128. cameraExposure: number;
  101129. /**
  101130. * The value of the contrast to apply to the scene.
  101131. * 1.6 by default if setupImageProcessing is true.
  101132. */
  101133. cameraContrast: number;
  101134. /**
  101135. * Specifies wether or not tonemapping should be enabled in the scene.
  101136. * true by default if setupImageProcessing is true.
  101137. */
  101138. toneMappingEnabled: boolean;
  101139. }
  101140. /**
  101141. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  101142. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  101143. * It also helps with the default setup of your imageProcessing configuration.
  101144. */
  101145. export class EnvironmentHelper {
  101146. /**
  101147. * Default ground texture URL.
  101148. */
  101149. private static _groundTextureCDNUrl;
  101150. /**
  101151. * Default skybox texture URL.
  101152. */
  101153. private static _skyboxTextureCDNUrl;
  101154. /**
  101155. * Default environment texture URL.
  101156. */
  101157. private static _environmentTextureCDNUrl;
  101158. /**
  101159. * Creates the default options for the helper.
  101160. */
  101161. private static _getDefaultOptions;
  101162. private _rootMesh;
  101163. /**
  101164. * Gets the root mesh created by the helper.
  101165. */
  101166. readonly rootMesh: Mesh;
  101167. private _skybox;
  101168. /**
  101169. * Gets the skybox created by the helper.
  101170. */
  101171. readonly skybox: Nullable<Mesh>;
  101172. private _skyboxTexture;
  101173. /**
  101174. * Gets the skybox texture created by the helper.
  101175. */
  101176. readonly skyboxTexture: Nullable<BaseTexture>;
  101177. private _skyboxMaterial;
  101178. /**
  101179. * Gets the skybox material created by the helper.
  101180. */
  101181. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  101182. private _ground;
  101183. /**
  101184. * Gets the ground mesh created by the helper.
  101185. */
  101186. readonly ground: Nullable<Mesh>;
  101187. private _groundTexture;
  101188. /**
  101189. * Gets the ground texture created by the helper.
  101190. */
  101191. readonly groundTexture: Nullable<BaseTexture>;
  101192. private _groundMirror;
  101193. /**
  101194. * Gets the ground mirror created by the helper.
  101195. */
  101196. readonly groundMirror: Nullable<MirrorTexture>;
  101197. /**
  101198. * Gets the ground mirror render list to helps pushing the meshes
  101199. * you wish in the ground reflection.
  101200. */
  101201. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  101202. private _groundMaterial;
  101203. /**
  101204. * Gets the ground material created by the helper.
  101205. */
  101206. readonly groundMaterial: Nullable<BackgroundMaterial>;
  101207. /**
  101208. * Stores the creation options.
  101209. */
  101210. private readonly _scene;
  101211. private _options;
  101212. /**
  101213. * This observable will be notified with any error during the creation of the environment,
  101214. * mainly texture creation errors.
  101215. */
  101216. onErrorObservable: Observable<{
  101217. message?: string;
  101218. exception?: any;
  101219. }>;
  101220. /**
  101221. * constructor
  101222. * @param options Defines the options we want to customize the helper
  101223. * @param scene The scene to add the material to
  101224. */
  101225. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  101226. /**
  101227. * Updates the background according to the new options
  101228. * @param options
  101229. */
  101230. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  101231. /**
  101232. * Sets the primary color of all the available elements.
  101233. * @param color the main color to affect to the ground and the background
  101234. */
  101235. setMainColor(color: Color3): void;
  101236. /**
  101237. * Setup the image processing according to the specified options.
  101238. */
  101239. private _setupImageProcessing;
  101240. /**
  101241. * Setup the environment texture according to the specified options.
  101242. */
  101243. private _setupEnvironmentTexture;
  101244. /**
  101245. * Setup the background according to the specified options.
  101246. */
  101247. private _setupBackground;
  101248. /**
  101249. * Get the scene sizes according to the setup.
  101250. */
  101251. private _getSceneSize;
  101252. /**
  101253. * Setup the ground according to the specified options.
  101254. */
  101255. private _setupGround;
  101256. /**
  101257. * Setup the ground material according to the specified options.
  101258. */
  101259. private _setupGroundMaterial;
  101260. /**
  101261. * Setup the ground diffuse texture according to the specified options.
  101262. */
  101263. private _setupGroundDiffuseTexture;
  101264. /**
  101265. * Setup the ground mirror texture according to the specified options.
  101266. */
  101267. private _setupGroundMirrorTexture;
  101268. /**
  101269. * Setup the ground to receive the mirror texture.
  101270. */
  101271. private _setupMirrorInGroundMaterial;
  101272. /**
  101273. * Setup the skybox according to the specified options.
  101274. */
  101275. private _setupSkybox;
  101276. /**
  101277. * Setup the skybox material according to the specified options.
  101278. */
  101279. private _setupSkyboxMaterial;
  101280. /**
  101281. * Setup the skybox reflection texture according to the specified options.
  101282. */
  101283. private _setupSkyboxReflectionTexture;
  101284. private _errorHandler;
  101285. /**
  101286. * Dispose all the elements created by the Helper.
  101287. */
  101288. dispose(): void;
  101289. }
  101290. }
  101291. declare module BABYLON {
  101292. /**
  101293. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  101294. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  101295. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  101296. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  101297. */
  101298. export class PhotoDome extends TransformNode {
  101299. private _useDirectMapping;
  101300. /**
  101301. * The texture being displayed on the sphere
  101302. */
  101303. protected _photoTexture: Texture;
  101304. /**
  101305. * Gets or sets the texture being displayed on the sphere
  101306. */
  101307. photoTexture: Texture;
  101308. /**
  101309. * Observable raised when an error occured while loading the 360 image
  101310. */
  101311. onLoadErrorObservable: Observable<string>;
  101312. /**
  101313. * The skybox material
  101314. */
  101315. protected _material: BackgroundMaterial;
  101316. /**
  101317. * The surface used for the skybox
  101318. */
  101319. protected _mesh: Mesh;
  101320. /**
  101321. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  101322. * Also see the options.resolution property.
  101323. */
  101324. fovMultiplier: number;
  101325. /**
  101326. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  101327. * @param name Element's name, child elements will append suffixes for their own names.
  101328. * @param urlsOfPhoto defines the url of the photo to display
  101329. * @param options defines an object containing optional or exposed sub element properties
  101330. * @param onError defines a callback called when an error occured while loading the texture
  101331. */
  101332. constructor(name: string, urlOfPhoto: string, options: {
  101333. resolution?: number;
  101334. size?: number;
  101335. useDirectMapping?: boolean;
  101336. faceForward?: boolean;
  101337. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  101338. /**
  101339. * Releases resources associated with this node.
  101340. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101341. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101342. */
  101343. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101344. }
  101345. }
  101346. declare module BABYLON {
  101347. /**
  101348. * Class used to host texture specific utilities
  101349. */
  101350. export class TextureTools {
  101351. /**
  101352. * Uses the GPU to create a copy texture rescaled at a given size
  101353. * @param texture Texture to copy from
  101354. * @param width defines the desired width
  101355. * @param height defines the desired height
  101356. * @param useBilinearMode defines if bilinear mode has to be used
  101357. * @return the generated texture
  101358. */
  101359. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  101360. /**
  101361. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  101362. * @param scene defines the hosting scene
  101363. * @returns the environment BRDF texture
  101364. */
  101365. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  101366. private static _environmentBRDFBase64Texture;
  101367. }
  101368. }
  101369. declare module BABYLON {
  101370. /**
  101371. * @hidden
  101372. */
  101373. export interface IMaterialClearCoatDefines {
  101374. CLEARCOAT: boolean;
  101375. CLEARCOAT_DEFAULTIOR: boolean;
  101376. CLEARCOAT_TEXTURE: boolean;
  101377. CLEARCOAT_TEXTUREDIRECTUV: number;
  101378. CLEARCOAT_BUMP: boolean;
  101379. CLEARCOAT_BUMPDIRECTUV: number;
  101380. CLEARCOAT_TINT: boolean;
  101381. CLEARCOAT_TINT_TEXTURE: boolean;
  101382. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  101383. /** @hidden */
  101384. _areTexturesDirty: boolean;
  101385. }
  101386. /**
  101387. * Define the code related to the clear coat parameters of the pbr material.
  101388. */
  101389. export class PBRClearCoatConfiguration {
  101390. /**
  101391. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  101392. * The default fits with a polyurethane material.
  101393. */
  101394. private static readonly _DefaultIndiceOfRefraction;
  101395. private _isEnabled;
  101396. /**
  101397. * Defines if the clear coat is enabled in the material.
  101398. */
  101399. isEnabled: boolean;
  101400. /**
  101401. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  101402. */
  101403. intensity: number;
  101404. /**
  101405. * Defines the clear coat layer roughness.
  101406. */
  101407. roughness: number;
  101408. private _indiceOfRefraction;
  101409. /**
  101410. * Defines the indice of refraction of the clear coat.
  101411. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  101412. * The default fits with a polyurethane material.
  101413. * Changing the default value is more performance intensive.
  101414. */
  101415. indiceOfRefraction: number;
  101416. private _texture;
  101417. /**
  101418. * Stores the clear coat values in a texture.
  101419. */
  101420. texture: Nullable<BaseTexture>;
  101421. private _bumpTexture;
  101422. /**
  101423. * Define the clear coat specific bump texture.
  101424. */
  101425. bumpTexture: Nullable<BaseTexture>;
  101426. private _isTintEnabled;
  101427. /**
  101428. * Defines if the clear coat tint is enabled in the material.
  101429. */
  101430. isTintEnabled: boolean;
  101431. /**
  101432. * Defines if the clear coat tint is enabled in the material.
  101433. * This is only use if tint is enabled
  101434. */
  101435. tintColor: Color3;
  101436. /**
  101437. * Defines if the distance at which the tint color should be found in the
  101438. * clear coat media.
  101439. * This is only use if tint is enabled
  101440. */
  101441. tintColorAtDistance: number;
  101442. /**
  101443. * Defines the clear coat layer thickness.
  101444. * This is only use if tint is enabled
  101445. */
  101446. tintThickness: number;
  101447. private _tintTexture;
  101448. /**
  101449. * Stores the clear tint values in a texture.
  101450. * rgb is tint
  101451. * a is a thickness factor
  101452. */
  101453. tintTexture: Nullable<BaseTexture>;
  101454. /** @hidden */
  101455. private _internalMarkAllSubMeshesAsTexturesDirty;
  101456. /** @hidden */
  101457. _markAllSubMeshesAsTexturesDirty(): void;
  101458. /**
  101459. * Instantiate a new istance of clear coat configuration.
  101460. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101461. */
  101462. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101463. /**
  101464. * Specifies that the submesh is ready to be used.
  101465. * @param defines the list of "defines" to update.
  101466. * @param scene defines the scene the material belongs to.
  101467. * @param engine defines the engine the material belongs to.
  101468. * @param disableBumpMap defines wether the material disables bump or not.
  101469. * @returns - boolean indicating that the submesh is ready or not.
  101470. */
  101471. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  101472. /**
  101473. * Checks to see if a texture is used in the material.
  101474. * @param defines the list of "defines" to update.
  101475. * @param scene defines the scene to the material belongs to.
  101476. */
  101477. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  101478. /**
  101479. * Binds the material data.
  101480. * @param uniformBuffer defines the Uniform buffer to fill in.
  101481. * @param scene defines the scene the material belongs to.
  101482. * @param engine defines the engine the material belongs to.
  101483. * @param disableBumpMap defines wether the material disables bump or not.
  101484. * @param isFrozen defines wether the material is frozen or not.
  101485. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  101486. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  101487. */
  101488. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  101489. /**
  101490. * Checks to see if a texture is used in the material.
  101491. * @param texture - Base texture to use.
  101492. * @returns - Boolean specifying if a texture is used in the material.
  101493. */
  101494. hasTexture(texture: BaseTexture): boolean;
  101495. /**
  101496. * Returns an array of the actively used textures.
  101497. * @param activeTextures Array of BaseTextures
  101498. */
  101499. getActiveTextures(activeTextures: BaseTexture[]): void;
  101500. /**
  101501. * Returns the animatable textures.
  101502. * @param animatables Array of animatable textures.
  101503. */
  101504. getAnimatables(animatables: IAnimatable[]): void;
  101505. /**
  101506. * Disposes the resources of the material.
  101507. * @param forceDisposeTextures - Forces the disposal of all textures.
  101508. */
  101509. dispose(forceDisposeTextures?: boolean): void;
  101510. /**
  101511. * Get the current class name of the texture useful for serialization or dynamic coding.
  101512. * @returns "PBRClearCoatConfiguration"
  101513. */
  101514. getClassName(): string;
  101515. /**
  101516. * Add fallbacks to the effect fallbacks list.
  101517. * @param defines defines the Base texture to use.
  101518. * @param fallbacks defines the current fallback list.
  101519. * @param currentRank defines the current fallback rank.
  101520. * @returns the new fallback rank.
  101521. */
  101522. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101523. /**
  101524. * Add the required uniforms to the current list.
  101525. * @param uniforms defines the current uniform list.
  101526. */
  101527. static AddUniforms(uniforms: string[]): void;
  101528. /**
  101529. * Add the required samplers to the current list.
  101530. * @param samplers defines the current sampler list.
  101531. */
  101532. static AddSamplers(samplers: string[]): void;
  101533. /**
  101534. * Add the required uniforms to the current buffer.
  101535. * @param uniformBuffer defines the current uniform buffer.
  101536. */
  101537. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101538. /**
  101539. * Makes a duplicate of the current configuration into another one.
  101540. * @param clearCoatConfiguration define the config where to copy the info
  101541. */
  101542. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  101543. /**
  101544. * Serializes this clear coat configuration.
  101545. * @returns - An object with the serialized config.
  101546. */
  101547. serialize(): any;
  101548. /**
  101549. * Parses a Clear Coat Configuration from a serialized object.
  101550. * @param source - Serialized object.
  101551. */
  101552. parse(source: any): void;
  101553. }
  101554. }
  101555. declare module BABYLON {
  101556. /**
  101557. * @hidden
  101558. */
  101559. export interface IMaterialAnisotropicDefines {
  101560. ANISOTROPIC: boolean;
  101561. ANISOTROPIC_TEXTURE: boolean;
  101562. ANISOTROPIC_TEXTUREDIRECTUV: number;
  101563. MAINUV1: boolean;
  101564. _areTexturesDirty: boolean;
  101565. _needUVs: boolean;
  101566. }
  101567. /**
  101568. * Define the code related to the anisotropic parameters of the pbr material.
  101569. */
  101570. export class PBRAnisotropicConfiguration {
  101571. private _isEnabled;
  101572. /**
  101573. * Defines if the anisotropy is enabled in the material.
  101574. */
  101575. isEnabled: boolean;
  101576. /**
  101577. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  101578. */
  101579. intensity: number;
  101580. /**
  101581. * Defines if the effect is along the tangents, bitangents or in between.
  101582. * By default, the effect is "strectching" the highlights along the tangents.
  101583. */
  101584. direction: Vector2;
  101585. private _texture;
  101586. /**
  101587. * Stores the anisotropy values in a texture.
  101588. * rg is direction (like normal from -1 to 1)
  101589. * b is a intensity
  101590. */
  101591. texture: Nullable<BaseTexture>;
  101592. /** @hidden */
  101593. private _internalMarkAllSubMeshesAsTexturesDirty;
  101594. /** @hidden */
  101595. _markAllSubMeshesAsTexturesDirty(): void;
  101596. /**
  101597. * Instantiate a new istance of anisotropy configuration.
  101598. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101599. */
  101600. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101601. /**
  101602. * Specifies that the submesh is ready to be used.
  101603. * @param defines the list of "defines" to update.
  101604. * @param scene defines the scene the material belongs to.
  101605. * @returns - boolean indicating that the submesh is ready or not.
  101606. */
  101607. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  101608. /**
  101609. * Checks to see if a texture is used in the material.
  101610. * @param defines the list of "defines" to update.
  101611. * @param mesh the mesh we are preparing the defines for.
  101612. * @param scene defines the scene the material belongs to.
  101613. */
  101614. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  101615. /**
  101616. * Binds the material data.
  101617. * @param uniformBuffer defines the Uniform buffer to fill in.
  101618. * @param scene defines the scene the material belongs to.
  101619. * @param isFrozen defines wether the material is frozen or not.
  101620. */
  101621. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  101622. /**
  101623. * Checks to see if a texture is used in the material.
  101624. * @param texture - Base texture to use.
  101625. * @returns - Boolean specifying if a texture is used in the material.
  101626. */
  101627. hasTexture(texture: BaseTexture): boolean;
  101628. /**
  101629. * Returns an array of the actively used textures.
  101630. * @param activeTextures Array of BaseTextures
  101631. */
  101632. getActiveTextures(activeTextures: BaseTexture[]): void;
  101633. /**
  101634. * Returns the animatable textures.
  101635. * @param animatables Array of animatable textures.
  101636. */
  101637. getAnimatables(animatables: IAnimatable[]): void;
  101638. /**
  101639. * Disposes the resources of the material.
  101640. * @param forceDisposeTextures - Forces the disposal of all textures.
  101641. */
  101642. dispose(forceDisposeTextures?: boolean): void;
  101643. /**
  101644. * Get the current class name of the texture useful for serialization or dynamic coding.
  101645. * @returns "PBRAnisotropicConfiguration"
  101646. */
  101647. getClassName(): string;
  101648. /**
  101649. * Add fallbacks to the effect fallbacks list.
  101650. * @param defines defines the Base texture to use.
  101651. * @param fallbacks defines the current fallback list.
  101652. * @param currentRank defines the current fallback rank.
  101653. * @returns the new fallback rank.
  101654. */
  101655. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101656. /**
  101657. * Add the required uniforms to the current list.
  101658. * @param uniforms defines the current uniform list.
  101659. */
  101660. static AddUniforms(uniforms: string[]): void;
  101661. /**
  101662. * Add the required uniforms to the current buffer.
  101663. * @param uniformBuffer defines the current uniform buffer.
  101664. */
  101665. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101666. /**
  101667. * Add the required samplers to the current list.
  101668. * @param samplers defines the current sampler list.
  101669. */
  101670. static AddSamplers(samplers: string[]): void;
  101671. /**
  101672. * Makes a duplicate of the current configuration into another one.
  101673. * @param anisotropicConfiguration define the config where to copy the info
  101674. */
  101675. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  101676. /**
  101677. * Serializes this anisotropy configuration.
  101678. * @returns - An object with the serialized config.
  101679. */
  101680. serialize(): any;
  101681. /**
  101682. * Parses a anisotropy Configuration from a serialized object.
  101683. * @param source - Serialized object.
  101684. */
  101685. parse(source: any): void;
  101686. }
  101687. }
  101688. declare module BABYLON {
  101689. /**
  101690. * @hidden
  101691. */
  101692. export interface IMaterialBRDFDefines {
  101693. BRDF_V_HEIGHT_CORRELATED: boolean;
  101694. MS_BRDF_ENERGY_CONSERVATION: boolean;
  101695. /** @hidden */
  101696. _areMiscDirty: boolean;
  101697. }
  101698. /**
  101699. * Define the code related to the BRDF parameters of the pbr material.
  101700. */
  101701. export class PBRBRDFConfiguration {
  101702. private _useEnergyConservation;
  101703. /**
  101704. * Defines if the material uses energy conservation.
  101705. */
  101706. useEnergyConservation: boolean;
  101707. private _useSmithVisibilityHeightCorrelated;
  101708. /**
  101709. * LEGACY Mode set to false
  101710. * Defines if the material uses height smith correlated visibility term.
  101711. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  101712. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  101713. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  101714. * Not relying on height correlated will also disable energy conservation.
  101715. */
  101716. useSmithVisibilityHeightCorrelated: boolean;
  101717. /** @hidden */
  101718. private _internalMarkAllSubMeshesAsMiscDirty;
  101719. /** @hidden */
  101720. _markAllSubMeshesAsMiscDirty(): void;
  101721. /**
  101722. * Instantiate a new istance of clear coat configuration.
  101723. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  101724. */
  101725. constructor(markAllSubMeshesAsMiscDirty: () => void);
  101726. /**
  101727. * Checks to see if a texture is used in the material.
  101728. * @param defines the list of "defines" to update.
  101729. */
  101730. prepareDefines(defines: IMaterialBRDFDefines): void;
  101731. /**
  101732. * Get the current class name of the texture useful for serialization or dynamic coding.
  101733. * @returns "PBRClearCoatConfiguration"
  101734. */
  101735. getClassName(): string;
  101736. /**
  101737. * Makes a duplicate of the current configuration into another one.
  101738. * @param brdfConfiguration define the config where to copy the info
  101739. */
  101740. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  101741. /**
  101742. * Serializes this BRDF configuration.
  101743. * @returns - An object with the serialized config.
  101744. */
  101745. serialize(): any;
  101746. /**
  101747. * Parses a BRDF Configuration from a serialized object.
  101748. * @param source - Serialized object.
  101749. */
  101750. parse(source: any): void;
  101751. }
  101752. }
  101753. declare module BABYLON {
  101754. /**
  101755. * @hidden
  101756. */
  101757. export interface IMaterialSheenDefines {
  101758. SHEEN: boolean;
  101759. SHEEN_TEXTURE: boolean;
  101760. SHEEN_TEXTUREDIRECTUV: number;
  101761. SHEEN_LINKWITHALBEDO: boolean;
  101762. /** @hidden */
  101763. _areTexturesDirty: boolean;
  101764. }
  101765. /**
  101766. * Define the code related to the Sheen parameters of the pbr material.
  101767. */
  101768. export class PBRSheenConfiguration {
  101769. private _isEnabled;
  101770. /**
  101771. * Defines if the material uses sheen.
  101772. */
  101773. isEnabled: boolean;
  101774. private _linkSheenWithAlbedo;
  101775. /**
  101776. * Defines if the sheen is linked to the sheen color.
  101777. */
  101778. linkSheenWithAlbedo: boolean;
  101779. /**
  101780. * Defines the sheen intensity.
  101781. */
  101782. intensity: number;
  101783. /**
  101784. * Defines the sheen color.
  101785. */
  101786. color: Color3;
  101787. private _texture;
  101788. /**
  101789. * Stores the sheen tint values in a texture.
  101790. * rgb is tint
  101791. * a is a intensity
  101792. */
  101793. texture: Nullable<BaseTexture>;
  101794. /** @hidden */
  101795. private _internalMarkAllSubMeshesAsTexturesDirty;
  101796. /** @hidden */
  101797. _markAllSubMeshesAsTexturesDirty(): void;
  101798. /**
  101799. * Instantiate a new istance of clear coat configuration.
  101800. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101801. */
  101802. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101803. /**
  101804. * Specifies that the submesh is ready to be used.
  101805. * @param defines the list of "defines" to update.
  101806. * @param scene defines the scene the material belongs to.
  101807. * @returns - boolean indicating that the submesh is ready or not.
  101808. */
  101809. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  101810. /**
  101811. * Checks to see if a texture is used in the material.
  101812. * @param defines the list of "defines" to update.
  101813. * @param scene defines the scene the material belongs to.
  101814. */
  101815. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  101816. /**
  101817. * Binds the material data.
  101818. * @param uniformBuffer defines the Uniform buffer to fill in.
  101819. * @param scene defines the scene the material belongs to.
  101820. * @param isFrozen defines wether the material is frozen or not.
  101821. */
  101822. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  101823. /**
  101824. * Checks to see if a texture is used in the material.
  101825. * @param texture - Base texture to use.
  101826. * @returns - Boolean specifying if a texture is used in the material.
  101827. */
  101828. hasTexture(texture: BaseTexture): boolean;
  101829. /**
  101830. * Returns an array of the actively used textures.
  101831. * @param activeTextures Array of BaseTextures
  101832. */
  101833. getActiveTextures(activeTextures: BaseTexture[]): void;
  101834. /**
  101835. * Returns the animatable textures.
  101836. * @param animatables Array of animatable textures.
  101837. */
  101838. getAnimatables(animatables: IAnimatable[]): void;
  101839. /**
  101840. * Disposes the resources of the material.
  101841. * @param forceDisposeTextures - Forces the disposal of all textures.
  101842. */
  101843. dispose(forceDisposeTextures?: boolean): void;
  101844. /**
  101845. * Get the current class name of the texture useful for serialization or dynamic coding.
  101846. * @returns "PBRSheenConfiguration"
  101847. */
  101848. getClassName(): string;
  101849. /**
  101850. * Add fallbacks to the effect fallbacks list.
  101851. * @param defines defines the Base texture to use.
  101852. * @param fallbacks defines the current fallback list.
  101853. * @param currentRank defines the current fallback rank.
  101854. * @returns the new fallback rank.
  101855. */
  101856. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101857. /**
  101858. * Add the required uniforms to the current list.
  101859. * @param uniforms defines the current uniform list.
  101860. */
  101861. static AddUniforms(uniforms: string[]): void;
  101862. /**
  101863. * Add the required uniforms to the current buffer.
  101864. * @param uniformBuffer defines the current uniform buffer.
  101865. */
  101866. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101867. /**
  101868. * Add the required samplers to the current list.
  101869. * @param samplers defines the current sampler list.
  101870. */
  101871. static AddSamplers(samplers: string[]): void;
  101872. /**
  101873. * Makes a duplicate of the current configuration into another one.
  101874. * @param sheenConfiguration define the config where to copy the info
  101875. */
  101876. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  101877. /**
  101878. * Serializes this BRDF configuration.
  101879. * @returns - An object with the serialized config.
  101880. */
  101881. serialize(): any;
  101882. /**
  101883. * Parses a Sheen Configuration from a serialized object.
  101884. * @param source - Serialized object.
  101885. */
  101886. parse(source: any): void;
  101887. }
  101888. }
  101889. declare module BABYLON {
  101890. /** @hidden */
  101891. export var pbrFragmentDeclaration: {
  101892. name: string;
  101893. shader: string;
  101894. };
  101895. }
  101896. declare module BABYLON {
  101897. /** @hidden */
  101898. export var pbrUboDeclaration: {
  101899. name: string;
  101900. shader: string;
  101901. };
  101902. }
  101903. declare module BABYLON {
  101904. /** @hidden */
  101905. export var pbrFunctions: {
  101906. name: string;
  101907. shader: string;
  101908. };
  101909. }
  101910. declare module BABYLON {
  101911. /** @hidden */
  101912. export var harmonicsFunctions: {
  101913. name: string;
  101914. shader: string;
  101915. };
  101916. }
  101917. declare module BABYLON {
  101918. /** @hidden */
  101919. export var pbrPreLightingFunctions: {
  101920. name: string;
  101921. shader: string;
  101922. };
  101923. }
  101924. declare module BABYLON {
  101925. /** @hidden */
  101926. export var pbrFalloffLightingFunctions: {
  101927. name: string;
  101928. shader: string;
  101929. };
  101930. }
  101931. declare module BABYLON {
  101932. /** @hidden */
  101933. export var pbrLightingFunctions: {
  101934. name: string;
  101935. shader: string;
  101936. };
  101937. }
  101938. declare module BABYLON {
  101939. /** @hidden */
  101940. export var pbrDebug: {
  101941. name: string;
  101942. shader: string;
  101943. };
  101944. }
  101945. declare module BABYLON {
  101946. /** @hidden */
  101947. export var pbrPixelShader: {
  101948. name: string;
  101949. shader: string;
  101950. };
  101951. }
  101952. declare module BABYLON {
  101953. /** @hidden */
  101954. export var pbrVertexDeclaration: {
  101955. name: string;
  101956. shader: string;
  101957. };
  101958. }
  101959. declare module BABYLON {
  101960. /** @hidden */
  101961. export var pbrVertexShader: {
  101962. name: string;
  101963. shader: string;
  101964. };
  101965. }
  101966. declare module BABYLON {
  101967. /**
  101968. * The Physically based material base class of BJS.
  101969. *
  101970. * This offers the main features of a standard PBR material.
  101971. * For more information, please refer to the documentation :
  101972. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  101973. */
  101974. export abstract class PBRBaseMaterial extends PushMaterial {
  101975. /**
  101976. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  101977. */
  101978. static readonly PBRMATERIAL_OPAQUE: number;
  101979. /**
  101980. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  101981. */
  101982. static readonly PBRMATERIAL_ALPHATEST: number;
  101983. /**
  101984. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101985. */
  101986. static readonly PBRMATERIAL_ALPHABLEND: number;
  101987. /**
  101988. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  101989. * They are also discarded below the alpha cutoff threshold to improve performances.
  101990. */
  101991. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  101992. /**
  101993. * Defines the default value of how much AO map is occluding the analytical lights
  101994. * (point spot...).
  101995. */
  101996. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  101997. /**
  101998. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  101999. */
  102000. static readonly LIGHTFALLOFF_PHYSICAL: number;
  102001. /**
  102002. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  102003. * to enhance interoperability with other engines.
  102004. */
  102005. static readonly LIGHTFALLOFF_GLTF: number;
  102006. /**
  102007. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  102008. * to enhance interoperability with other materials.
  102009. */
  102010. static readonly LIGHTFALLOFF_STANDARD: number;
  102011. /**
  102012. * Intensity of the direct lights e.g. the four lights available in your scene.
  102013. * This impacts both the direct diffuse and specular highlights.
  102014. */
  102015. protected _directIntensity: number;
  102016. /**
  102017. * Intensity of the emissive part of the material.
  102018. * This helps controlling the emissive effect without modifying the emissive color.
  102019. */
  102020. protected _emissiveIntensity: number;
  102021. /**
  102022. * Intensity of the environment e.g. how much the environment will light the object
  102023. * either through harmonics for rough material or through the refelction for shiny ones.
  102024. */
  102025. protected _environmentIntensity: number;
  102026. /**
  102027. * This is a special control allowing the reduction of the specular highlights coming from the
  102028. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  102029. */
  102030. protected _specularIntensity: number;
  102031. /**
  102032. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  102033. */
  102034. private _lightingInfos;
  102035. /**
  102036. * Debug Control allowing disabling the bump map on this material.
  102037. */
  102038. protected _disableBumpMap: boolean;
  102039. /**
  102040. * AKA Diffuse Texture in standard nomenclature.
  102041. */
  102042. protected _albedoTexture: BaseTexture;
  102043. /**
  102044. * AKA Occlusion Texture in other nomenclature.
  102045. */
  102046. protected _ambientTexture: BaseTexture;
  102047. /**
  102048. * AKA Occlusion Texture Intensity in other nomenclature.
  102049. */
  102050. protected _ambientTextureStrength: number;
  102051. /**
  102052. * Defines how much the AO map is occluding the analytical lights (point spot...).
  102053. * 1 means it completely occludes it
  102054. * 0 mean it has no impact
  102055. */
  102056. protected _ambientTextureImpactOnAnalyticalLights: number;
  102057. /**
  102058. * Stores the alpha values in a texture.
  102059. */
  102060. protected _opacityTexture: BaseTexture;
  102061. /**
  102062. * Stores the reflection values in a texture.
  102063. */
  102064. protected _reflectionTexture: BaseTexture;
  102065. /**
  102066. * Stores the refraction values in a texture.
  102067. */
  102068. protected _refractionTexture: BaseTexture;
  102069. /**
  102070. * Stores the emissive values in a texture.
  102071. */
  102072. protected _emissiveTexture: BaseTexture;
  102073. /**
  102074. * AKA Specular texture in other nomenclature.
  102075. */
  102076. protected _reflectivityTexture: BaseTexture;
  102077. /**
  102078. * Used to switch from specular/glossiness to metallic/roughness workflow.
  102079. */
  102080. protected _metallicTexture: BaseTexture;
  102081. /**
  102082. * Specifies the metallic scalar of the metallic/roughness workflow.
  102083. * Can also be used to scale the metalness values of the metallic texture.
  102084. */
  102085. protected _metallic: Nullable<number>;
  102086. /**
  102087. * Specifies the roughness scalar of the metallic/roughness workflow.
  102088. * Can also be used to scale the roughness values of the metallic texture.
  102089. */
  102090. protected _roughness: Nullable<number>;
  102091. /**
  102092. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  102093. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  102094. */
  102095. protected _microSurfaceTexture: BaseTexture;
  102096. /**
  102097. * Stores surface normal data used to displace a mesh in a texture.
  102098. */
  102099. protected _bumpTexture: BaseTexture;
  102100. /**
  102101. * Stores the pre-calculated light information of a mesh in a texture.
  102102. */
  102103. protected _lightmapTexture: BaseTexture;
  102104. /**
  102105. * The color of a material in ambient lighting.
  102106. */
  102107. protected _ambientColor: Color3;
  102108. /**
  102109. * AKA Diffuse Color in other nomenclature.
  102110. */
  102111. protected _albedoColor: Color3;
  102112. /**
  102113. * AKA Specular Color in other nomenclature.
  102114. */
  102115. protected _reflectivityColor: Color3;
  102116. /**
  102117. * The color applied when light is reflected from a material.
  102118. */
  102119. protected _reflectionColor: Color3;
  102120. /**
  102121. * The color applied when light is emitted from a material.
  102122. */
  102123. protected _emissiveColor: Color3;
  102124. /**
  102125. * AKA Glossiness in other nomenclature.
  102126. */
  102127. protected _microSurface: number;
  102128. /**
  102129. * source material index of refraction (IOR)' / 'destination material IOR.
  102130. */
  102131. protected _indexOfRefraction: number;
  102132. /**
  102133. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  102134. */
  102135. protected _invertRefractionY: boolean;
  102136. /**
  102137. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  102138. * Materials half opaque for instance using refraction could benefit from this control.
  102139. */
  102140. protected _linkRefractionWithTransparency: boolean;
  102141. /**
  102142. * Specifies that the material will use the light map as a show map.
  102143. */
  102144. protected _useLightmapAsShadowmap: boolean;
  102145. /**
  102146. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  102147. * makes the reflect vector face the model (under horizon).
  102148. */
  102149. protected _useHorizonOcclusion: boolean;
  102150. /**
  102151. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  102152. * too much the area relying on ambient texture to define their ambient occlusion.
  102153. */
  102154. protected _useRadianceOcclusion: boolean;
  102155. /**
  102156. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  102157. */
  102158. protected _useAlphaFromAlbedoTexture: boolean;
  102159. /**
  102160. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  102161. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102162. */
  102163. protected _useSpecularOverAlpha: boolean;
  102164. /**
  102165. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  102166. */
  102167. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  102168. /**
  102169. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  102170. */
  102171. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  102172. /**
  102173. * Specifies if the metallic texture contains the roughness information in its green channel.
  102174. */
  102175. protected _useRoughnessFromMetallicTextureGreen: boolean;
  102176. /**
  102177. * Specifies if the metallic texture contains the metallness information in its blue channel.
  102178. */
  102179. protected _useMetallnessFromMetallicTextureBlue: boolean;
  102180. /**
  102181. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  102182. */
  102183. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  102184. /**
  102185. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  102186. */
  102187. protected _useAmbientInGrayScale: boolean;
  102188. /**
  102189. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  102190. * The material will try to infer what glossiness each pixel should be.
  102191. */
  102192. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  102193. /**
  102194. * Defines the falloff type used in this material.
  102195. * It by default is Physical.
  102196. */
  102197. protected _lightFalloff: number;
  102198. /**
  102199. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102200. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102201. */
  102202. protected _useRadianceOverAlpha: boolean;
  102203. /**
  102204. * Allows using an object space normal map (instead of tangent space).
  102205. */
  102206. protected _useObjectSpaceNormalMap: boolean;
  102207. /**
  102208. * Allows using the bump map in parallax mode.
  102209. */
  102210. protected _useParallax: boolean;
  102211. /**
  102212. * Allows using the bump map in parallax occlusion mode.
  102213. */
  102214. protected _useParallaxOcclusion: boolean;
  102215. /**
  102216. * Controls the scale bias of the parallax mode.
  102217. */
  102218. protected _parallaxScaleBias: number;
  102219. /**
  102220. * If sets to true, disables all the lights affecting the material.
  102221. */
  102222. protected _disableLighting: boolean;
  102223. /**
  102224. * Number of Simultaneous lights allowed on the material.
  102225. */
  102226. protected _maxSimultaneousLights: number;
  102227. /**
  102228. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  102229. */
  102230. protected _invertNormalMapX: boolean;
  102231. /**
  102232. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  102233. */
  102234. protected _invertNormalMapY: boolean;
  102235. /**
  102236. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102237. */
  102238. protected _twoSidedLighting: boolean;
  102239. /**
  102240. * Defines the alpha limits in alpha test mode.
  102241. */
  102242. protected _alphaCutOff: number;
  102243. /**
  102244. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  102245. */
  102246. protected _forceAlphaTest: boolean;
  102247. /**
  102248. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102249. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  102250. */
  102251. protected _useAlphaFresnel: boolean;
  102252. /**
  102253. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102254. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  102255. */
  102256. protected _useLinearAlphaFresnel: boolean;
  102257. /**
  102258. * The transparency mode of the material.
  102259. */
  102260. protected _transparencyMode: Nullable<number>;
  102261. /**
  102262. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  102263. * from cos thetav and roughness:
  102264. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  102265. */
  102266. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  102267. /**
  102268. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  102269. */
  102270. protected _forceIrradianceInFragment: boolean;
  102271. /**
  102272. * Force normal to face away from face.
  102273. */
  102274. protected _forceNormalForward: boolean;
  102275. /**
  102276. * Enables specular anti aliasing in the PBR shader.
  102277. * It will both interacts on the Geometry for analytical and IBL lighting.
  102278. * It also prefilter the roughness map based on the bump values.
  102279. */
  102280. protected _enableSpecularAntiAliasing: boolean;
  102281. /**
  102282. * Default configuration related to image processing available in the PBR Material.
  102283. */
  102284. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102285. /**
  102286. * Keep track of the image processing observer to allow dispose and replace.
  102287. */
  102288. private _imageProcessingObserver;
  102289. /**
  102290. * Attaches a new image processing configuration to the PBR Material.
  102291. * @param configuration
  102292. */
  102293. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102294. /**
  102295. * Stores the available render targets.
  102296. */
  102297. private _renderTargets;
  102298. /**
  102299. * Sets the global ambient color for the material used in lighting calculations.
  102300. */
  102301. private _globalAmbientColor;
  102302. /**
  102303. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  102304. */
  102305. private _useLogarithmicDepth;
  102306. /**
  102307. * If set to true, no lighting calculations will be applied.
  102308. */
  102309. private _unlit;
  102310. private _debugMode;
  102311. /**
  102312. * @hidden
  102313. * This is reserved for the inspector.
  102314. * Defines the material debug mode.
  102315. * It helps seeing only some components of the material while troubleshooting.
  102316. */
  102317. debugMode: number;
  102318. /**
  102319. * @hidden
  102320. * This is reserved for the inspector.
  102321. * Specify from where on screen the debug mode should start.
  102322. * The value goes from -1 (full screen) to 1 (not visible)
  102323. * It helps with side by side comparison against the final render
  102324. * This defaults to -1
  102325. */
  102326. private debugLimit;
  102327. /**
  102328. * @hidden
  102329. * This is reserved for the inspector.
  102330. * As the default viewing range might not be enough (if the ambient is really small for instance)
  102331. * You can use the factor to better multiply the final value.
  102332. */
  102333. private debugFactor;
  102334. /**
  102335. * Defines the clear coat layer parameters for the material.
  102336. */
  102337. readonly clearCoat: PBRClearCoatConfiguration;
  102338. /**
  102339. * Defines the anisotropic parameters for the material.
  102340. */
  102341. readonly anisotropy: PBRAnisotropicConfiguration;
  102342. /**
  102343. * Defines the BRDF parameters for the material.
  102344. */
  102345. readonly brdf: PBRBRDFConfiguration;
  102346. /**
  102347. * Defines the Sheen parameters for the material.
  102348. */
  102349. readonly sheen: PBRSheenConfiguration;
  102350. /**
  102351. * Instantiates a new PBRMaterial instance.
  102352. *
  102353. * @param name The material name
  102354. * @param scene The scene the material will be use in.
  102355. */
  102356. constructor(name: string, scene: Scene);
  102357. /**
  102358. * Gets a boolean indicating that current material needs to register RTT
  102359. */
  102360. readonly hasRenderTargetTextures: boolean;
  102361. /**
  102362. * Gets the name of the material class.
  102363. */
  102364. getClassName(): string;
  102365. /**
  102366. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  102367. */
  102368. /**
  102369. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  102370. */
  102371. useLogarithmicDepth: boolean;
  102372. /**
  102373. * Gets the current transparency mode.
  102374. */
  102375. /**
  102376. * Sets the transparency mode of the material.
  102377. *
  102378. * | Value | Type | Description |
  102379. * | ----- | ----------------------------------- | ----------- |
  102380. * | 0 | OPAQUE | |
  102381. * | 1 | ALPHATEST | |
  102382. * | 2 | ALPHABLEND | |
  102383. * | 3 | ALPHATESTANDBLEND | |
  102384. *
  102385. */
  102386. transparencyMode: Nullable<number>;
  102387. /**
  102388. * Returns true if alpha blending should be disabled.
  102389. */
  102390. private readonly _disableAlphaBlending;
  102391. /**
  102392. * Specifies whether or not this material should be rendered in alpha blend mode.
  102393. */
  102394. needAlphaBlending(): boolean;
  102395. /**
  102396. * Specifies if the mesh will require alpha blending.
  102397. * @param mesh - BJS mesh.
  102398. */
  102399. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  102400. /**
  102401. * Specifies whether or not this material should be rendered in alpha test mode.
  102402. */
  102403. needAlphaTesting(): boolean;
  102404. /**
  102405. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  102406. */
  102407. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  102408. /**
  102409. * Gets the texture used for the alpha test.
  102410. */
  102411. getAlphaTestTexture(): BaseTexture;
  102412. /**
  102413. * Specifies that the submesh is ready to be used.
  102414. * @param mesh - BJS mesh.
  102415. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  102416. * @param useInstances - Specifies that instances should be used.
  102417. * @returns - boolean indicating that the submesh is ready or not.
  102418. */
  102419. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102420. /**
  102421. * Specifies if the material uses metallic roughness workflow.
  102422. * @returns boolean specifiying if the material uses metallic roughness workflow.
  102423. */
  102424. isMetallicWorkflow(): boolean;
  102425. private _prepareEffect;
  102426. private _prepareDefines;
  102427. /**
  102428. * Force shader compilation
  102429. */
  102430. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  102431. clipPlane: boolean;
  102432. }>): void;
  102433. /**
  102434. * Initializes the uniform buffer layout for the shader.
  102435. */
  102436. buildUniformLayout(): void;
  102437. /**
  102438. * Unbinds the textures.
  102439. */
  102440. unbind(): void;
  102441. /**
  102442. * Binds the submesh data.
  102443. * @param world - The world matrix.
  102444. * @param mesh - The BJS mesh.
  102445. * @param subMesh - A submesh of the BJS mesh.
  102446. */
  102447. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102448. /**
  102449. * Returns the animatable textures.
  102450. * @returns - Array of animatable textures.
  102451. */
  102452. getAnimatables(): IAnimatable[];
  102453. /**
  102454. * Returns the texture used for reflections.
  102455. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  102456. */
  102457. private _getReflectionTexture;
  102458. /**
  102459. * Returns the texture used for refraction or null if none is used.
  102460. * @returns - Refection texture if present. If no refraction texture and refraction
  102461. * is linked with transparency, returns environment texture. Otherwise, returns null.
  102462. */
  102463. private _getRefractionTexture;
  102464. /**
  102465. * Returns an array of the actively used textures.
  102466. * @returns - Array of BaseTextures
  102467. */
  102468. getActiveTextures(): BaseTexture[];
  102469. /**
  102470. * Checks to see if a texture is used in the material.
  102471. * @param texture - Base texture to use.
  102472. * @returns - Boolean specifying if a texture is used in the material.
  102473. */
  102474. hasTexture(texture: BaseTexture): boolean;
  102475. /**
  102476. * Disposes the resources of the material.
  102477. * @param forceDisposeEffect - Forces the disposal of effects.
  102478. * @param forceDisposeTextures - Forces the disposal of all textures.
  102479. */
  102480. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102481. }
  102482. }
  102483. declare module BABYLON {
  102484. /**
  102485. * The Physically based material of BJS.
  102486. *
  102487. * This offers the main features of a standard PBR material.
  102488. * For more information, please refer to the documentation :
  102489. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  102490. */
  102491. export class PBRMaterial extends PBRBaseMaterial {
  102492. /**
  102493. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  102494. */
  102495. static readonly PBRMATERIAL_OPAQUE: number;
  102496. /**
  102497. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  102498. */
  102499. static readonly PBRMATERIAL_ALPHATEST: number;
  102500. /**
  102501. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102502. */
  102503. static readonly PBRMATERIAL_ALPHABLEND: number;
  102504. /**
  102505. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102506. * They are also discarded below the alpha cutoff threshold to improve performances.
  102507. */
  102508. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  102509. /**
  102510. * Defines the default value of how much AO map is occluding the analytical lights
  102511. * (point spot...).
  102512. */
  102513. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  102514. /**
  102515. * Intensity of the direct lights e.g. the four lights available in your scene.
  102516. * This impacts both the direct diffuse and specular highlights.
  102517. */
  102518. directIntensity: number;
  102519. /**
  102520. * Intensity of the emissive part of the material.
  102521. * This helps controlling the emissive effect without modifying the emissive color.
  102522. */
  102523. emissiveIntensity: number;
  102524. /**
  102525. * Intensity of the environment e.g. how much the environment will light the object
  102526. * either through harmonics for rough material or through the refelction for shiny ones.
  102527. */
  102528. environmentIntensity: number;
  102529. /**
  102530. * This is a special control allowing the reduction of the specular highlights coming from the
  102531. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  102532. */
  102533. specularIntensity: number;
  102534. /**
  102535. * Debug Control allowing disabling the bump map on this material.
  102536. */
  102537. disableBumpMap: boolean;
  102538. /**
  102539. * AKA Diffuse Texture in standard nomenclature.
  102540. */
  102541. albedoTexture: BaseTexture;
  102542. /**
  102543. * AKA Occlusion Texture in other nomenclature.
  102544. */
  102545. ambientTexture: BaseTexture;
  102546. /**
  102547. * AKA Occlusion Texture Intensity in other nomenclature.
  102548. */
  102549. ambientTextureStrength: number;
  102550. /**
  102551. * Defines how much the AO map is occluding the analytical lights (point spot...).
  102552. * 1 means it completely occludes it
  102553. * 0 mean it has no impact
  102554. */
  102555. ambientTextureImpactOnAnalyticalLights: number;
  102556. /**
  102557. * Stores the alpha values in a texture.
  102558. */
  102559. opacityTexture: BaseTexture;
  102560. /**
  102561. * Stores the reflection values in a texture.
  102562. */
  102563. reflectionTexture: Nullable<BaseTexture>;
  102564. /**
  102565. * Stores the emissive values in a texture.
  102566. */
  102567. emissiveTexture: BaseTexture;
  102568. /**
  102569. * AKA Specular texture in other nomenclature.
  102570. */
  102571. reflectivityTexture: BaseTexture;
  102572. /**
  102573. * Used to switch from specular/glossiness to metallic/roughness workflow.
  102574. */
  102575. metallicTexture: BaseTexture;
  102576. /**
  102577. * Specifies the metallic scalar of the metallic/roughness workflow.
  102578. * Can also be used to scale the metalness values of the metallic texture.
  102579. */
  102580. metallic: Nullable<number>;
  102581. /**
  102582. * Specifies the roughness scalar of the metallic/roughness workflow.
  102583. * Can also be used to scale the roughness values of the metallic texture.
  102584. */
  102585. roughness: Nullable<number>;
  102586. /**
  102587. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  102588. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  102589. */
  102590. microSurfaceTexture: BaseTexture;
  102591. /**
  102592. * Stores surface normal data used to displace a mesh in a texture.
  102593. */
  102594. bumpTexture: BaseTexture;
  102595. /**
  102596. * Stores the pre-calculated light information of a mesh in a texture.
  102597. */
  102598. lightmapTexture: BaseTexture;
  102599. /**
  102600. * Stores the refracted light information in a texture.
  102601. */
  102602. refractionTexture: BaseTexture;
  102603. /**
  102604. * The color of a material in ambient lighting.
  102605. */
  102606. ambientColor: Color3;
  102607. /**
  102608. * AKA Diffuse Color in other nomenclature.
  102609. */
  102610. albedoColor: Color3;
  102611. /**
  102612. * AKA Specular Color in other nomenclature.
  102613. */
  102614. reflectivityColor: Color3;
  102615. /**
  102616. * The color reflected from the material.
  102617. */
  102618. reflectionColor: Color3;
  102619. /**
  102620. * The color emitted from the material.
  102621. */
  102622. emissiveColor: Color3;
  102623. /**
  102624. * AKA Glossiness in other nomenclature.
  102625. */
  102626. microSurface: number;
  102627. /**
  102628. * source material index of refraction (IOR)' / 'destination material IOR.
  102629. */
  102630. indexOfRefraction: number;
  102631. /**
  102632. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  102633. */
  102634. invertRefractionY: boolean;
  102635. /**
  102636. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  102637. * Materials half opaque for instance using refraction could benefit from this control.
  102638. */
  102639. linkRefractionWithTransparency: boolean;
  102640. /**
  102641. * If true, the light map contains occlusion information instead of lighting info.
  102642. */
  102643. useLightmapAsShadowmap: boolean;
  102644. /**
  102645. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  102646. */
  102647. useAlphaFromAlbedoTexture: boolean;
  102648. /**
  102649. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  102650. */
  102651. forceAlphaTest: boolean;
  102652. /**
  102653. * Defines the alpha limits in alpha test mode.
  102654. */
  102655. alphaCutOff: number;
  102656. /**
  102657. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  102658. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102659. */
  102660. useSpecularOverAlpha: boolean;
  102661. /**
  102662. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  102663. */
  102664. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  102665. /**
  102666. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  102667. */
  102668. useRoughnessFromMetallicTextureAlpha: boolean;
  102669. /**
  102670. * Specifies if the metallic texture contains the roughness information in its green channel.
  102671. */
  102672. useRoughnessFromMetallicTextureGreen: boolean;
  102673. /**
  102674. * Specifies if the metallic texture contains the metallness information in its blue channel.
  102675. */
  102676. useMetallnessFromMetallicTextureBlue: boolean;
  102677. /**
  102678. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  102679. */
  102680. useAmbientOcclusionFromMetallicTextureRed: boolean;
  102681. /**
  102682. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  102683. */
  102684. useAmbientInGrayScale: boolean;
  102685. /**
  102686. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  102687. * The material will try to infer what glossiness each pixel should be.
  102688. */
  102689. useAutoMicroSurfaceFromReflectivityMap: boolean;
  102690. /**
  102691. * BJS is using an harcoded light falloff based on a manually sets up range.
  102692. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  102693. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  102694. */
  102695. /**
  102696. * BJS is using an harcoded light falloff based on a manually sets up range.
  102697. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  102698. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  102699. */
  102700. usePhysicalLightFalloff: boolean;
  102701. /**
  102702. * In order to support the falloff compatibility with gltf, a special mode has been added
  102703. * to reproduce the gltf light falloff.
  102704. */
  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. useGLTFLightFalloff: boolean;
  102710. /**
  102711. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102712. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102713. */
  102714. useRadianceOverAlpha: boolean;
  102715. /**
  102716. * Allows using an object space normal map (instead of tangent space).
  102717. */
  102718. useObjectSpaceNormalMap: boolean;
  102719. /**
  102720. * Allows using the bump map in parallax mode.
  102721. */
  102722. useParallax: boolean;
  102723. /**
  102724. * Allows using the bump map in parallax occlusion mode.
  102725. */
  102726. useParallaxOcclusion: boolean;
  102727. /**
  102728. * Controls the scale bias of the parallax mode.
  102729. */
  102730. parallaxScaleBias: number;
  102731. /**
  102732. * If sets to true, disables all the lights affecting the material.
  102733. */
  102734. disableLighting: boolean;
  102735. /**
  102736. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  102737. */
  102738. forceIrradianceInFragment: boolean;
  102739. /**
  102740. * Number of Simultaneous lights allowed on the material.
  102741. */
  102742. maxSimultaneousLights: number;
  102743. /**
  102744. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  102745. */
  102746. invertNormalMapX: boolean;
  102747. /**
  102748. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  102749. */
  102750. invertNormalMapY: boolean;
  102751. /**
  102752. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102753. */
  102754. twoSidedLighting: boolean;
  102755. /**
  102756. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102757. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  102758. */
  102759. useAlphaFresnel: boolean;
  102760. /**
  102761. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102762. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  102763. */
  102764. useLinearAlphaFresnel: boolean;
  102765. /**
  102766. * Let user defines the brdf lookup texture used for IBL.
  102767. * A default 8bit version is embedded but you could point at :
  102768. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  102769. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  102770. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  102771. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  102772. */
  102773. environmentBRDFTexture: Nullable<BaseTexture>;
  102774. /**
  102775. * Force normal to face away from face.
  102776. */
  102777. forceNormalForward: boolean;
  102778. /**
  102779. * Enables specular anti aliasing in the PBR shader.
  102780. * It will both interacts on the Geometry for analytical and IBL lighting.
  102781. * It also prefilter the roughness map based on the bump values.
  102782. */
  102783. enableSpecularAntiAliasing: boolean;
  102784. /**
  102785. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  102786. * makes the reflect vector face the model (under horizon).
  102787. */
  102788. useHorizonOcclusion: boolean;
  102789. /**
  102790. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  102791. * too much the area relying on ambient texture to define their ambient occlusion.
  102792. */
  102793. useRadianceOcclusion: boolean;
  102794. /**
  102795. * If set to true, no lighting calculations will be applied.
  102796. */
  102797. unlit: boolean;
  102798. /**
  102799. * Gets the image processing configuration used either in this material.
  102800. */
  102801. /**
  102802. * Sets the Default image processing configuration used either in the this material.
  102803. *
  102804. * If sets to null, the scene one is in use.
  102805. */
  102806. imageProcessingConfiguration: ImageProcessingConfiguration;
  102807. /**
  102808. * Gets wether the color curves effect is enabled.
  102809. */
  102810. /**
  102811. * Sets wether the color curves effect is enabled.
  102812. */
  102813. cameraColorCurvesEnabled: boolean;
  102814. /**
  102815. * Gets wether the color grading effect is enabled.
  102816. */
  102817. /**
  102818. * Gets wether the color grading effect is enabled.
  102819. */
  102820. cameraColorGradingEnabled: boolean;
  102821. /**
  102822. * Gets wether tonemapping is enabled or not.
  102823. */
  102824. /**
  102825. * Sets wether tonemapping is enabled or not
  102826. */
  102827. cameraToneMappingEnabled: boolean;
  102828. /**
  102829. * The camera exposure used on this material.
  102830. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102831. * This corresponds to a photographic exposure.
  102832. */
  102833. /**
  102834. * The camera exposure used on this material.
  102835. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102836. * This corresponds to a photographic exposure.
  102837. */
  102838. cameraExposure: number;
  102839. /**
  102840. * Gets The camera contrast used on this material.
  102841. */
  102842. /**
  102843. * Sets The camera contrast used on this material.
  102844. */
  102845. cameraContrast: number;
  102846. /**
  102847. * Gets the Color Grading 2D Lookup Texture.
  102848. */
  102849. /**
  102850. * Sets the Color Grading 2D Lookup Texture.
  102851. */
  102852. cameraColorGradingTexture: Nullable<BaseTexture>;
  102853. /**
  102854. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102855. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102856. * 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;
  102857. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102858. */
  102859. /**
  102860. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102861. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102862. * 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;
  102863. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102864. */
  102865. cameraColorCurves: Nullable<ColorCurves>;
  102866. /**
  102867. * Instantiates a new PBRMaterial instance.
  102868. *
  102869. * @param name The material name
  102870. * @param scene The scene the material will be use in.
  102871. */
  102872. constructor(name: string, scene: Scene);
  102873. /**
  102874. * Returns the name of this material class.
  102875. */
  102876. getClassName(): string;
  102877. /**
  102878. * Makes a duplicate of the current material.
  102879. * @param name - name to use for the new material.
  102880. */
  102881. clone(name: string): PBRMaterial;
  102882. /**
  102883. * Serializes this PBR Material.
  102884. * @returns - An object with the serialized material.
  102885. */
  102886. serialize(): any;
  102887. /**
  102888. * Parses a PBR Material from a serialized object.
  102889. * @param source - Serialized object.
  102890. * @param scene - BJS scene instance.
  102891. * @param rootUrl - url for the scene object
  102892. * @returns - PBRMaterial
  102893. */
  102894. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  102895. }
  102896. }
  102897. declare module BABYLON {
  102898. /**
  102899. * Direct draw surface info
  102900. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  102901. */
  102902. export interface DDSInfo {
  102903. /**
  102904. * Width of the texture
  102905. */
  102906. width: number;
  102907. /**
  102908. * Width of the texture
  102909. */
  102910. height: number;
  102911. /**
  102912. * Number of Mipmaps for the texture
  102913. * @see https://en.wikipedia.org/wiki/Mipmap
  102914. */
  102915. mipmapCount: number;
  102916. /**
  102917. * If the textures format is a known fourCC format
  102918. * @see https://www.fourcc.org/
  102919. */
  102920. isFourCC: boolean;
  102921. /**
  102922. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  102923. */
  102924. isRGB: boolean;
  102925. /**
  102926. * If the texture is a lumincance format
  102927. */
  102928. isLuminance: boolean;
  102929. /**
  102930. * If this is a cube texture
  102931. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  102932. */
  102933. isCube: boolean;
  102934. /**
  102935. * If the texture is a compressed format eg. FOURCC_DXT1
  102936. */
  102937. isCompressed: boolean;
  102938. /**
  102939. * The dxgiFormat of the texture
  102940. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  102941. */
  102942. dxgiFormat: number;
  102943. /**
  102944. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  102945. */
  102946. textureType: number;
  102947. /**
  102948. * Sphericle polynomial created for the dds texture
  102949. */
  102950. sphericalPolynomial?: SphericalPolynomial;
  102951. }
  102952. /**
  102953. * Class used to provide DDS decompression tools
  102954. */
  102955. export class DDSTools {
  102956. /**
  102957. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  102958. */
  102959. static StoreLODInAlphaChannel: boolean;
  102960. /**
  102961. * Gets DDS information from an array buffer
  102962. * @param arrayBuffer defines the array buffer to read data from
  102963. * @returns the DDS information
  102964. */
  102965. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  102966. private static _FloatView;
  102967. private static _Int32View;
  102968. private static _ToHalfFloat;
  102969. private static _FromHalfFloat;
  102970. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  102971. private static _GetHalfFloatRGBAArrayBuffer;
  102972. private static _GetFloatRGBAArrayBuffer;
  102973. private static _GetFloatAsUIntRGBAArrayBuffer;
  102974. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  102975. private static _GetRGBAArrayBuffer;
  102976. private static _ExtractLongWordOrder;
  102977. private static _GetRGBArrayBuffer;
  102978. private static _GetLuminanceArrayBuffer;
  102979. /**
  102980. * Uploads DDS Levels to a Babylon Texture
  102981. * @hidden
  102982. */
  102983. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  102984. }
  102985. interface Engine {
  102986. /**
  102987. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  102988. * @param rootUrl defines the url where the file to load is located
  102989. * @param scene defines the current scene
  102990. * @param lodScale defines scale to apply to the mip map selection
  102991. * @param lodOffset defines offset to apply to the mip map selection
  102992. * @param onLoad defines an optional callback raised when the texture is loaded
  102993. * @param onError defines an optional callback raised if there is an issue to load the texture
  102994. * @param format defines the format of the data
  102995. * @param forcedExtension defines the extension to use to pick the right loader
  102996. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  102997. * @returns the cube texture as an InternalTexture
  102998. */
  102999. 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;
  103000. }
  103001. }
  103002. declare module BABYLON {
  103003. /**
  103004. * Implementation of the DDS Texture Loader.
  103005. * @hidden
  103006. */
  103007. export class _DDSTextureLoader implements IInternalTextureLoader {
  103008. /**
  103009. * Defines wether the loader supports cascade loading the different faces.
  103010. */
  103011. readonly supportCascades: boolean;
  103012. /**
  103013. * This returns if the loader support the current file information.
  103014. * @param extension defines the file extension of the file being loaded
  103015. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103016. * @param fallback defines the fallback internal texture if any
  103017. * @param isBase64 defines whether the texture is encoded as a base64
  103018. * @param isBuffer defines whether the texture data are stored as a buffer
  103019. * @returns true if the loader can load the specified file
  103020. */
  103021. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103022. /**
  103023. * Transform the url before loading if required.
  103024. * @param rootUrl the url of the texture
  103025. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103026. * @returns the transformed texture
  103027. */
  103028. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103029. /**
  103030. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103031. * @param rootUrl the url of the texture
  103032. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103033. * @returns the fallback texture
  103034. */
  103035. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103036. /**
  103037. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103038. * @param data contains the texture data
  103039. * @param texture defines the BabylonJS internal texture
  103040. * @param createPolynomials will be true if polynomials have been requested
  103041. * @param onLoad defines the callback to trigger once the texture is ready
  103042. * @param onError defines the callback to trigger in case of error
  103043. */
  103044. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103045. /**
  103046. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103047. * @param data contains the texture data
  103048. * @param texture defines the BabylonJS internal texture
  103049. * @param callback defines the method to call once ready to upload
  103050. */
  103051. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  103052. }
  103053. }
  103054. declare module BABYLON {
  103055. /** @hidden */
  103056. export var rgbdEncodePixelShader: {
  103057. name: string;
  103058. shader: string;
  103059. };
  103060. }
  103061. declare module BABYLON {
  103062. /** @hidden */
  103063. export var rgbdDecodePixelShader: {
  103064. name: string;
  103065. shader: string;
  103066. };
  103067. }
  103068. declare module BABYLON {
  103069. /**
  103070. * Raw texture data and descriptor sufficient for WebGL texture upload
  103071. */
  103072. export interface EnvironmentTextureInfo {
  103073. /**
  103074. * Version of the environment map
  103075. */
  103076. version: number;
  103077. /**
  103078. * Width of image
  103079. */
  103080. width: number;
  103081. /**
  103082. * Irradiance information stored in the file.
  103083. */
  103084. irradiance: any;
  103085. /**
  103086. * Specular information stored in the file.
  103087. */
  103088. specular: any;
  103089. }
  103090. /**
  103091. * Sets of helpers addressing the serialization and deserialization of environment texture
  103092. * stored in a BabylonJS env file.
  103093. * Those files are usually stored as .env files.
  103094. */
  103095. export class EnvironmentTextureTools {
  103096. /**
  103097. * Magic number identifying the env file.
  103098. */
  103099. private static _MagicBytes;
  103100. /**
  103101. * Gets the environment info from an env file.
  103102. * @param data The array buffer containing the .env bytes.
  103103. * @returns the environment file info (the json header) if successfully parsed.
  103104. */
  103105. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  103106. /**
  103107. * Creates an environment texture from a loaded cube texture.
  103108. * @param texture defines the cube texture to convert in env file
  103109. * @return a promise containing the environment data if succesfull.
  103110. */
  103111. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  103112. /**
  103113. * Creates a JSON representation of the spherical data.
  103114. * @param texture defines the texture containing the polynomials
  103115. * @return the JSON representation of the spherical info
  103116. */
  103117. private static _CreateEnvTextureIrradiance;
  103118. /**
  103119. * Uploads the texture info contained in the env file to the GPU.
  103120. * @param texture defines the internal texture to upload to
  103121. * @param arrayBuffer defines the buffer cotaining the data to load
  103122. * @param info defines the texture info retrieved through the GetEnvInfo method
  103123. * @returns a promise
  103124. */
  103125. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  103126. /**
  103127. * Uploads the levels of image data to the GPU.
  103128. * @param texture defines the internal texture to upload to
  103129. * @param imageData defines the array buffer views of image data [mipmap][face]
  103130. * @returns a promise
  103131. */
  103132. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  103133. /**
  103134. * Uploads spherical polynomials information to the texture.
  103135. * @param texture defines the texture we are trying to upload the information to
  103136. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  103137. */
  103138. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  103139. /** @hidden */
  103140. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  103141. }
  103142. }
  103143. declare module BABYLON {
  103144. /**
  103145. * Implementation of the ENV Texture Loader.
  103146. * @hidden
  103147. */
  103148. export class _ENVTextureLoader implements IInternalTextureLoader {
  103149. /**
  103150. * Defines wether the loader supports cascade loading the different faces.
  103151. */
  103152. readonly supportCascades: boolean;
  103153. /**
  103154. * This returns if the loader support the current file information.
  103155. * @param extension defines the file extension of the file being loaded
  103156. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103157. * @param fallback defines the fallback internal texture if any
  103158. * @param isBase64 defines whether the texture is encoded as a base64
  103159. * @param isBuffer defines whether the texture data are stored as a buffer
  103160. * @returns true if the loader can load the specified file
  103161. */
  103162. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103163. /**
  103164. * Transform the url before loading if required.
  103165. * @param rootUrl the url of the texture
  103166. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103167. * @returns the transformed texture
  103168. */
  103169. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103170. /**
  103171. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103172. * @param rootUrl the url of the texture
  103173. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103174. * @returns the fallback texture
  103175. */
  103176. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103177. /**
  103178. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103179. * @param data contains the texture data
  103180. * @param texture defines the BabylonJS internal texture
  103181. * @param createPolynomials will be true if polynomials have been requested
  103182. * @param onLoad defines the callback to trigger once the texture is ready
  103183. * @param onError defines the callback to trigger in case of error
  103184. */
  103185. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103186. /**
  103187. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103188. * @param data contains the texture data
  103189. * @param texture defines the BabylonJS internal texture
  103190. * @param callback defines the method to call once ready to upload
  103191. */
  103192. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  103193. }
  103194. }
  103195. declare module BABYLON {
  103196. /**
  103197. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  103198. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  103199. */
  103200. export class KhronosTextureContainer {
  103201. /** contents of the KTX container file */
  103202. arrayBuffer: any;
  103203. private static HEADER_LEN;
  103204. private static COMPRESSED_2D;
  103205. private static COMPRESSED_3D;
  103206. private static TEX_2D;
  103207. private static TEX_3D;
  103208. /**
  103209. * Gets the openGL type
  103210. */
  103211. glType: number;
  103212. /**
  103213. * Gets the openGL type size
  103214. */
  103215. glTypeSize: number;
  103216. /**
  103217. * Gets the openGL format
  103218. */
  103219. glFormat: number;
  103220. /**
  103221. * Gets the openGL internal format
  103222. */
  103223. glInternalFormat: number;
  103224. /**
  103225. * Gets the base internal format
  103226. */
  103227. glBaseInternalFormat: number;
  103228. /**
  103229. * Gets image width in pixel
  103230. */
  103231. pixelWidth: number;
  103232. /**
  103233. * Gets image height in pixel
  103234. */
  103235. pixelHeight: number;
  103236. /**
  103237. * Gets image depth in pixels
  103238. */
  103239. pixelDepth: number;
  103240. /**
  103241. * Gets the number of array elements
  103242. */
  103243. numberOfArrayElements: number;
  103244. /**
  103245. * Gets the number of faces
  103246. */
  103247. numberOfFaces: number;
  103248. /**
  103249. * Gets the number of mipmap levels
  103250. */
  103251. numberOfMipmapLevels: number;
  103252. /**
  103253. * Gets the bytes of key value data
  103254. */
  103255. bytesOfKeyValueData: number;
  103256. /**
  103257. * Gets the load type
  103258. */
  103259. loadType: number;
  103260. /**
  103261. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  103262. */
  103263. isInvalid: boolean;
  103264. /**
  103265. * Creates a new KhronosTextureContainer
  103266. * @param arrayBuffer contents of the KTX container file
  103267. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  103268. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  103269. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  103270. */
  103271. constructor(
  103272. /** contents of the KTX container file */
  103273. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  103274. /**
  103275. * Uploads KTX content to a Babylon Texture.
  103276. * It is assumed that the texture has already been created & is currently bound
  103277. * @hidden
  103278. */
  103279. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  103280. private _upload2DCompressedLevels;
  103281. }
  103282. }
  103283. declare module BABYLON {
  103284. /**
  103285. * Implementation of the KTX Texture Loader.
  103286. * @hidden
  103287. */
  103288. export class _KTXTextureLoader implements IInternalTextureLoader {
  103289. /**
  103290. * Defines wether the loader supports cascade loading the different faces.
  103291. */
  103292. readonly supportCascades: boolean;
  103293. /**
  103294. * This returns if the loader support the current file information.
  103295. * @param extension defines the file extension of the file being loaded
  103296. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103297. * @param fallback defines the fallback internal texture if any
  103298. * @param isBase64 defines whether the texture is encoded as a base64
  103299. * @param isBuffer defines whether the texture data are stored as a buffer
  103300. * @returns true if the loader can load the specified file
  103301. */
  103302. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  103303. /**
  103304. * Transform the url before loading if required.
  103305. * @param rootUrl the url of the texture
  103306. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103307. * @returns the transformed texture
  103308. */
  103309. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  103310. /**
  103311. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  103312. * @param rootUrl the url of the texture
  103313. * @param textureFormatInUse defines the current compressed format in use iun the engine
  103314. * @returns the fallback texture
  103315. */
  103316. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  103317. /**
  103318. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  103319. * @param data contains the texture data
  103320. * @param texture defines the BabylonJS internal texture
  103321. * @param createPolynomials will be true if polynomials have been requested
  103322. * @param onLoad defines the callback to trigger once the texture is ready
  103323. * @param onError defines the callback to trigger in case of error
  103324. */
  103325. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  103326. /**
  103327. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  103328. * @param data contains the texture data
  103329. * @param texture defines the BabylonJS internal texture
  103330. * @param callback defines the method to call once ready to upload
  103331. */
  103332. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  103333. }
  103334. }
  103335. declare module BABYLON {
  103336. /** @hidden */
  103337. export var _forceSceneHelpersToBundle: boolean;
  103338. interface Scene {
  103339. /**
  103340. * Creates a default light for the scene.
  103341. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  103342. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  103343. */
  103344. createDefaultLight(replace?: boolean): void;
  103345. /**
  103346. * Creates a default camera for the scene.
  103347. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  103348. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  103349. * @param replace has default false, when true replaces the active camera in the scene
  103350. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  103351. */
  103352. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  103353. /**
  103354. * Creates a default camera and a default light.
  103355. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  103356. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  103357. * @param replace has the default false, when true replaces the active camera/light in the scene
  103358. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  103359. */
  103360. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  103361. /**
  103362. * Creates a new sky box
  103363. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  103364. * @param environmentTexture defines the texture to use as environment texture
  103365. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  103366. * @param scale defines the overall scale of the skybox
  103367. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  103368. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  103369. * @returns a new mesh holding the sky box
  103370. */
  103371. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  103372. /**
  103373. * Creates a new environment
  103374. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  103375. * @param options defines the options you can use to configure the environment
  103376. * @returns the new EnvironmentHelper
  103377. */
  103378. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  103379. /**
  103380. * Creates a new VREXperienceHelper
  103381. * @see http://doc.babylonjs.com/how_to/webvr_helper
  103382. * @param webVROptions defines the options used to create the new VREXperienceHelper
  103383. * @returns a new VREXperienceHelper
  103384. */
  103385. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  103386. /**
  103387. * Creates a new XREXperienceHelper
  103388. * @see http://doc.babylonjs.com/how_to/webxr
  103389. * @returns a promise for a new XREXperienceHelper
  103390. */
  103391. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  103392. }
  103393. }
  103394. declare module BABYLON {
  103395. /**
  103396. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  103397. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  103398. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  103399. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  103400. */
  103401. export class VideoDome extends TransformNode {
  103402. /**
  103403. * Define the video source as a Monoscopic panoramic 360 video.
  103404. */
  103405. static readonly MODE_MONOSCOPIC: number;
  103406. /**
  103407. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  103408. */
  103409. static readonly MODE_TOPBOTTOM: number;
  103410. /**
  103411. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  103412. */
  103413. static readonly MODE_SIDEBYSIDE: number;
  103414. private _useDirectMapping;
  103415. /**
  103416. * The video texture being displayed on the sphere
  103417. */
  103418. protected _videoTexture: VideoTexture;
  103419. /**
  103420. * Gets the video texture being displayed on the sphere
  103421. */
  103422. readonly videoTexture: VideoTexture;
  103423. /**
  103424. * The skybox material
  103425. */
  103426. protected _material: BackgroundMaterial;
  103427. /**
  103428. * The surface used for the skybox
  103429. */
  103430. protected _mesh: Mesh;
  103431. /**
  103432. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103433. * Also see the options.resolution property.
  103434. */
  103435. fovMultiplier: number;
  103436. private _videoMode;
  103437. /**
  103438. * Gets or set the current video mode for the video. It can be:
  103439. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  103440. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  103441. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  103442. */
  103443. videoMode: number;
  103444. /**
  103445. * Oberserver used in Stereoscopic VR Mode.
  103446. */
  103447. private _onBeforeCameraRenderObserver;
  103448. /**
  103449. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  103450. * @param name Element's name, child elements will append suffixes for their own names.
  103451. * @param urlsOrVideo defines the url(s) or the video element to use
  103452. * @param options An object containing optional or exposed sub element properties
  103453. */
  103454. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  103455. resolution?: number;
  103456. clickToPlay?: boolean;
  103457. autoPlay?: boolean;
  103458. loop?: boolean;
  103459. size?: number;
  103460. poster?: string;
  103461. faceForward?: boolean;
  103462. useDirectMapping?: boolean;
  103463. }, scene: Scene);
  103464. private _changeVideoMode;
  103465. /**
  103466. * Releases resources associated with this node.
  103467. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103468. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103469. */
  103470. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103471. }
  103472. }
  103473. declare module BABYLON {
  103474. /**
  103475. * This class can be used to get instrumentation data from a Babylon engine
  103476. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  103477. */
  103478. export class EngineInstrumentation implements IDisposable {
  103479. /**
  103480. * Define the instrumented engine.
  103481. */
  103482. engine: Engine;
  103483. private _captureGPUFrameTime;
  103484. private _gpuFrameTimeToken;
  103485. private _gpuFrameTime;
  103486. private _captureShaderCompilationTime;
  103487. private _shaderCompilationTime;
  103488. private _onBeginFrameObserver;
  103489. private _onEndFrameObserver;
  103490. private _onBeforeShaderCompilationObserver;
  103491. private _onAfterShaderCompilationObserver;
  103492. /**
  103493. * Gets the perf counter used for GPU frame time
  103494. */
  103495. readonly gpuFrameTimeCounter: PerfCounter;
  103496. /**
  103497. * Gets the GPU frame time capture status
  103498. */
  103499. /**
  103500. * Enable or disable the GPU frame time capture
  103501. */
  103502. captureGPUFrameTime: boolean;
  103503. /**
  103504. * Gets the perf counter used for shader compilation time
  103505. */
  103506. readonly shaderCompilationTimeCounter: PerfCounter;
  103507. /**
  103508. * Gets the shader compilation time capture status
  103509. */
  103510. /**
  103511. * Enable or disable the shader compilation time capture
  103512. */
  103513. captureShaderCompilationTime: boolean;
  103514. /**
  103515. * Instantiates a new engine instrumentation.
  103516. * This class can be used to get instrumentation data from a Babylon engine
  103517. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  103518. * @param engine Defines the engine to instrument
  103519. */
  103520. constructor(
  103521. /**
  103522. * Define the instrumented engine.
  103523. */
  103524. engine: Engine);
  103525. /**
  103526. * Dispose and release associated resources.
  103527. */
  103528. dispose(): void;
  103529. }
  103530. }
  103531. declare module BABYLON {
  103532. /**
  103533. * This class can be used to get instrumentation data from a Babylon engine
  103534. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  103535. */
  103536. export class SceneInstrumentation implements IDisposable {
  103537. /**
  103538. * Defines the scene to instrument
  103539. */
  103540. scene: Scene;
  103541. private _captureActiveMeshesEvaluationTime;
  103542. private _activeMeshesEvaluationTime;
  103543. private _captureRenderTargetsRenderTime;
  103544. private _renderTargetsRenderTime;
  103545. private _captureFrameTime;
  103546. private _frameTime;
  103547. private _captureRenderTime;
  103548. private _renderTime;
  103549. private _captureInterFrameTime;
  103550. private _interFrameTime;
  103551. private _captureParticlesRenderTime;
  103552. private _particlesRenderTime;
  103553. private _captureSpritesRenderTime;
  103554. private _spritesRenderTime;
  103555. private _capturePhysicsTime;
  103556. private _physicsTime;
  103557. private _captureAnimationsTime;
  103558. private _animationsTime;
  103559. private _captureCameraRenderTime;
  103560. private _cameraRenderTime;
  103561. private _onBeforeActiveMeshesEvaluationObserver;
  103562. private _onAfterActiveMeshesEvaluationObserver;
  103563. private _onBeforeRenderTargetsRenderObserver;
  103564. private _onAfterRenderTargetsRenderObserver;
  103565. private _onAfterRenderObserver;
  103566. private _onBeforeDrawPhaseObserver;
  103567. private _onAfterDrawPhaseObserver;
  103568. private _onBeforeAnimationsObserver;
  103569. private _onBeforeParticlesRenderingObserver;
  103570. private _onAfterParticlesRenderingObserver;
  103571. private _onBeforeSpritesRenderingObserver;
  103572. private _onAfterSpritesRenderingObserver;
  103573. private _onBeforePhysicsObserver;
  103574. private _onAfterPhysicsObserver;
  103575. private _onAfterAnimationsObserver;
  103576. private _onBeforeCameraRenderObserver;
  103577. private _onAfterCameraRenderObserver;
  103578. /**
  103579. * Gets the perf counter used for active meshes evaluation time
  103580. */
  103581. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  103582. /**
  103583. * Gets the active meshes evaluation time capture status
  103584. */
  103585. /**
  103586. * Enable or disable the active meshes evaluation time capture
  103587. */
  103588. captureActiveMeshesEvaluationTime: boolean;
  103589. /**
  103590. * Gets the perf counter used for render targets render time
  103591. */
  103592. readonly renderTargetsRenderTimeCounter: PerfCounter;
  103593. /**
  103594. * Gets the render targets render time capture status
  103595. */
  103596. /**
  103597. * Enable or disable the render targets render time capture
  103598. */
  103599. captureRenderTargetsRenderTime: boolean;
  103600. /**
  103601. * Gets the perf counter used for particles render time
  103602. */
  103603. readonly particlesRenderTimeCounter: PerfCounter;
  103604. /**
  103605. * Gets the particles render time capture status
  103606. */
  103607. /**
  103608. * Enable or disable the particles render time capture
  103609. */
  103610. captureParticlesRenderTime: boolean;
  103611. /**
  103612. * Gets the perf counter used for sprites render time
  103613. */
  103614. readonly spritesRenderTimeCounter: PerfCounter;
  103615. /**
  103616. * Gets the sprites render time capture status
  103617. */
  103618. /**
  103619. * Enable or disable the sprites render time capture
  103620. */
  103621. captureSpritesRenderTime: boolean;
  103622. /**
  103623. * Gets the perf counter used for physics time
  103624. */
  103625. readonly physicsTimeCounter: PerfCounter;
  103626. /**
  103627. * Gets the physics time capture status
  103628. */
  103629. /**
  103630. * Enable or disable the physics time capture
  103631. */
  103632. capturePhysicsTime: boolean;
  103633. /**
  103634. * Gets the perf counter used for animations time
  103635. */
  103636. readonly animationsTimeCounter: PerfCounter;
  103637. /**
  103638. * Gets the animations time capture status
  103639. */
  103640. /**
  103641. * Enable or disable the animations time capture
  103642. */
  103643. captureAnimationsTime: boolean;
  103644. /**
  103645. * Gets the perf counter used for frame time capture
  103646. */
  103647. readonly frameTimeCounter: PerfCounter;
  103648. /**
  103649. * Gets the frame time capture status
  103650. */
  103651. /**
  103652. * Enable or disable the frame time capture
  103653. */
  103654. captureFrameTime: boolean;
  103655. /**
  103656. * Gets the perf counter used for inter-frames time capture
  103657. */
  103658. readonly interFrameTimeCounter: PerfCounter;
  103659. /**
  103660. * Gets the inter-frames time capture status
  103661. */
  103662. /**
  103663. * Enable or disable the inter-frames time capture
  103664. */
  103665. captureInterFrameTime: boolean;
  103666. /**
  103667. * Gets the perf counter used for render time capture
  103668. */
  103669. readonly renderTimeCounter: PerfCounter;
  103670. /**
  103671. * Gets the render time capture status
  103672. */
  103673. /**
  103674. * Enable or disable the render time capture
  103675. */
  103676. captureRenderTime: boolean;
  103677. /**
  103678. * Gets the perf counter used for camera render time capture
  103679. */
  103680. readonly cameraRenderTimeCounter: PerfCounter;
  103681. /**
  103682. * Gets the camera render time capture status
  103683. */
  103684. /**
  103685. * Enable or disable the camera render time capture
  103686. */
  103687. captureCameraRenderTime: boolean;
  103688. /**
  103689. * Gets the perf counter used for draw calls
  103690. */
  103691. readonly drawCallsCounter: PerfCounter;
  103692. /**
  103693. * Gets the perf counter used for texture collisions
  103694. */
  103695. readonly textureCollisionsCounter: PerfCounter;
  103696. /**
  103697. * Instantiates a new scene instrumentation.
  103698. * This class can be used to get instrumentation data from a Babylon engine
  103699. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  103700. * @param scene Defines the scene to instrument
  103701. */
  103702. constructor(
  103703. /**
  103704. * Defines the scene to instrument
  103705. */
  103706. scene: Scene);
  103707. /**
  103708. * Dispose and release associated resources.
  103709. */
  103710. dispose(): void;
  103711. }
  103712. }
  103713. declare module BABYLON {
  103714. /** @hidden */
  103715. export var glowMapGenerationPixelShader: {
  103716. name: string;
  103717. shader: string;
  103718. };
  103719. }
  103720. declare module BABYLON {
  103721. /** @hidden */
  103722. export var glowMapGenerationVertexShader: {
  103723. name: string;
  103724. shader: string;
  103725. };
  103726. }
  103727. declare module BABYLON {
  103728. /**
  103729. * Effect layer options. This helps customizing the behaviour
  103730. * of the effect layer.
  103731. */
  103732. export interface IEffectLayerOptions {
  103733. /**
  103734. * Multiplication factor apply to the canvas size to compute the render target size
  103735. * used to generated the objects (the smaller the faster).
  103736. */
  103737. mainTextureRatio: number;
  103738. /**
  103739. * Enforces a fixed size texture to ensure effect stability across devices.
  103740. */
  103741. mainTextureFixedSize?: number;
  103742. /**
  103743. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  103744. */
  103745. alphaBlendingMode: number;
  103746. /**
  103747. * The camera attached to the layer.
  103748. */
  103749. camera: Nullable<Camera>;
  103750. /**
  103751. * The rendering group to draw the layer in.
  103752. */
  103753. renderingGroupId: number;
  103754. }
  103755. /**
  103756. * The effect layer Helps adding post process effect blended with the main pass.
  103757. *
  103758. * This can be for instance use to generate glow or higlight effects on the scene.
  103759. *
  103760. * The effect layer class can not be used directly and is intented to inherited from to be
  103761. * customized per effects.
  103762. */
  103763. export abstract class EffectLayer {
  103764. private _vertexBuffers;
  103765. private _indexBuffer;
  103766. private _cachedDefines;
  103767. private _effectLayerMapGenerationEffect;
  103768. private _effectLayerOptions;
  103769. private _mergeEffect;
  103770. protected _scene: Scene;
  103771. protected _engine: Engine;
  103772. protected _maxSize: number;
  103773. protected _mainTextureDesiredSize: ISize;
  103774. protected _mainTexture: RenderTargetTexture;
  103775. protected _shouldRender: boolean;
  103776. protected _postProcesses: PostProcess[];
  103777. protected _textures: BaseTexture[];
  103778. protected _emissiveTextureAndColor: {
  103779. texture: Nullable<BaseTexture>;
  103780. color: Color4;
  103781. };
  103782. /**
  103783. * The name of the layer
  103784. */
  103785. name: string;
  103786. /**
  103787. * The clear color of the texture used to generate the glow map.
  103788. */
  103789. neutralColor: Color4;
  103790. /**
  103791. * Specifies wether the highlight layer is enabled or not.
  103792. */
  103793. isEnabled: boolean;
  103794. /**
  103795. * Gets the camera attached to the layer.
  103796. */
  103797. readonly camera: Nullable<Camera>;
  103798. /**
  103799. * Gets the rendering group id the layer should render in.
  103800. */
  103801. readonly renderingGroupId: number;
  103802. /**
  103803. * An event triggered when the effect layer has been disposed.
  103804. */
  103805. onDisposeObservable: Observable<EffectLayer>;
  103806. /**
  103807. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  103808. */
  103809. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  103810. /**
  103811. * An event triggered when the generated texture is being merged in the scene.
  103812. */
  103813. onBeforeComposeObservable: Observable<EffectLayer>;
  103814. /**
  103815. * An event triggered when the generated texture has been merged in the scene.
  103816. */
  103817. onAfterComposeObservable: Observable<EffectLayer>;
  103818. /**
  103819. * An event triggered when the efffect layer changes its size.
  103820. */
  103821. onSizeChangedObservable: Observable<EffectLayer>;
  103822. /** @hidden */
  103823. static _SceneComponentInitialization: (scene: Scene) => void;
  103824. /**
  103825. * Instantiates a new effect Layer and references it in the scene.
  103826. * @param name The name of the layer
  103827. * @param scene The scene to use the layer in
  103828. */
  103829. constructor(
  103830. /** The Friendly of the effect in the scene */
  103831. name: string, scene: Scene);
  103832. /**
  103833. * Get the effect name of the layer.
  103834. * @return The effect name
  103835. */
  103836. abstract getEffectName(): string;
  103837. /**
  103838. * Checks for the readiness of the element composing the layer.
  103839. * @param subMesh the mesh to check for
  103840. * @param useInstances specify wether or not to use instances to render the mesh
  103841. * @return true if ready otherwise, false
  103842. */
  103843. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103844. /**
  103845. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  103846. * @returns true if the effect requires stencil during the main canvas render pass.
  103847. */
  103848. abstract needStencil(): boolean;
  103849. /**
  103850. * Create the merge effect. This is the shader use to blit the information back
  103851. * to the main canvas at the end of the scene rendering.
  103852. * @returns The effect containing the shader used to merge the effect on the main canvas
  103853. */
  103854. protected abstract _createMergeEffect(): Effect;
  103855. /**
  103856. * Creates the render target textures and post processes used in the effect layer.
  103857. */
  103858. protected abstract _createTextureAndPostProcesses(): void;
  103859. /**
  103860. * Implementation specific of rendering the generating effect on the main canvas.
  103861. * @param effect The effect used to render through
  103862. */
  103863. protected abstract _internalRender(effect: Effect): void;
  103864. /**
  103865. * Sets the required values for both the emissive texture and and the main color.
  103866. */
  103867. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  103868. /**
  103869. * Free any resources and references associated to a mesh.
  103870. * Internal use
  103871. * @param mesh The mesh to free.
  103872. */
  103873. abstract _disposeMesh(mesh: Mesh): void;
  103874. /**
  103875. * Serializes this layer (Glow or Highlight for example)
  103876. * @returns a serialized layer object
  103877. */
  103878. abstract serialize?(): any;
  103879. /**
  103880. * Initializes the effect layer with the required options.
  103881. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  103882. */
  103883. protected _init(options: Partial<IEffectLayerOptions>): void;
  103884. /**
  103885. * Generates the index buffer of the full screen quad blending to the main canvas.
  103886. */
  103887. private _generateIndexBuffer;
  103888. /**
  103889. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  103890. */
  103891. private _genrateVertexBuffer;
  103892. /**
  103893. * Sets the main texture desired size which is the closest power of two
  103894. * of the engine canvas size.
  103895. */
  103896. private _setMainTextureSize;
  103897. /**
  103898. * Creates the main texture for the effect layer.
  103899. */
  103900. protected _createMainTexture(): void;
  103901. /**
  103902. * Adds specific effects defines.
  103903. * @param defines The defines to add specifics to.
  103904. */
  103905. protected _addCustomEffectDefines(defines: string[]): void;
  103906. /**
  103907. * Checks for the readiness of the element composing the layer.
  103908. * @param subMesh the mesh to check for
  103909. * @param useInstances specify wether or not to use instances to render the mesh
  103910. * @param emissiveTexture the associated emissive texture used to generate the glow
  103911. * @return true if ready otherwise, false
  103912. */
  103913. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  103914. /**
  103915. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  103916. */
  103917. render(): void;
  103918. /**
  103919. * Determine if a given mesh will be used in the current effect.
  103920. * @param mesh mesh to test
  103921. * @returns true if the mesh will be used
  103922. */
  103923. hasMesh(mesh: AbstractMesh): boolean;
  103924. /**
  103925. * Returns true if the layer contains information to display, otherwise false.
  103926. * @returns true if the glow layer should be rendered
  103927. */
  103928. shouldRender(): boolean;
  103929. /**
  103930. * Returns true if the mesh should render, otherwise false.
  103931. * @param mesh The mesh to render
  103932. * @returns true if it should render otherwise false
  103933. */
  103934. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  103935. /**
  103936. * Returns true if the mesh can be rendered, otherwise false.
  103937. * @param mesh The mesh to render
  103938. * @param material The material used on the mesh
  103939. * @returns true if it can be rendered otherwise false
  103940. */
  103941. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  103942. /**
  103943. * Returns true if the mesh should render, otherwise false.
  103944. * @param mesh The mesh to render
  103945. * @returns true if it should render otherwise false
  103946. */
  103947. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  103948. /**
  103949. * Renders the submesh passed in parameter to the generation map.
  103950. */
  103951. protected _renderSubMesh(subMesh: SubMesh): void;
  103952. /**
  103953. * Rebuild the required buffers.
  103954. * @hidden Internal use only.
  103955. */
  103956. _rebuild(): void;
  103957. /**
  103958. * Dispose only the render target textures and post process.
  103959. */
  103960. private _disposeTextureAndPostProcesses;
  103961. /**
  103962. * Dispose the highlight layer and free resources.
  103963. */
  103964. dispose(): void;
  103965. /**
  103966. * Gets the class name of the effect layer
  103967. * @returns the string with the class name of the effect layer
  103968. */
  103969. getClassName(): string;
  103970. /**
  103971. * Creates an effect layer from parsed effect layer data
  103972. * @param parsedEffectLayer defines effect layer data
  103973. * @param scene defines the current scene
  103974. * @param rootUrl defines the root URL containing the effect layer information
  103975. * @returns a parsed effect Layer
  103976. */
  103977. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  103978. }
  103979. }
  103980. declare module BABYLON {
  103981. interface AbstractScene {
  103982. /**
  103983. * The list of effect layers (highlights/glow) added to the scene
  103984. * @see http://doc.babylonjs.com/how_to/highlight_layer
  103985. * @see http://doc.babylonjs.com/how_to/glow_layer
  103986. */
  103987. effectLayers: Array<EffectLayer>;
  103988. /**
  103989. * Removes the given effect layer from this scene.
  103990. * @param toRemove defines the effect layer to remove
  103991. * @returns the index of the removed effect layer
  103992. */
  103993. removeEffectLayer(toRemove: EffectLayer): number;
  103994. /**
  103995. * Adds the given effect layer to this scene
  103996. * @param newEffectLayer defines the effect layer to add
  103997. */
  103998. addEffectLayer(newEffectLayer: EffectLayer): void;
  103999. }
  104000. /**
  104001. * Defines the layer scene component responsible to manage any effect layers
  104002. * in a given scene.
  104003. */
  104004. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  104005. /**
  104006. * The component name helpfull to identify the component in the list of scene components.
  104007. */
  104008. readonly name: string;
  104009. /**
  104010. * The scene the component belongs to.
  104011. */
  104012. scene: Scene;
  104013. private _engine;
  104014. private _renderEffects;
  104015. private _needStencil;
  104016. private _previousStencilState;
  104017. /**
  104018. * Creates a new instance of the component for the given scene
  104019. * @param scene Defines the scene to register the component in
  104020. */
  104021. constructor(scene: Scene);
  104022. /**
  104023. * Registers the component in a given scene
  104024. */
  104025. register(): void;
  104026. /**
  104027. * Rebuilds the elements related to this component in case of
  104028. * context lost for instance.
  104029. */
  104030. rebuild(): void;
  104031. /**
  104032. * Serializes the component data to the specified json object
  104033. * @param serializationObject The object to serialize to
  104034. */
  104035. serialize(serializationObject: any): void;
  104036. /**
  104037. * Adds all the element from the container to the scene
  104038. * @param container the container holding the elements
  104039. */
  104040. addFromContainer(container: AbstractScene): void;
  104041. /**
  104042. * Removes all the elements in the container from the scene
  104043. * @param container contains the elements to remove
  104044. */
  104045. removeFromContainer(container: AbstractScene): void;
  104046. /**
  104047. * Disposes the component and the associated ressources.
  104048. */
  104049. dispose(): void;
  104050. private _isReadyForMesh;
  104051. private _renderMainTexture;
  104052. private _setStencil;
  104053. private _setStencilBack;
  104054. private _draw;
  104055. private _drawCamera;
  104056. private _drawRenderingGroup;
  104057. }
  104058. }
  104059. declare module BABYLON {
  104060. /** @hidden */
  104061. export var glowMapMergePixelShader: {
  104062. name: string;
  104063. shader: string;
  104064. };
  104065. }
  104066. declare module BABYLON {
  104067. /** @hidden */
  104068. export var glowMapMergeVertexShader: {
  104069. name: string;
  104070. shader: string;
  104071. };
  104072. }
  104073. declare module BABYLON {
  104074. interface AbstractScene {
  104075. /**
  104076. * Return a the first highlight layer of the scene with a given name.
  104077. * @param name The name of the highlight layer to look for.
  104078. * @return The highlight layer if found otherwise null.
  104079. */
  104080. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  104081. }
  104082. /**
  104083. * Glow layer options. This helps customizing the behaviour
  104084. * of the glow layer.
  104085. */
  104086. export interface IGlowLayerOptions {
  104087. /**
  104088. * Multiplication factor apply to the canvas size to compute the render target size
  104089. * used to generated the glowing objects (the smaller the faster).
  104090. */
  104091. mainTextureRatio: number;
  104092. /**
  104093. * Enforces a fixed size texture to ensure resize independant blur.
  104094. */
  104095. mainTextureFixedSize?: number;
  104096. /**
  104097. * How big is the kernel of the blur texture.
  104098. */
  104099. blurKernelSize: number;
  104100. /**
  104101. * The camera attached to the layer.
  104102. */
  104103. camera: Nullable<Camera>;
  104104. /**
  104105. * Enable MSAA by chosing the number of samples.
  104106. */
  104107. mainTextureSamples?: number;
  104108. /**
  104109. * The rendering group to draw the layer in.
  104110. */
  104111. renderingGroupId: number;
  104112. }
  104113. /**
  104114. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  104115. *
  104116. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  104117. * glowy meshes to your scene.
  104118. *
  104119. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  104120. */
  104121. export class GlowLayer extends EffectLayer {
  104122. /**
  104123. * Effect Name of the layer.
  104124. */
  104125. static readonly EffectName: string;
  104126. /**
  104127. * The default blur kernel size used for the glow.
  104128. */
  104129. static DefaultBlurKernelSize: number;
  104130. /**
  104131. * The default texture size ratio used for the glow.
  104132. */
  104133. static DefaultTextureRatio: number;
  104134. /**
  104135. * Sets the kernel size of the blur.
  104136. */
  104137. /**
  104138. * Gets the kernel size of the blur.
  104139. */
  104140. blurKernelSize: number;
  104141. /**
  104142. * Sets the glow intensity.
  104143. */
  104144. /**
  104145. * Gets the glow intensity.
  104146. */
  104147. intensity: number;
  104148. private _options;
  104149. private _intensity;
  104150. private _horizontalBlurPostprocess1;
  104151. private _verticalBlurPostprocess1;
  104152. private _horizontalBlurPostprocess2;
  104153. private _verticalBlurPostprocess2;
  104154. private _blurTexture1;
  104155. private _blurTexture2;
  104156. private _postProcesses1;
  104157. private _postProcesses2;
  104158. private _includedOnlyMeshes;
  104159. private _excludedMeshes;
  104160. /**
  104161. * Callback used to let the user override the color selection on a per mesh basis
  104162. */
  104163. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  104164. /**
  104165. * Callback used to let the user override the texture selection on a per mesh basis
  104166. */
  104167. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  104168. /**
  104169. * Instantiates a new glow Layer and references it to the scene.
  104170. * @param name The name of the layer
  104171. * @param scene The scene to use the layer in
  104172. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  104173. */
  104174. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  104175. /**
  104176. * Get the effect name of the layer.
  104177. * @return The effect name
  104178. */
  104179. getEffectName(): string;
  104180. /**
  104181. * Create the merge effect. This is the shader use to blit the information back
  104182. * to the main canvas at the end of the scene rendering.
  104183. */
  104184. protected _createMergeEffect(): Effect;
  104185. /**
  104186. * Creates the render target textures and post processes used in the glow layer.
  104187. */
  104188. protected _createTextureAndPostProcesses(): void;
  104189. /**
  104190. * Checks for the readiness of the element composing the layer.
  104191. * @param subMesh the mesh to check for
  104192. * @param useInstances specify wether or not to use instances to render the mesh
  104193. * @param emissiveTexture the associated emissive texture used to generate the glow
  104194. * @return true if ready otherwise, false
  104195. */
  104196. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  104197. /**
  104198. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  104199. */
  104200. needStencil(): boolean;
  104201. /**
  104202. * Returns true if the mesh can be rendered, otherwise false.
  104203. * @param mesh The mesh to render
  104204. * @param material The material used on the mesh
  104205. * @returns true if it can be rendered otherwise false
  104206. */
  104207. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  104208. /**
  104209. * Implementation specific of rendering the generating effect on the main canvas.
  104210. * @param effect The effect used to render through
  104211. */
  104212. protected _internalRender(effect: Effect): void;
  104213. /**
  104214. * Sets the required values for both the emissive texture and and the main color.
  104215. */
  104216. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  104217. /**
  104218. * Returns true if the mesh should render, otherwise false.
  104219. * @param mesh The mesh to render
  104220. * @returns true if it should render otherwise false
  104221. */
  104222. protected _shouldRenderMesh(mesh: Mesh): boolean;
  104223. /**
  104224. * Adds specific effects defines.
  104225. * @param defines The defines to add specifics to.
  104226. */
  104227. protected _addCustomEffectDefines(defines: string[]): void;
  104228. /**
  104229. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  104230. * @param mesh The mesh to exclude from the glow layer
  104231. */
  104232. addExcludedMesh(mesh: Mesh): void;
  104233. /**
  104234. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  104235. * @param mesh The mesh to remove
  104236. */
  104237. removeExcludedMesh(mesh: Mesh): void;
  104238. /**
  104239. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  104240. * @param mesh The mesh to include in the glow layer
  104241. */
  104242. addIncludedOnlyMesh(mesh: Mesh): void;
  104243. /**
  104244. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  104245. * @param mesh The mesh to remove
  104246. */
  104247. removeIncludedOnlyMesh(mesh: Mesh): void;
  104248. /**
  104249. * Determine if a given mesh will be used in the glow layer
  104250. * @param mesh The mesh to test
  104251. * @returns true if the mesh will be highlighted by the current glow layer
  104252. */
  104253. hasMesh(mesh: AbstractMesh): boolean;
  104254. /**
  104255. * Free any resources and references associated to a mesh.
  104256. * Internal use
  104257. * @param mesh The mesh to free.
  104258. * @hidden
  104259. */
  104260. _disposeMesh(mesh: Mesh): void;
  104261. /**
  104262. * Gets the class name of the effect layer
  104263. * @returns the string with the class name of the effect layer
  104264. */
  104265. getClassName(): string;
  104266. /**
  104267. * Serializes this glow layer
  104268. * @returns a serialized glow layer object
  104269. */
  104270. serialize(): any;
  104271. /**
  104272. * Creates a Glow Layer from parsed glow layer data
  104273. * @param parsedGlowLayer defines glow layer data
  104274. * @param scene defines the current scene
  104275. * @param rootUrl defines the root URL containing the glow layer information
  104276. * @returns a parsed Glow Layer
  104277. */
  104278. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  104279. }
  104280. }
  104281. declare module BABYLON {
  104282. /** @hidden */
  104283. export var glowBlurPostProcessPixelShader: {
  104284. name: string;
  104285. shader: string;
  104286. };
  104287. }
  104288. declare module BABYLON {
  104289. interface AbstractScene {
  104290. /**
  104291. * Return a the first highlight layer of the scene with a given name.
  104292. * @param name The name of the highlight layer to look for.
  104293. * @return The highlight layer if found otherwise null.
  104294. */
  104295. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  104296. }
  104297. /**
  104298. * Highlight layer options. This helps customizing the behaviour
  104299. * of the highlight layer.
  104300. */
  104301. export interface IHighlightLayerOptions {
  104302. /**
  104303. * Multiplication factor apply to the canvas size to compute the render target size
  104304. * used to generated the glowing objects (the smaller the faster).
  104305. */
  104306. mainTextureRatio: number;
  104307. /**
  104308. * Enforces a fixed size texture to ensure resize independant blur.
  104309. */
  104310. mainTextureFixedSize?: number;
  104311. /**
  104312. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  104313. * of the picture to blur (the smaller the faster).
  104314. */
  104315. blurTextureSizeRatio: number;
  104316. /**
  104317. * How big in texel of the blur texture is the vertical blur.
  104318. */
  104319. blurVerticalSize: number;
  104320. /**
  104321. * How big in texel of the blur texture is the horizontal blur.
  104322. */
  104323. blurHorizontalSize: number;
  104324. /**
  104325. * Alpha blending mode used to apply the blur. Default is combine.
  104326. */
  104327. alphaBlendingMode: number;
  104328. /**
  104329. * The camera attached to the layer.
  104330. */
  104331. camera: Nullable<Camera>;
  104332. /**
  104333. * Should we display highlight as a solid stroke?
  104334. */
  104335. isStroke?: boolean;
  104336. /**
  104337. * The rendering group to draw the layer in.
  104338. */
  104339. renderingGroupId: number;
  104340. }
  104341. /**
  104342. * The highlight layer Helps adding a glow effect around a mesh.
  104343. *
  104344. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  104345. * glowy meshes to your scene.
  104346. *
  104347. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  104348. */
  104349. export class HighlightLayer extends EffectLayer {
  104350. name: string;
  104351. /**
  104352. * Effect Name of the highlight layer.
  104353. */
  104354. static readonly EffectName: string;
  104355. /**
  104356. * The neutral color used during the preparation of the glow effect.
  104357. * This is black by default as the blend operation is a blend operation.
  104358. */
  104359. static NeutralColor: Color4;
  104360. /**
  104361. * Stencil value used for glowing meshes.
  104362. */
  104363. static GlowingMeshStencilReference: number;
  104364. /**
  104365. * Stencil value used for the other meshes in the scene.
  104366. */
  104367. static NormalMeshStencilReference: number;
  104368. /**
  104369. * Specifies whether or not the inner glow is ACTIVE in the layer.
  104370. */
  104371. innerGlow: boolean;
  104372. /**
  104373. * Specifies whether or not the outer glow is ACTIVE in the layer.
  104374. */
  104375. outerGlow: boolean;
  104376. /**
  104377. * Specifies the horizontal size of the blur.
  104378. */
  104379. /**
  104380. * Gets the horizontal size of the blur.
  104381. */
  104382. blurHorizontalSize: number;
  104383. /**
  104384. * Specifies the vertical size of the blur.
  104385. */
  104386. /**
  104387. * Gets the vertical size of the blur.
  104388. */
  104389. blurVerticalSize: number;
  104390. /**
  104391. * An event triggered when the highlight layer is being blurred.
  104392. */
  104393. onBeforeBlurObservable: Observable<HighlightLayer>;
  104394. /**
  104395. * An event triggered when the highlight layer has been blurred.
  104396. */
  104397. onAfterBlurObservable: Observable<HighlightLayer>;
  104398. private _instanceGlowingMeshStencilReference;
  104399. private _options;
  104400. private _downSamplePostprocess;
  104401. private _horizontalBlurPostprocess;
  104402. private _verticalBlurPostprocess;
  104403. private _blurTexture;
  104404. private _meshes;
  104405. private _excludedMeshes;
  104406. /**
  104407. * Instantiates a new highlight Layer and references it to the scene..
  104408. * @param name The name of the layer
  104409. * @param scene The scene to use the layer in
  104410. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  104411. */
  104412. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  104413. /**
  104414. * Get the effect name of the layer.
  104415. * @return The effect name
  104416. */
  104417. getEffectName(): string;
  104418. /**
  104419. * Create the merge effect. This is the shader use to blit the information back
  104420. * to the main canvas at the end of the scene rendering.
  104421. */
  104422. protected _createMergeEffect(): Effect;
  104423. /**
  104424. * Creates the render target textures and post processes used in the highlight layer.
  104425. */
  104426. protected _createTextureAndPostProcesses(): void;
  104427. /**
  104428. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  104429. */
  104430. needStencil(): boolean;
  104431. /**
  104432. * Checks for the readiness of the element composing the layer.
  104433. * @param subMesh the mesh to check for
  104434. * @param useInstances specify wether or not to use instances to render the mesh
  104435. * @param emissiveTexture the associated emissive texture used to generate the glow
  104436. * @return true if ready otherwise, false
  104437. */
  104438. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  104439. /**
  104440. * Implementation specific of rendering the generating effect on the main canvas.
  104441. * @param effect The effect used to render through
  104442. */
  104443. protected _internalRender(effect: Effect): void;
  104444. /**
  104445. * Returns true if the layer contains information to display, otherwise false.
  104446. */
  104447. shouldRender(): boolean;
  104448. /**
  104449. * Returns true if the mesh should render, otherwise false.
  104450. * @param mesh The mesh to render
  104451. * @returns true if it should render otherwise false
  104452. */
  104453. protected _shouldRenderMesh(mesh: Mesh): boolean;
  104454. /**
  104455. * Sets the required values for both the emissive texture and and the main color.
  104456. */
  104457. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  104458. /**
  104459. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  104460. * @param mesh The mesh to exclude from the highlight layer
  104461. */
  104462. addExcludedMesh(mesh: Mesh): void;
  104463. /**
  104464. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  104465. * @param mesh The mesh to highlight
  104466. */
  104467. removeExcludedMesh(mesh: Mesh): void;
  104468. /**
  104469. * Determine if a given mesh will be highlighted by the current HighlightLayer
  104470. * @param mesh mesh to test
  104471. * @returns true if the mesh will be highlighted by the current HighlightLayer
  104472. */
  104473. hasMesh(mesh: AbstractMesh): boolean;
  104474. /**
  104475. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  104476. * @param mesh The mesh to highlight
  104477. * @param color The color of the highlight
  104478. * @param glowEmissiveOnly Extract the glow from the emissive texture
  104479. */
  104480. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  104481. /**
  104482. * Remove a mesh from the highlight layer in order to make it stop glowing.
  104483. * @param mesh The mesh to highlight
  104484. */
  104485. removeMesh(mesh: Mesh): void;
  104486. /**
  104487. * Force the stencil to the normal expected value for none glowing parts
  104488. */
  104489. private _defaultStencilReference;
  104490. /**
  104491. * Free any resources and references associated to a mesh.
  104492. * Internal use
  104493. * @param mesh The mesh to free.
  104494. * @hidden
  104495. */
  104496. _disposeMesh(mesh: Mesh): void;
  104497. /**
  104498. * Dispose the highlight layer and free resources.
  104499. */
  104500. dispose(): void;
  104501. /**
  104502. * Gets the class name of the effect layer
  104503. * @returns the string with the class name of the effect layer
  104504. */
  104505. getClassName(): string;
  104506. /**
  104507. * Serializes this Highlight layer
  104508. * @returns a serialized Highlight layer object
  104509. */
  104510. serialize(): any;
  104511. /**
  104512. * Creates a Highlight layer from parsed Highlight layer data
  104513. * @param parsedHightlightLayer defines the Highlight layer data
  104514. * @param scene defines the current scene
  104515. * @param rootUrl defines the root URL containing the Highlight layer information
  104516. * @returns a parsed Highlight layer
  104517. */
  104518. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  104519. }
  104520. }
  104521. declare module BABYLON {
  104522. /** @hidden */
  104523. export var lensFlarePixelShader: {
  104524. name: string;
  104525. shader: string;
  104526. };
  104527. }
  104528. declare module BABYLON {
  104529. /** @hidden */
  104530. export var lensFlareVertexShader: {
  104531. name: string;
  104532. shader: string;
  104533. };
  104534. }
  104535. declare module BABYLON {
  104536. /**
  104537. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  104538. * It is usually composed of several `lensFlare`.
  104539. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104540. */
  104541. export class LensFlareSystem {
  104542. /**
  104543. * Define the name of the lens flare system
  104544. */
  104545. name: string;
  104546. /**
  104547. * List of lens flares used in this system.
  104548. */
  104549. lensFlares: LensFlare[];
  104550. /**
  104551. * Define a limit from the border the lens flare can be visible.
  104552. */
  104553. borderLimit: number;
  104554. /**
  104555. * Define a viewport border we do not want to see the lens flare in.
  104556. */
  104557. viewportBorder: number;
  104558. /**
  104559. * Define a predicate which could limit the list of meshes able to occlude the effect.
  104560. */
  104561. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  104562. /**
  104563. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  104564. */
  104565. layerMask: number;
  104566. /**
  104567. * Define the id of the lens flare system in the scene.
  104568. * (equal to name by default)
  104569. */
  104570. id: string;
  104571. private _scene;
  104572. private _emitter;
  104573. private _vertexBuffers;
  104574. private _indexBuffer;
  104575. private _effect;
  104576. private _positionX;
  104577. private _positionY;
  104578. private _isEnabled;
  104579. /** @hidden */
  104580. static _SceneComponentInitialization: (scene: Scene) => void;
  104581. /**
  104582. * Instantiates a lens flare system.
  104583. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  104584. * It is usually composed of several `lensFlare`.
  104585. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104586. * @param name Define the name of the lens flare system in the scene
  104587. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  104588. * @param scene Define the scene the lens flare system belongs to
  104589. */
  104590. constructor(
  104591. /**
  104592. * Define the name of the lens flare system
  104593. */
  104594. name: string, emitter: any, scene: Scene);
  104595. /**
  104596. * Define if the lens flare system is enabled.
  104597. */
  104598. isEnabled: boolean;
  104599. /**
  104600. * Get the scene the effects belongs to.
  104601. * @returns the scene holding the lens flare system
  104602. */
  104603. getScene(): Scene;
  104604. /**
  104605. * Get the emitter of the lens flare system.
  104606. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  104607. * @returns the emitter of the lens flare system
  104608. */
  104609. getEmitter(): any;
  104610. /**
  104611. * Set the emitter of the lens flare system.
  104612. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  104613. * @param newEmitter Define the new emitter of the system
  104614. */
  104615. setEmitter(newEmitter: any): void;
  104616. /**
  104617. * Get the lens flare system emitter position.
  104618. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  104619. * @returns the position
  104620. */
  104621. getEmitterPosition(): Vector3;
  104622. /**
  104623. * @hidden
  104624. */
  104625. computeEffectivePosition(globalViewport: Viewport): boolean;
  104626. /** @hidden */
  104627. _isVisible(): boolean;
  104628. /**
  104629. * @hidden
  104630. */
  104631. render(): boolean;
  104632. /**
  104633. * Dispose and release the lens flare with its associated resources.
  104634. */
  104635. dispose(): void;
  104636. /**
  104637. * Parse a lens flare system from a JSON repressentation
  104638. * @param parsedLensFlareSystem Define the JSON to parse
  104639. * @param scene Define the scene the parsed system should be instantiated in
  104640. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  104641. * @returns the parsed system
  104642. */
  104643. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  104644. /**
  104645. * Serialize the current Lens Flare System into a JSON representation.
  104646. * @returns the serialized JSON
  104647. */
  104648. serialize(): any;
  104649. }
  104650. }
  104651. declare module BABYLON {
  104652. /**
  104653. * This represents one of the lens effect in a `lensFlareSystem`.
  104654. * It controls one of the indiviual texture used in the effect.
  104655. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104656. */
  104657. export class LensFlare {
  104658. /**
  104659. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  104660. */
  104661. size: number;
  104662. /**
  104663. * 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.
  104664. */
  104665. position: number;
  104666. /**
  104667. * Define the lens color.
  104668. */
  104669. color: Color3;
  104670. /**
  104671. * Define the lens texture.
  104672. */
  104673. texture: Nullable<Texture>;
  104674. /**
  104675. * Define the alpha mode to render this particular lens.
  104676. */
  104677. alphaMode: number;
  104678. private _system;
  104679. /**
  104680. * Creates a new Lens Flare.
  104681. * This represents one of the lens effect in a `lensFlareSystem`.
  104682. * It controls one of the indiviual texture used in the effect.
  104683. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104684. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  104685. * @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.
  104686. * @param color Define the lens color
  104687. * @param imgUrl Define the lens texture url
  104688. * @param system Define the `lensFlareSystem` this flare is part of
  104689. * @returns The newly created Lens Flare
  104690. */
  104691. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  104692. /**
  104693. * Instantiates a new Lens Flare.
  104694. * This represents one of the lens effect in a `lensFlareSystem`.
  104695. * It controls one of the indiviual texture used in the effect.
  104696. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104697. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  104698. * @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.
  104699. * @param color Define the lens color
  104700. * @param imgUrl Define the lens texture url
  104701. * @param system Define the `lensFlareSystem` this flare is part of
  104702. */
  104703. constructor(
  104704. /**
  104705. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  104706. */
  104707. size: number,
  104708. /**
  104709. * 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.
  104710. */
  104711. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  104712. /**
  104713. * Dispose and release the lens flare with its associated resources.
  104714. */
  104715. dispose(): void;
  104716. }
  104717. }
  104718. declare module BABYLON {
  104719. interface AbstractScene {
  104720. /**
  104721. * The list of lens flare system added to the scene
  104722. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  104723. */
  104724. lensFlareSystems: Array<LensFlareSystem>;
  104725. /**
  104726. * Removes the given lens flare system from this scene.
  104727. * @param toRemove The lens flare system to remove
  104728. * @returns The index of the removed lens flare system
  104729. */
  104730. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  104731. /**
  104732. * Adds the given lens flare system to this scene
  104733. * @param newLensFlareSystem The lens flare system to add
  104734. */
  104735. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  104736. /**
  104737. * Gets a lens flare system using its name
  104738. * @param name defines the name to look for
  104739. * @returns the lens flare system or null if not found
  104740. */
  104741. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  104742. /**
  104743. * Gets a lens flare system using its id
  104744. * @param id defines the id to look for
  104745. * @returns the lens flare system or null if not found
  104746. */
  104747. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  104748. }
  104749. /**
  104750. * Defines the lens flare scene component responsible to manage any lens flares
  104751. * in a given scene.
  104752. */
  104753. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  104754. /**
  104755. * The component name helpfull to identify the component in the list of scene components.
  104756. */
  104757. readonly name: string;
  104758. /**
  104759. * The scene the component belongs to.
  104760. */
  104761. scene: Scene;
  104762. /**
  104763. * Creates a new instance of the component for the given scene
  104764. * @param scene Defines the scene to register the component in
  104765. */
  104766. constructor(scene: Scene);
  104767. /**
  104768. * Registers the component in a given scene
  104769. */
  104770. register(): void;
  104771. /**
  104772. * Rebuilds the elements related to this component in case of
  104773. * context lost for instance.
  104774. */
  104775. rebuild(): void;
  104776. /**
  104777. * Adds all the element from the container to the scene
  104778. * @param container the container holding the elements
  104779. */
  104780. addFromContainer(container: AbstractScene): void;
  104781. /**
  104782. * Removes all the elements in the container from the scene
  104783. * @param container contains the elements to remove
  104784. */
  104785. removeFromContainer(container: AbstractScene): void;
  104786. /**
  104787. * Serializes the component data to the specified json object
  104788. * @param serializationObject The object to serialize to
  104789. */
  104790. serialize(serializationObject: any): void;
  104791. /**
  104792. * Disposes the component and the associated ressources.
  104793. */
  104794. dispose(): void;
  104795. private _draw;
  104796. }
  104797. }
  104798. declare module BABYLON {
  104799. /**
  104800. * Defines the shadow generator component responsible to manage any shadow generators
  104801. * in a given scene.
  104802. */
  104803. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  104804. /**
  104805. * The component name helpfull to identify the component in the list of scene components.
  104806. */
  104807. readonly name: string;
  104808. /**
  104809. * The scene the component belongs to.
  104810. */
  104811. scene: Scene;
  104812. /**
  104813. * Creates a new instance of the component for the given scene
  104814. * @param scene Defines the scene to register the component in
  104815. */
  104816. constructor(scene: Scene);
  104817. /**
  104818. * Registers the component in a given scene
  104819. */
  104820. register(): void;
  104821. /**
  104822. * Rebuilds the elements related to this component in case of
  104823. * context lost for instance.
  104824. */
  104825. rebuild(): void;
  104826. /**
  104827. * Serializes the component data to the specified json object
  104828. * @param serializationObject The object to serialize to
  104829. */
  104830. serialize(serializationObject: any): void;
  104831. /**
  104832. * Adds all the element from the container to the scene
  104833. * @param container the container holding the elements
  104834. */
  104835. addFromContainer(container: AbstractScene): void;
  104836. /**
  104837. * Removes all the elements in the container from the scene
  104838. * @param container contains the elements to remove
  104839. */
  104840. removeFromContainer(container: AbstractScene): void;
  104841. /**
  104842. * Rebuilds the elements related to this component in case of
  104843. * context lost for instance.
  104844. */
  104845. dispose(): void;
  104846. private _gatherRenderTargets;
  104847. }
  104848. }
  104849. declare module BABYLON {
  104850. /**
  104851. * A directional light is defined by a direction (what a surprise!).
  104852. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  104853. * 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.
  104854. * Documentation: https://doc.babylonjs.com/babylon101/lights
  104855. */
  104856. export class DirectionalLight extends ShadowLight {
  104857. private _shadowFrustumSize;
  104858. /**
  104859. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  104860. */
  104861. /**
  104862. * Specifies a fix frustum size for the shadow generation.
  104863. */
  104864. shadowFrustumSize: number;
  104865. private _shadowOrthoScale;
  104866. /**
  104867. * Gets the shadow projection scale against the optimal computed one.
  104868. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  104869. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  104870. */
  104871. /**
  104872. * Sets the shadow projection scale against the optimal computed one.
  104873. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  104874. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  104875. */
  104876. shadowOrthoScale: number;
  104877. /**
  104878. * Automatically compute the projection matrix to best fit (including all the casters)
  104879. * on each frame.
  104880. */
  104881. autoUpdateExtends: boolean;
  104882. private _orthoLeft;
  104883. private _orthoRight;
  104884. private _orthoTop;
  104885. private _orthoBottom;
  104886. /**
  104887. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  104888. * The directional light is emitted from everywhere in the given direction.
  104889. * It can cast shadows.
  104890. * Documentation : https://doc.babylonjs.com/babylon101/lights
  104891. * @param name The friendly name of the light
  104892. * @param direction The direction of the light
  104893. * @param scene The scene the light belongs to
  104894. */
  104895. constructor(name: string, direction: Vector3, scene: Scene);
  104896. /**
  104897. * Returns the string "DirectionalLight".
  104898. * @return The class name
  104899. */
  104900. getClassName(): string;
  104901. /**
  104902. * Returns the integer 1.
  104903. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  104904. */
  104905. getTypeID(): number;
  104906. /**
  104907. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  104908. * Returns the DirectionalLight Shadow projection matrix.
  104909. */
  104910. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  104911. /**
  104912. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  104913. * Returns the DirectionalLight Shadow projection matrix.
  104914. */
  104915. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  104916. /**
  104917. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  104918. * Returns the DirectionalLight Shadow projection matrix.
  104919. */
  104920. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  104921. protected _buildUniformLayout(): void;
  104922. /**
  104923. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  104924. * @param effect The effect to update
  104925. * @param lightIndex The index of the light in the effect to update
  104926. * @returns The directional light
  104927. */
  104928. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  104929. /**
  104930. * Gets the minZ used for shadow according to both the scene and the light.
  104931. *
  104932. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  104933. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  104934. * @param activeCamera The camera we are returning the min for
  104935. * @returns the depth min z
  104936. */
  104937. getDepthMinZ(activeCamera: Camera): number;
  104938. /**
  104939. * Gets the maxZ used for shadow according to both the scene and the light.
  104940. *
  104941. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  104942. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  104943. * @param activeCamera The camera we are returning the max for
  104944. * @returns the depth max z
  104945. */
  104946. getDepthMaxZ(activeCamera: Camera): number;
  104947. /**
  104948. * Prepares the list of defines specific to the light type.
  104949. * @param defines the list of defines
  104950. * @param lightIndex defines the index of the light for the effect
  104951. */
  104952. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  104953. }
  104954. }
  104955. declare module BABYLON {
  104956. /**
  104957. * A point light is a light defined by an unique point in world space.
  104958. * The light is emitted in every direction from this point.
  104959. * A good example of a point light is a standard light bulb.
  104960. * Documentation: https://doc.babylonjs.com/babylon101/lights
  104961. */
  104962. export class PointLight extends ShadowLight {
  104963. private _shadowAngle;
  104964. /**
  104965. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  104966. * This specifies what angle the shadow will use to be created.
  104967. *
  104968. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  104969. */
  104970. /**
  104971. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  104972. * This specifies what angle the shadow will use to be created.
  104973. *
  104974. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  104975. */
  104976. shadowAngle: number;
  104977. /**
  104978. * Gets the direction if it has been set.
  104979. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  104980. */
  104981. /**
  104982. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  104983. */
  104984. direction: Vector3;
  104985. /**
  104986. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  104987. * A PointLight emits the light in every direction.
  104988. * It can cast shadows.
  104989. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  104990. * ```javascript
  104991. * var pointLight = new PointLight("pl", camera.position, scene);
  104992. * ```
  104993. * Documentation : https://doc.babylonjs.com/babylon101/lights
  104994. * @param name The light friendly name
  104995. * @param position The position of the point light in the scene
  104996. * @param scene The scene the lights belongs to
  104997. */
  104998. constructor(name: string, position: Vector3, scene: Scene);
  104999. /**
  105000. * Returns the string "PointLight"
  105001. * @returns the class name
  105002. */
  105003. getClassName(): string;
  105004. /**
  105005. * Returns the integer 0.
  105006. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105007. */
  105008. getTypeID(): number;
  105009. /**
  105010. * Specifies wether or not the shadowmap should be a cube texture.
  105011. * @returns true if the shadowmap needs to be a cube texture.
  105012. */
  105013. needCube(): boolean;
  105014. /**
  105015. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  105016. * @param faceIndex The index of the face we are computed the direction to generate shadow
  105017. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  105018. */
  105019. getShadowDirection(faceIndex?: number): Vector3;
  105020. /**
  105021. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  105022. * - fov = PI / 2
  105023. * - aspect ratio : 1.0
  105024. * - z-near and far equal to the active camera minZ and maxZ.
  105025. * Returns the PointLight.
  105026. */
  105027. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105028. protected _buildUniformLayout(): void;
  105029. /**
  105030. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  105031. * @param effect The effect to update
  105032. * @param lightIndex The index of the light in the effect to update
  105033. * @returns The point light
  105034. */
  105035. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  105036. /**
  105037. * Prepares the list of defines specific to the light type.
  105038. * @param defines the list of defines
  105039. * @param lightIndex defines the index of the light for the effect
  105040. */
  105041. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105042. }
  105043. }
  105044. declare module BABYLON {
  105045. /**
  105046. * A spot light is defined by a position, a direction, an angle, and an exponent.
  105047. * These values define a cone of light starting from the position, emitting toward the direction.
  105048. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  105049. * and the exponent defines the speed of the decay of the light with distance (reach).
  105050. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105051. */
  105052. export class SpotLight extends ShadowLight {
  105053. private _angle;
  105054. private _innerAngle;
  105055. private _cosHalfAngle;
  105056. private _lightAngleScale;
  105057. private _lightAngleOffset;
  105058. /**
  105059. * Gets the cone angle of the spot light in Radians.
  105060. */
  105061. /**
  105062. * Sets the cone angle of the spot light in Radians.
  105063. */
  105064. angle: number;
  105065. /**
  105066. * Only used in gltf falloff mode, this defines the angle where
  105067. * the directional falloff will start before cutting at angle which could be seen
  105068. * as outer angle.
  105069. */
  105070. /**
  105071. * Only used in gltf falloff mode, this defines the angle where
  105072. * the directional falloff will start before cutting at angle which could be seen
  105073. * as outer angle.
  105074. */
  105075. innerAngle: number;
  105076. private _shadowAngleScale;
  105077. /**
  105078. * Allows scaling the angle of the light for shadow generation only.
  105079. */
  105080. /**
  105081. * Allows scaling the angle of the light for shadow generation only.
  105082. */
  105083. shadowAngleScale: number;
  105084. /**
  105085. * The light decay speed with the distance from the emission spot.
  105086. */
  105087. exponent: number;
  105088. private _projectionTextureMatrix;
  105089. /**
  105090. * Allows reading the projecton texture
  105091. */
  105092. readonly projectionTextureMatrix: Matrix;
  105093. protected _projectionTextureLightNear: number;
  105094. /**
  105095. * Gets the near clip of the Spotlight for texture projection.
  105096. */
  105097. /**
  105098. * Sets the near clip of the Spotlight for texture projection.
  105099. */
  105100. projectionTextureLightNear: number;
  105101. protected _projectionTextureLightFar: number;
  105102. /**
  105103. * Gets the far clip of the Spotlight for texture projection.
  105104. */
  105105. /**
  105106. * Sets the far clip of the Spotlight for texture projection.
  105107. */
  105108. projectionTextureLightFar: number;
  105109. protected _projectionTextureUpDirection: Vector3;
  105110. /**
  105111. * Gets the Up vector of the Spotlight for texture projection.
  105112. */
  105113. /**
  105114. * Sets the Up vector of the Spotlight for texture projection.
  105115. */
  105116. projectionTextureUpDirection: Vector3;
  105117. private _projectionTexture;
  105118. /**
  105119. * Gets the projection texture of the light.
  105120. */
  105121. /**
  105122. * Sets the projection texture of the light.
  105123. */
  105124. projectionTexture: Nullable<BaseTexture>;
  105125. private _projectionTextureViewLightDirty;
  105126. private _projectionTextureProjectionLightDirty;
  105127. private _projectionTextureDirty;
  105128. private _projectionTextureViewTargetVector;
  105129. private _projectionTextureViewLightMatrix;
  105130. private _projectionTextureProjectionLightMatrix;
  105131. private _projectionTextureScalingMatrix;
  105132. /**
  105133. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  105134. * It can cast shadows.
  105135. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105136. * @param name The light friendly name
  105137. * @param position The position of the spot light in the scene
  105138. * @param direction The direction of the light in the scene
  105139. * @param angle The cone angle of the light in Radians
  105140. * @param exponent The light decay speed with the distance from the emission spot
  105141. * @param scene The scene the lights belongs to
  105142. */
  105143. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  105144. /**
  105145. * Returns the string "SpotLight".
  105146. * @returns the class name
  105147. */
  105148. getClassName(): string;
  105149. /**
  105150. * Returns the integer 2.
  105151. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105152. */
  105153. getTypeID(): number;
  105154. /**
  105155. * Overrides the direction setter to recompute the projection texture view light Matrix.
  105156. */
  105157. protected _setDirection(value: Vector3): void;
  105158. /**
  105159. * Overrides the position setter to recompute the projection texture view light Matrix.
  105160. */
  105161. protected _setPosition(value: Vector3): void;
  105162. /**
  105163. * 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.
  105164. * Returns the SpotLight.
  105165. */
  105166. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105167. protected _computeProjectionTextureViewLightMatrix(): void;
  105168. protected _computeProjectionTextureProjectionLightMatrix(): void;
  105169. /**
  105170. * Main function for light texture projection matrix computing.
  105171. */
  105172. protected _computeProjectionTextureMatrix(): void;
  105173. protected _buildUniformLayout(): void;
  105174. private _computeAngleValues;
  105175. /**
  105176. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  105177. * @param effect The effect to update
  105178. * @param lightIndex The index of the light in the effect to update
  105179. * @returns The spot light
  105180. */
  105181. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  105182. /**
  105183. * Disposes the light and the associated resources.
  105184. */
  105185. dispose(): void;
  105186. /**
  105187. * Prepares the list of defines specific to the light type.
  105188. * @param defines the list of defines
  105189. * @param lightIndex defines the index of the light for the effect
  105190. */
  105191. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105192. }
  105193. }
  105194. declare module BABYLON {
  105195. /**
  105196. * Header information of HDR texture files.
  105197. */
  105198. export interface HDRInfo {
  105199. /**
  105200. * The height of the texture in pixels.
  105201. */
  105202. height: number;
  105203. /**
  105204. * The width of the texture in pixels.
  105205. */
  105206. width: number;
  105207. /**
  105208. * The index of the beginning of the data in the binary file.
  105209. */
  105210. dataPosition: number;
  105211. }
  105212. /**
  105213. * This groups tools to convert HDR texture to native colors array.
  105214. */
  105215. export class HDRTools {
  105216. private static Ldexp;
  105217. private static Rgbe2float;
  105218. private static readStringLine;
  105219. /**
  105220. * Reads header information from an RGBE texture stored in a native array.
  105221. * More information on this format are available here:
  105222. * https://en.wikipedia.org/wiki/RGBE_image_format
  105223. *
  105224. * @param uint8array The binary file stored in native array.
  105225. * @return The header information.
  105226. */
  105227. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  105228. /**
  105229. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  105230. * This RGBE texture needs to store the information as a panorama.
  105231. *
  105232. * More information on this format are available here:
  105233. * https://en.wikipedia.org/wiki/RGBE_image_format
  105234. *
  105235. * @param buffer The binary file stored in an array buffer.
  105236. * @param size The expected size of the extracted cubemap.
  105237. * @return The Cube Map information.
  105238. */
  105239. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  105240. /**
  105241. * Returns the pixels data extracted from an RGBE texture.
  105242. * This pixels will be stored left to right up to down in the R G B order in one array.
  105243. *
  105244. * More information on this format are available here:
  105245. * https://en.wikipedia.org/wiki/RGBE_image_format
  105246. *
  105247. * @param uint8array The binary file stored in an array buffer.
  105248. * @param hdrInfo The header information of the file.
  105249. * @return The pixels data in RGB right to left up to down order.
  105250. */
  105251. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  105252. private static RGBE_ReadPixels_RLE;
  105253. }
  105254. }
  105255. declare module BABYLON {
  105256. /**
  105257. * This represents a texture coming from an HDR input.
  105258. *
  105259. * The only supported format is currently panorama picture stored in RGBE format.
  105260. * Example of such files can be found on HDRLib: http://hdrlib.com/
  105261. */
  105262. export class HDRCubeTexture extends BaseTexture {
  105263. private static _facesMapping;
  105264. private _generateHarmonics;
  105265. private _noMipmap;
  105266. private _textureMatrix;
  105267. private _size;
  105268. private _onLoad;
  105269. private _onError;
  105270. /**
  105271. * The texture URL.
  105272. */
  105273. url: string;
  105274. /**
  105275. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  105276. */
  105277. coordinatesMode: number;
  105278. protected _isBlocking: boolean;
  105279. /**
  105280. * Sets wether or not the texture is blocking during loading.
  105281. */
  105282. /**
  105283. * Gets wether or not the texture is blocking during loading.
  105284. */
  105285. isBlocking: boolean;
  105286. protected _rotationY: number;
  105287. /**
  105288. * Sets texture matrix rotation angle around Y axis in radians.
  105289. */
  105290. /**
  105291. * Gets texture matrix rotation angle around Y axis radians.
  105292. */
  105293. rotationY: number;
  105294. /**
  105295. * Gets or sets the center of the bounding box associated with the cube texture
  105296. * It must define where the camera used to render the texture was set
  105297. */
  105298. boundingBoxPosition: Vector3;
  105299. private _boundingBoxSize;
  105300. /**
  105301. * Gets or sets the size of the bounding box associated with the cube texture
  105302. * When defined, the cubemap will switch to local mode
  105303. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  105304. * @example https://www.babylonjs-playground.com/#RNASML
  105305. */
  105306. boundingBoxSize: Vector3;
  105307. /**
  105308. * Instantiates an HDRTexture from the following parameters.
  105309. *
  105310. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  105311. * @param scene The scene the texture will be used in
  105312. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  105313. * @param noMipmap Forces to not generate the mipmap if true
  105314. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  105315. * @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)
  105316. * @param reserved Reserved flag for internal use.
  105317. */
  105318. 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>);
  105319. /**
  105320. * Get the current class name of the texture useful for serialization or dynamic coding.
  105321. * @returns "HDRCubeTexture"
  105322. */
  105323. getClassName(): string;
  105324. /**
  105325. * Occurs when the file is raw .hdr file.
  105326. */
  105327. private loadTexture;
  105328. clone(): HDRCubeTexture;
  105329. delayLoad(): void;
  105330. /**
  105331. * Get the texture reflection matrix used to rotate/transform the reflection.
  105332. * @returns the reflection matrix
  105333. */
  105334. getReflectionTextureMatrix(): Matrix;
  105335. /**
  105336. * Set the texture reflection matrix used to rotate/transform the reflection.
  105337. * @param value Define the reflection matrix to set
  105338. */
  105339. setReflectionTextureMatrix(value: Matrix): void;
  105340. /**
  105341. * Parses a JSON representation of an HDR Texture in order to create the texture
  105342. * @param parsedTexture Define the JSON representation
  105343. * @param scene Define the scene the texture should be created in
  105344. * @param rootUrl Define the root url in case we need to load relative dependencies
  105345. * @returns the newly created texture after parsing
  105346. */
  105347. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  105348. serialize(): any;
  105349. }
  105350. }
  105351. declare module BABYLON {
  105352. /**
  105353. * Class used to control physics engine
  105354. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  105355. */
  105356. export class PhysicsEngine implements IPhysicsEngine {
  105357. private _physicsPlugin;
  105358. /**
  105359. * Global value used to control the smallest number supported by the simulation
  105360. */
  105361. static Epsilon: number;
  105362. private _impostors;
  105363. private _joints;
  105364. /**
  105365. * Gets the gravity vector used by the simulation
  105366. */
  105367. gravity: Vector3;
  105368. /**
  105369. * Factory used to create the default physics plugin.
  105370. * @returns The default physics plugin
  105371. */
  105372. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  105373. /**
  105374. * Creates a new Physics Engine
  105375. * @param gravity defines the gravity vector used by the simulation
  105376. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  105377. */
  105378. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  105379. /**
  105380. * Sets the gravity vector used by the simulation
  105381. * @param gravity defines the gravity vector to use
  105382. */
  105383. setGravity(gravity: Vector3): void;
  105384. /**
  105385. * Set the time step of the physics engine.
  105386. * Default is 1/60.
  105387. * To slow it down, enter 1/600 for example.
  105388. * To speed it up, 1/30
  105389. * @param newTimeStep defines the new timestep to apply to this world.
  105390. */
  105391. setTimeStep(newTimeStep?: number): void;
  105392. /**
  105393. * Get the time step of the physics engine.
  105394. * @returns the current time step
  105395. */
  105396. getTimeStep(): number;
  105397. /**
  105398. * Release all resources
  105399. */
  105400. dispose(): void;
  105401. /**
  105402. * Gets the name of the current physics plugin
  105403. * @returns the name of the plugin
  105404. */
  105405. getPhysicsPluginName(): string;
  105406. /**
  105407. * Adding a new impostor for the impostor tracking.
  105408. * This will be done by the impostor itself.
  105409. * @param impostor the impostor to add
  105410. */
  105411. addImpostor(impostor: PhysicsImpostor): void;
  105412. /**
  105413. * Remove an impostor from the engine.
  105414. * This impostor and its mesh will not longer be updated by the physics engine.
  105415. * @param impostor the impostor to remove
  105416. */
  105417. removeImpostor(impostor: PhysicsImpostor): void;
  105418. /**
  105419. * Add a joint to the physics engine
  105420. * @param mainImpostor defines the main impostor to which the joint is added.
  105421. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  105422. * @param joint defines the joint that will connect both impostors.
  105423. */
  105424. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  105425. /**
  105426. * Removes a joint from the simulation
  105427. * @param mainImpostor defines the impostor used with the joint
  105428. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  105429. * @param joint defines the joint to remove
  105430. */
  105431. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  105432. /**
  105433. * Called by the scene. No need to call it.
  105434. * @param delta defines the timespam between frames
  105435. */
  105436. _step(delta: number): void;
  105437. /**
  105438. * Gets the current plugin used to run the simulation
  105439. * @returns current plugin
  105440. */
  105441. getPhysicsPlugin(): IPhysicsEnginePlugin;
  105442. /**
  105443. * Gets the list of physic impostors
  105444. * @returns an array of PhysicsImpostor
  105445. */
  105446. getImpostors(): Array<PhysicsImpostor>;
  105447. /**
  105448. * Gets the impostor for a physics enabled object
  105449. * @param object defines the object impersonated by the impostor
  105450. * @returns the PhysicsImpostor or null if not found
  105451. */
  105452. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  105453. /**
  105454. * Gets the impostor for a physics body object
  105455. * @param body defines physics body used by the impostor
  105456. * @returns the PhysicsImpostor or null if not found
  105457. */
  105458. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  105459. /**
  105460. * Does a raycast in the physics world
  105461. * @param from when should the ray start?
  105462. * @param to when should the ray end?
  105463. * @returns PhysicsRaycastResult
  105464. */
  105465. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  105466. }
  105467. }
  105468. declare module BABYLON {
  105469. /** @hidden */
  105470. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  105471. private _useDeltaForWorldStep;
  105472. world: any;
  105473. name: string;
  105474. private _physicsMaterials;
  105475. private _fixedTimeStep;
  105476. private _cannonRaycastResult;
  105477. private _raycastResult;
  105478. BJSCANNON: any;
  105479. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  105480. setGravity(gravity: Vector3): void;
  105481. setTimeStep(timeStep: number): void;
  105482. getTimeStep(): number;
  105483. executeStep(delta: number): void;
  105484. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105485. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105486. generatePhysicsBody(impostor: PhysicsImpostor): void;
  105487. private _processChildMeshes;
  105488. removePhysicsBody(impostor: PhysicsImpostor): void;
  105489. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  105490. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  105491. private _addMaterial;
  105492. private _checkWithEpsilon;
  105493. private _createShape;
  105494. private _createHeightmap;
  105495. private _minus90X;
  105496. private _plus90X;
  105497. private _tmpPosition;
  105498. private _tmpDeltaPosition;
  105499. private _tmpUnityRotation;
  105500. private _updatePhysicsBodyTransformation;
  105501. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  105502. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  105503. isSupported(): boolean;
  105504. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105505. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105506. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105507. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105508. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  105509. getBodyMass(impostor: PhysicsImpostor): number;
  105510. getBodyFriction(impostor: PhysicsImpostor): number;
  105511. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  105512. getBodyRestitution(impostor: PhysicsImpostor): number;
  105513. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  105514. sleepBody(impostor: PhysicsImpostor): void;
  105515. wakeUpBody(impostor: PhysicsImpostor): void;
  105516. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  105517. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  105518. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  105519. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  105520. getRadius(impostor: PhysicsImpostor): number;
  105521. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  105522. dispose(): void;
  105523. private _extendNamespace;
  105524. /**
  105525. * Does a raycast in the physics world
  105526. * @param from when should the ray start?
  105527. * @param to when should the ray end?
  105528. * @returns PhysicsRaycastResult
  105529. */
  105530. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  105531. }
  105532. }
  105533. declare module BABYLON {
  105534. /** @hidden */
  105535. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  105536. world: any;
  105537. name: string;
  105538. BJSOIMO: any;
  105539. private _raycastResult;
  105540. constructor(iterations?: number, oimoInjection?: any);
  105541. setGravity(gravity: Vector3): void;
  105542. setTimeStep(timeStep: number): void;
  105543. getTimeStep(): number;
  105544. private _tmpImpostorsArray;
  105545. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  105546. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105547. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105548. generatePhysicsBody(impostor: PhysicsImpostor): void;
  105549. private _tmpPositionVector;
  105550. removePhysicsBody(impostor: PhysicsImpostor): void;
  105551. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  105552. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  105553. isSupported(): boolean;
  105554. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  105555. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  105556. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105557. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105558. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105559. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105560. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  105561. getBodyMass(impostor: PhysicsImpostor): number;
  105562. getBodyFriction(impostor: PhysicsImpostor): number;
  105563. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  105564. getBodyRestitution(impostor: PhysicsImpostor): number;
  105565. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  105566. sleepBody(impostor: PhysicsImpostor): void;
  105567. wakeUpBody(impostor: PhysicsImpostor): void;
  105568. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  105569. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  105570. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  105571. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  105572. getRadius(impostor: PhysicsImpostor): number;
  105573. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  105574. dispose(): void;
  105575. /**
  105576. * Does a raycast in the physics world
  105577. * @param from when should the ray start?
  105578. * @param to when should the ray end?
  105579. * @returns PhysicsRaycastResult
  105580. */
  105581. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  105582. }
  105583. }
  105584. declare module BABYLON {
  105585. interface AbstractScene {
  105586. /**
  105587. * The list of reflection probes added to the scene
  105588. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  105589. */
  105590. reflectionProbes: Array<ReflectionProbe>;
  105591. /**
  105592. * Removes the given reflection probe from this scene.
  105593. * @param toRemove The reflection probe to remove
  105594. * @returns The index of the removed reflection probe
  105595. */
  105596. removeReflectionProbe(toRemove: ReflectionProbe): number;
  105597. /**
  105598. * Adds the given reflection probe to this scene.
  105599. * @param newReflectionProbe The reflection probe to add
  105600. */
  105601. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  105602. }
  105603. /**
  105604. * Class used to generate realtime reflection / refraction cube textures
  105605. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  105606. */
  105607. export class ReflectionProbe {
  105608. /** defines the name of the probe */
  105609. name: string;
  105610. private _scene;
  105611. private _renderTargetTexture;
  105612. private _projectionMatrix;
  105613. private _viewMatrix;
  105614. private _target;
  105615. private _add;
  105616. private _attachedMesh;
  105617. private _invertYAxis;
  105618. /** Gets or sets probe position (center of the cube map) */
  105619. position: Vector3;
  105620. /**
  105621. * Creates a new reflection probe
  105622. * @param name defines the name of the probe
  105623. * @param size defines the texture resolution (for each face)
  105624. * @param scene defines the hosting scene
  105625. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  105626. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  105627. */
  105628. constructor(
  105629. /** defines the name of the probe */
  105630. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  105631. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  105632. samples: number;
  105633. /** Gets or sets the refresh rate to use (on every frame by default) */
  105634. refreshRate: number;
  105635. /**
  105636. * Gets the hosting scene
  105637. * @returns a Scene
  105638. */
  105639. getScene(): Scene;
  105640. /** Gets the internal CubeTexture used to render to */
  105641. readonly cubeTexture: RenderTargetTexture;
  105642. /** Gets the list of meshes to render */
  105643. readonly renderList: Nullable<AbstractMesh[]>;
  105644. /**
  105645. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  105646. * @param mesh defines the mesh to attach to
  105647. */
  105648. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  105649. /**
  105650. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  105651. * @param renderingGroupId The rendering group id corresponding to its index
  105652. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  105653. */
  105654. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  105655. /**
  105656. * Clean all associated resources
  105657. */
  105658. dispose(): void;
  105659. /**
  105660. * Converts the reflection probe information to a readable string for debug purpose.
  105661. * @param fullDetails Supports for multiple levels of logging within scene loading
  105662. * @returns the human readable reflection probe info
  105663. */
  105664. toString(fullDetails?: boolean): string;
  105665. /**
  105666. * Get the class name of the relfection probe.
  105667. * @returns "ReflectionProbe"
  105668. */
  105669. getClassName(): string;
  105670. /**
  105671. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  105672. * @returns The JSON representation of the texture
  105673. */
  105674. serialize(): any;
  105675. /**
  105676. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  105677. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  105678. * @param scene Define the scene the parsed reflection probe should be instantiated in
  105679. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  105680. * @returns The parsed reflection probe if successful
  105681. */
  105682. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  105683. }
  105684. }
  105685. declare module BABYLON {
  105686. /** @hidden */
  105687. export var _BabylonLoaderRegistered: boolean;
  105688. }
  105689. declare module BABYLON {
  105690. /**
  105691. * The Physically based simple base material of BJS.
  105692. *
  105693. * This enables better naming and convention enforcements on top of the pbrMaterial.
  105694. * It is used as the base class for both the specGloss and metalRough conventions.
  105695. */
  105696. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  105697. /**
  105698. * Number of Simultaneous lights allowed on the material.
  105699. */
  105700. maxSimultaneousLights: number;
  105701. /**
  105702. * If sets to true, disables all the lights affecting the material.
  105703. */
  105704. disableLighting: boolean;
  105705. /**
  105706. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  105707. */
  105708. environmentTexture: BaseTexture;
  105709. /**
  105710. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105711. */
  105712. invertNormalMapX: boolean;
  105713. /**
  105714. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105715. */
  105716. invertNormalMapY: boolean;
  105717. /**
  105718. * Normal map used in the model.
  105719. */
  105720. normalTexture: BaseTexture;
  105721. /**
  105722. * Emissivie color used to self-illuminate the model.
  105723. */
  105724. emissiveColor: Color3;
  105725. /**
  105726. * Emissivie texture used to self-illuminate the model.
  105727. */
  105728. emissiveTexture: BaseTexture;
  105729. /**
  105730. * Occlusion Channel Strenght.
  105731. */
  105732. occlusionStrength: number;
  105733. /**
  105734. * Occlusion Texture of the material (adding extra occlusion effects).
  105735. */
  105736. occlusionTexture: BaseTexture;
  105737. /**
  105738. * Defines the alpha limits in alpha test mode.
  105739. */
  105740. alphaCutOff: number;
  105741. /**
  105742. * Gets the current double sided mode.
  105743. */
  105744. /**
  105745. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105746. */
  105747. doubleSided: boolean;
  105748. /**
  105749. * Stores the pre-calculated light information of a mesh in a texture.
  105750. */
  105751. lightmapTexture: BaseTexture;
  105752. /**
  105753. * If true, the light map contains occlusion information instead of lighting info.
  105754. */
  105755. useLightmapAsShadowmap: boolean;
  105756. /**
  105757. * Instantiates a new PBRMaterial instance.
  105758. *
  105759. * @param name The material name
  105760. * @param scene The scene the material will be use in.
  105761. */
  105762. constructor(name: string, scene: Scene);
  105763. getClassName(): string;
  105764. }
  105765. }
  105766. declare module BABYLON {
  105767. /**
  105768. * The PBR material of BJS following the metal roughness convention.
  105769. *
  105770. * This fits to the PBR convention in the GLTF definition:
  105771. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  105772. */
  105773. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  105774. /**
  105775. * The base color has two different interpretations depending on the value of metalness.
  105776. * When the material is a metal, the base color is the specific measured reflectance value
  105777. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  105778. * of the material.
  105779. */
  105780. baseColor: Color3;
  105781. /**
  105782. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  105783. * well as opacity information in the alpha channel.
  105784. */
  105785. baseTexture: BaseTexture;
  105786. /**
  105787. * Specifies the metallic scalar value of the material.
  105788. * Can also be used to scale the metalness values of the metallic texture.
  105789. */
  105790. metallic: number;
  105791. /**
  105792. * Specifies the roughness scalar value of the material.
  105793. * Can also be used to scale the roughness values of the metallic texture.
  105794. */
  105795. roughness: number;
  105796. /**
  105797. * Texture containing both the metallic value in the B channel and the
  105798. * roughness value in the G channel to keep better precision.
  105799. */
  105800. metallicRoughnessTexture: BaseTexture;
  105801. /**
  105802. * Instantiates a new PBRMetalRoughnessMaterial instance.
  105803. *
  105804. * @param name The material name
  105805. * @param scene The scene the material will be use in.
  105806. */
  105807. constructor(name: string, scene: Scene);
  105808. /**
  105809. * Return the currrent class name of the material.
  105810. */
  105811. getClassName(): string;
  105812. /**
  105813. * Makes a duplicate of the current material.
  105814. * @param name - name to use for the new material.
  105815. */
  105816. clone(name: string): PBRMetallicRoughnessMaterial;
  105817. /**
  105818. * Serialize the material to a parsable JSON object.
  105819. */
  105820. serialize(): any;
  105821. /**
  105822. * Parses a JSON object correponding to the serialize function.
  105823. */
  105824. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  105825. }
  105826. }
  105827. declare module BABYLON {
  105828. /**
  105829. * The PBR material of BJS following the specular glossiness convention.
  105830. *
  105831. * This fits to the PBR convention in the GLTF definition:
  105832. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  105833. */
  105834. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  105835. /**
  105836. * Specifies the diffuse color of the material.
  105837. */
  105838. diffuseColor: Color3;
  105839. /**
  105840. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  105841. * channel.
  105842. */
  105843. diffuseTexture: BaseTexture;
  105844. /**
  105845. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  105846. */
  105847. specularColor: Color3;
  105848. /**
  105849. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  105850. */
  105851. glossiness: number;
  105852. /**
  105853. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  105854. */
  105855. specularGlossinessTexture: BaseTexture;
  105856. /**
  105857. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  105858. *
  105859. * @param name The material name
  105860. * @param scene The scene the material will be use in.
  105861. */
  105862. constructor(name: string, scene: Scene);
  105863. /**
  105864. * Return the currrent class name of the material.
  105865. */
  105866. getClassName(): string;
  105867. /**
  105868. * Makes a duplicate of the current material.
  105869. * @param name - name to use for the new material.
  105870. */
  105871. clone(name: string): PBRSpecularGlossinessMaterial;
  105872. /**
  105873. * Serialize the material to a parsable JSON object.
  105874. */
  105875. serialize(): any;
  105876. /**
  105877. * Parses a JSON object correponding to the serialize function.
  105878. */
  105879. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  105880. }
  105881. }
  105882. declare module BABYLON {
  105883. /**
  105884. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  105885. * It can help converting any input color in a desired output one. This can then be used to create effects
  105886. * from sepia, black and white to sixties or futuristic rendering...
  105887. *
  105888. * The only supported format is currently 3dl.
  105889. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  105890. */
  105891. export class ColorGradingTexture extends BaseTexture {
  105892. /**
  105893. * The current texture matrix. (will always be identity in color grading texture)
  105894. */
  105895. private _textureMatrix;
  105896. /**
  105897. * The texture URL.
  105898. */
  105899. url: string;
  105900. /**
  105901. * Empty line regex stored for GC.
  105902. */
  105903. private static _noneEmptyLineRegex;
  105904. private _engine;
  105905. /**
  105906. * Instantiates a ColorGradingTexture from the following parameters.
  105907. *
  105908. * @param url The location of the color gradind data (currently only supporting 3dl)
  105909. * @param scene The scene the texture will be used in
  105910. */
  105911. constructor(url: string, scene: Scene);
  105912. /**
  105913. * Returns the texture matrix used in most of the material.
  105914. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  105915. */
  105916. getTextureMatrix(): Matrix;
  105917. /**
  105918. * Occurs when the file being loaded is a .3dl LUT file.
  105919. */
  105920. private load3dlTexture;
  105921. /**
  105922. * Starts the loading process of the texture.
  105923. */
  105924. private loadTexture;
  105925. /**
  105926. * Clones the color gradind texture.
  105927. */
  105928. clone(): ColorGradingTexture;
  105929. /**
  105930. * Called during delayed load for textures.
  105931. */
  105932. delayLoad(): void;
  105933. /**
  105934. * Parses a color grading texture serialized by Babylon.
  105935. * @param parsedTexture The texture information being parsedTexture
  105936. * @param scene The scene to load the texture in
  105937. * @param rootUrl The root url of the data assets to load
  105938. * @return A color gradind texture
  105939. */
  105940. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  105941. /**
  105942. * Serializes the LUT texture to json format.
  105943. */
  105944. serialize(): any;
  105945. }
  105946. }
  105947. declare module BABYLON {
  105948. /**
  105949. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  105950. */
  105951. export class EquiRectangularCubeTexture extends BaseTexture {
  105952. /** The six faces of the cube. */
  105953. private static _FacesMapping;
  105954. private _noMipmap;
  105955. private _onLoad;
  105956. private _onError;
  105957. /** The size of the cubemap. */
  105958. private _size;
  105959. /** The buffer of the image. */
  105960. private _buffer;
  105961. /** The width of the input image. */
  105962. private _width;
  105963. /** The height of the input image. */
  105964. private _height;
  105965. /** The URL to the image. */
  105966. url: string;
  105967. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  105968. coordinatesMode: number;
  105969. /**
  105970. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  105971. * @param url The location of the image
  105972. * @param scene The scene the texture will be used in
  105973. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  105974. * @param noMipmap Forces to not generate the mipmap if true
  105975. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  105976. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  105977. * @param onLoad — defines a callback called when texture is loaded
  105978. * @param onError — defines a callback called if there is an error
  105979. */
  105980. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  105981. /**
  105982. * Load the image data, by putting the image on a canvas and extracting its buffer.
  105983. */
  105984. private loadImage;
  105985. /**
  105986. * Convert the image buffer into a cubemap and create a CubeTexture.
  105987. */
  105988. private loadTexture;
  105989. /**
  105990. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  105991. * @param buffer The ArrayBuffer that should be converted.
  105992. * @returns The buffer as Float32Array.
  105993. */
  105994. private getFloat32ArrayFromArrayBuffer;
  105995. /**
  105996. * Get the current class name of the texture useful for serialization or dynamic coding.
  105997. * @returns "EquiRectangularCubeTexture"
  105998. */
  105999. getClassName(): string;
  106000. /**
  106001. * Create a clone of the current EquiRectangularCubeTexture and return it.
  106002. * @returns A clone of the current EquiRectangularCubeTexture.
  106003. */
  106004. clone(): EquiRectangularCubeTexture;
  106005. }
  106006. }
  106007. declare module BABYLON {
  106008. /**
  106009. * Based on jsTGALoader - Javascript loader for TGA file
  106010. * By Vincent Thibault
  106011. * @see http://blog.robrowser.com/javascript-tga-loader.html
  106012. */
  106013. export class TGATools {
  106014. private static _TYPE_INDEXED;
  106015. private static _TYPE_RGB;
  106016. private static _TYPE_GREY;
  106017. private static _TYPE_RLE_INDEXED;
  106018. private static _TYPE_RLE_RGB;
  106019. private static _TYPE_RLE_GREY;
  106020. private static _ORIGIN_MASK;
  106021. private static _ORIGIN_SHIFT;
  106022. private static _ORIGIN_BL;
  106023. private static _ORIGIN_BR;
  106024. private static _ORIGIN_UL;
  106025. private static _ORIGIN_UR;
  106026. /**
  106027. * Gets the header of a TGA file
  106028. * @param data defines the TGA data
  106029. * @returns the header
  106030. */
  106031. static GetTGAHeader(data: Uint8Array): any;
  106032. /**
  106033. * Uploads TGA content to a Babylon Texture
  106034. * @hidden
  106035. */
  106036. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  106037. /** @hidden */
  106038. 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;
  106039. /** @hidden */
  106040. 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;
  106041. /** @hidden */
  106042. 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;
  106043. /** @hidden */
  106044. 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;
  106045. /** @hidden */
  106046. 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;
  106047. /** @hidden */
  106048. 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;
  106049. }
  106050. }
  106051. declare module BABYLON {
  106052. /**
  106053. * Implementation of the TGA Texture Loader.
  106054. * @hidden
  106055. */
  106056. export class _TGATextureLoader implements IInternalTextureLoader {
  106057. /**
  106058. * Defines wether the loader supports cascade loading the different faces.
  106059. */
  106060. readonly supportCascades: boolean;
  106061. /**
  106062. * This returns if the loader support the current file information.
  106063. * @param extension defines the file extension of the file being loaded
  106064. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106065. * @param fallback defines the fallback internal texture if any
  106066. * @param isBase64 defines whether the texture is encoded as a base64
  106067. * @param isBuffer defines whether the texture data are stored as a buffer
  106068. * @returns true if the loader can load the specified file
  106069. */
  106070. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  106071. /**
  106072. * Transform the url before loading if required.
  106073. * @param rootUrl the url of the texture
  106074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106075. * @returns the transformed texture
  106076. */
  106077. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  106078. /**
  106079. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  106080. * @param rootUrl the url of the texture
  106081. * @param textureFormatInUse defines the current compressed format in use iun the engine
  106082. * @returns the fallback texture
  106083. */
  106084. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  106085. /**
  106086. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  106087. * @param data contains the texture data
  106088. * @param texture defines the BabylonJS internal texture
  106089. * @param createPolynomials will be true if polynomials have been requested
  106090. * @param onLoad defines the callback to trigger once the texture is ready
  106091. * @param onError defines the callback to trigger in case of error
  106092. */
  106093. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  106094. /**
  106095. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  106096. * @param data contains the texture data
  106097. * @param texture defines the BabylonJS internal texture
  106098. * @param callback defines the method to call once ready to upload
  106099. */
  106100. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  106101. }
  106102. }
  106103. declare module BABYLON {
  106104. /**
  106105. * 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.
  106106. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  106107. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  106108. */
  106109. export class CustomProceduralTexture extends ProceduralTexture {
  106110. private _animate;
  106111. private _time;
  106112. private _config;
  106113. private _texturePath;
  106114. /**
  106115. * Instantiates a new Custom Procedural Texture.
  106116. * 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.
  106117. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  106118. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  106119. * @param name Define the name of the texture
  106120. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  106121. * @param size Define the size of the texture to create
  106122. * @param scene Define the scene the texture belongs to
  106123. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  106124. * @param generateMipMaps Define if the texture should creates mip maps or not
  106125. */
  106126. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  106127. private _loadJson;
  106128. /**
  106129. * Is the texture ready to be used ? (rendered at least once)
  106130. * @returns true if ready, otherwise, false.
  106131. */
  106132. isReady(): boolean;
  106133. /**
  106134. * Render the texture to its associated render target.
  106135. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  106136. */
  106137. render(useCameraPostProcess?: boolean): void;
  106138. /**
  106139. * Update the list of dependant textures samplers in the shader.
  106140. */
  106141. updateTextures(): void;
  106142. /**
  106143. * Update the uniform values of the procedural texture in the shader.
  106144. */
  106145. updateShaderUniforms(): void;
  106146. /**
  106147. * Define if the texture animates or not.
  106148. */
  106149. animate: boolean;
  106150. }
  106151. }
  106152. declare module BABYLON {
  106153. /** @hidden */
  106154. export var noisePixelShader: {
  106155. name: string;
  106156. shader: string;
  106157. };
  106158. }
  106159. declare module BABYLON {
  106160. /**
  106161. * Class used to generate noise procedural textures
  106162. */
  106163. export class NoiseProceduralTexture extends ProceduralTexture {
  106164. private _time;
  106165. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  106166. brightness: number;
  106167. /** Defines the number of octaves to process */
  106168. octaves: number;
  106169. /** Defines the level of persistence (0.8 by default) */
  106170. persistence: number;
  106171. /** Gets or sets animation speed factor (default is 1) */
  106172. animationSpeedFactor: number;
  106173. /**
  106174. * Creates a new NoiseProceduralTexture
  106175. * @param name defines the name fo the texture
  106176. * @param size defines the size of the texture (default is 256)
  106177. * @param scene defines the hosting scene
  106178. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  106179. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  106180. */
  106181. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  106182. private _updateShaderUniforms;
  106183. protected _getDefines(): string;
  106184. /** Generate the current state of the procedural texture */
  106185. render(useCameraPostProcess?: boolean): void;
  106186. /**
  106187. * Serializes this noise procedural texture
  106188. * @returns a serialized noise procedural texture object
  106189. */
  106190. serialize(): any;
  106191. /**
  106192. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  106193. * @param parsedTexture defines parsed texture data
  106194. * @param scene defines the current scene
  106195. * @param rootUrl defines the root URL containing noise procedural texture information
  106196. * @returns a parsed NoiseProceduralTexture
  106197. */
  106198. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  106199. }
  106200. }
  106201. declare module BABYLON {
  106202. /**
  106203. * Raw cube texture where the raw buffers are passed in
  106204. */
  106205. export class RawCubeTexture extends CubeTexture {
  106206. /**
  106207. * Creates a cube texture where the raw buffers are passed in.
  106208. * @param scene defines the scene the texture is attached to
  106209. * @param data defines the array of data to use to create each face
  106210. * @param size defines the size of the textures
  106211. * @param format defines the format of the data
  106212. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  106213. * @param generateMipMaps defines if the engine should generate the mip levels
  106214. * @param invertY defines if data must be stored with Y axis inverted
  106215. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106216. * @param compression defines the compression used (null by default)
  106217. */
  106218. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  106219. /**
  106220. * Updates the raw cube texture.
  106221. * @param data defines the data to store
  106222. * @param format defines the data format
  106223. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  106224. * @param invertY defines if data must be stored with Y axis inverted
  106225. * @param compression defines the compression used (null by default)
  106226. * @param level defines which level of the texture to update
  106227. */
  106228. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  106229. /**
  106230. * Updates a raw cube texture with RGBD encoded data.
  106231. * @param data defines the array of data [mipmap][face] to use to create each face
  106232. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  106233. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  106234. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  106235. * @returns a promsie that resolves when the operation is complete
  106236. */
  106237. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  106238. /**
  106239. * Clones the raw cube texture.
  106240. * @return a new cube texture
  106241. */
  106242. clone(): CubeTexture;
  106243. /** @hidden */
  106244. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  106245. }
  106246. }
  106247. declare module BABYLON {
  106248. /**
  106249. * Class used to store 3D textures containing user data
  106250. */
  106251. export class RawTexture3D extends Texture {
  106252. /** Gets or sets the texture format to use */
  106253. format: number;
  106254. private _engine;
  106255. /**
  106256. * Create a new RawTexture3D
  106257. * @param data defines the data of the texture
  106258. * @param width defines the width of the texture
  106259. * @param height defines the height of the texture
  106260. * @param depth defines the depth of the texture
  106261. * @param format defines the texture format to use
  106262. * @param scene defines the hosting scene
  106263. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  106264. * @param invertY defines if texture must be stored with Y axis inverted
  106265. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  106266. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  106267. */
  106268. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  106269. /** Gets or sets the texture format to use */
  106270. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  106271. /**
  106272. * Update the texture with new data
  106273. * @param data defines the data to store in the texture
  106274. */
  106275. update(data: ArrayBufferView): void;
  106276. }
  106277. }
  106278. declare module BABYLON {
  106279. /**
  106280. * Creates a refraction texture used by refraction channel of the standard material.
  106281. * It is like a mirror but to see through a material.
  106282. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  106283. */
  106284. export class RefractionTexture extends RenderTargetTexture {
  106285. /**
  106286. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  106287. * 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.
  106288. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  106289. */
  106290. refractionPlane: Plane;
  106291. /**
  106292. * Define how deep under the surface we should see.
  106293. */
  106294. depth: number;
  106295. /**
  106296. * Creates a refraction texture used by refraction channel of the standard material.
  106297. * It is like a mirror but to see through a material.
  106298. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  106299. * @param name Define the texture name
  106300. * @param size Define the size of the underlying texture
  106301. * @param scene Define the scene the refraction belongs to
  106302. * @param generateMipMaps Define if we need to generate mips level for the refraction
  106303. */
  106304. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  106305. /**
  106306. * Clone the refraction texture.
  106307. * @returns the cloned texture
  106308. */
  106309. clone(): RefractionTexture;
  106310. /**
  106311. * Serialize the texture to a JSON representation you could use in Parse later on
  106312. * @returns the serialized JSON representation
  106313. */
  106314. serialize(): any;
  106315. }
  106316. }
  106317. declare module BABYLON {
  106318. /**
  106319. * Configuration for Draco compression
  106320. */
  106321. export interface IDracoCompressionConfiguration {
  106322. /**
  106323. * Configuration for the decoder.
  106324. */
  106325. decoder?: {
  106326. /**
  106327. * The url to the WebAssembly module.
  106328. */
  106329. wasmUrl?: string;
  106330. /**
  106331. * The url to the WebAssembly binary.
  106332. */
  106333. wasmBinaryUrl?: string;
  106334. /**
  106335. * The url to the fallback JavaScript module.
  106336. */
  106337. fallbackUrl?: string;
  106338. };
  106339. }
  106340. /**
  106341. * Draco compression (https://google.github.io/draco/)
  106342. *
  106343. * This class wraps the Draco module.
  106344. *
  106345. * **Encoder**
  106346. *
  106347. * The encoder is not currently implemented.
  106348. *
  106349. * **Decoder**
  106350. *
  106351. * 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.
  106352. *
  106353. * To update the configuration, use the following code:
  106354. * ```javascript
  106355. * DracoCompression.Configuration = {
  106356. * decoder: {
  106357. * wasmUrl: "<url to the WebAssembly library>",
  106358. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  106359. * fallbackUrl: "<url to the fallback JavaScript library>",
  106360. * }
  106361. * };
  106362. * ```
  106363. *
  106364. * 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.
  106365. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  106366. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  106367. *
  106368. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  106369. * ```javascript
  106370. * var dracoCompression = new DracoCompression();
  106371. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  106372. * [VertexBuffer.PositionKind]: 0
  106373. * });
  106374. * ```
  106375. *
  106376. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  106377. */
  106378. export class DracoCompression implements IDisposable {
  106379. private static _DecoderModulePromise;
  106380. /**
  106381. * The configuration. Defaults to the following urls:
  106382. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  106383. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  106384. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  106385. */
  106386. static Configuration: IDracoCompressionConfiguration;
  106387. /**
  106388. * Returns true if the decoder is available.
  106389. */
  106390. static readonly DecoderAvailable: boolean;
  106391. /**
  106392. * Constructor
  106393. */
  106394. constructor();
  106395. /**
  106396. * Stop all async operations and release resources.
  106397. */
  106398. dispose(): void;
  106399. /**
  106400. * Decode Draco compressed mesh data to vertex data.
  106401. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  106402. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  106403. * @returns A promise that resolves with the decoded vertex data
  106404. */
  106405. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  106406. [kind: string]: number;
  106407. }): Promise<VertexData>;
  106408. private static _GetDecoderModule;
  106409. private static _LoadScriptAsync;
  106410. private static _LoadFileAsync;
  106411. }
  106412. }
  106413. declare module BABYLON {
  106414. /**
  106415. * Class for building Constructive Solid Geometry
  106416. */
  106417. export class CSG {
  106418. private polygons;
  106419. /**
  106420. * The world matrix
  106421. */
  106422. matrix: Matrix;
  106423. /**
  106424. * Stores the position
  106425. */
  106426. position: Vector3;
  106427. /**
  106428. * Stores the rotation
  106429. */
  106430. rotation: Vector3;
  106431. /**
  106432. * Stores the rotation quaternion
  106433. */
  106434. rotationQuaternion: Nullable<Quaternion>;
  106435. /**
  106436. * Stores the scaling vector
  106437. */
  106438. scaling: Vector3;
  106439. /**
  106440. * Convert the Mesh to CSG
  106441. * @param mesh The Mesh to convert to CSG
  106442. * @returns A new CSG from the Mesh
  106443. */
  106444. static FromMesh(mesh: Mesh): CSG;
  106445. /**
  106446. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  106447. * @param polygons Polygons used to construct a CSG solid
  106448. */
  106449. private static FromPolygons;
  106450. /**
  106451. * Clones, or makes a deep copy, of the CSG
  106452. * @returns A new CSG
  106453. */
  106454. clone(): CSG;
  106455. /**
  106456. * Unions this CSG with another CSG
  106457. * @param csg The CSG to union against this CSG
  106458. * @returns The unioned CSG
  106459. */
  106460. union(csg: CSG): CSG;
  106461. /**
  106462. * Unions this CSG with another CSG in place
  106463. * @param csg The CSG to union against this CSG
  106464. */
  106465. unionInPlace(csg: CSG): void;
  106466. /**
  106467. * Subtracts this CSG with another CSG
  106468. * @param csg The CSG to subtract against this CSG
  106469. * @returns A new CSG
  106470. */
  106471. subtract(csg: CSG): CSG;
  106472. /**
  106473. * Subtracts this CSG with another CSG in place
  106474. * @param csg The CSG to subtact against this CSG
  106475. */
  106476. subtractInPlace(csg: CSG): void;
  106477. /**
  106478. * Intersect this CSG with another CSG
  106479. * @param csg The CSG to intersect against this CSG
  106480. * @returns A new CSG
  106481. */
  106482. intersect(csg: CSG): CSG;
  106483. /**
  106484. * Intersects this CSG with another CSG in place
  106485. * @param csg The CSG to intersect against this CSG
  106486. */
  106487. intersectInPlace(csg: CSG): void;
  106488. /**
  106489. * Return a new CSG solid with solid and empty space switched. This solid is
  106490. * not modified.
  106491. * @returns A new CSG solid with solid and empty space switched
  106492. */
  106493. inverse(): CSG;
  106494. /**
  106495. * Inverses the CSG in place
  106496. */
  106497. inverseInPlace(): void;
  106498. /**
  106499. * This is used to keep meshes transformations so they can be restored
  106500. * when we build back a Babylon Mesh
  106501. * NB : All CSG operations are performed in world coordinates
  106502. * @param csg The CSG to copy the transform attributes from
  106503. * @returns This CSG
  106504. */
  106505. copyTransformAttributes(csg: CSG): CSG;
  106506. /**
  106507. * Build Raw mesh from CSG
  106508. * Coordinates here are in world space
  106509. * @param name The name of the mesh geometry
  106510. * @param scene The Scene
  106511. * @param keepSubMeshes Specifies if the submeshes should be kept
  106512. * @returns A new Mesh
  106513. */
  106514. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  106515. /**
  106516. * Build Mesh from CSG taking material and transforms into account
  106517. * @param name The name of the Mesh
  106518. * @param material The material of the Mesh
  106519. * @param scene The Scene
  106520. * @param keepSubMeshes Specifies if submeshes should be kept
  106521. * @returns The new Mesh
  106522. */
  106523. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  106524. }
  106525. }
  106526. declare module BABYLON {
  106527. /**
  106528. * Class used to create a trail following a mesh
  106529. */
  106530. export class TrailMesh extends Mesh {
  106531. private _generator;
  106532. private _autoStart;
  106533. private _running;
  106534. private _diameter;
  106535. private _length;
  106536. private _sectionPolygonPointsCount;
  106537. private _sectionVectors;
  106538. private _sectionNormalVectors;
  106539. private _beforeRenderObserver;
  106540. /**
  106541. * @constructor
  106542. * @param name The value used by scene.getMeshByName() to do a lookup.
  106543. * @param generator The mesh to generate a trail.
  106544. * @param scene The scene to add this mesh to.
  106545. * @param diameter Diameter of trailing mesh. Default is 1.
  106546. * @param length Length of trailing mesh. Default is 60.
  106547. * @param autoStart Automatically start trailing mesh. Default true.
  106548. */
  106549. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  106550. /**
  106551. * "TrailMesh"
  106552. * @returns "TrailMesh"
  106553. */
  106554. getClassName(): string;
  106555. private _createMesh;
  106556. /**
  106557. * Start trailing mesh.
  106558. */
  106559. start(): void;
  106560. /**
  106561. * Stop trailing mesh.
  106562. */
  106563. stop(): void;
  106564. /**
  106565. * Update trailing mesh geometry.
  106566. */
  106567. update(): void;
  106568. /**
  106569. * Returns a new TrailMesh object.
  106570. * @param name is a string, the name given to the new mesh
  106571. * @param newGenerator use new generator object for cloned trail mesh
  106572. * @returns a new mesh
  106573. */
  106574. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  106575. /**
  106576. * Serializes this trail mesh
  106577. * @param serializationObject object to write serialization to
  106578. */
  106579. serialize(serializationObject: any): void;
  106580. /**
  106581. * Parses a serialized trail mesh
  106582. * @param parsedMesh the serialized mesh
  106583. * @param scene the scene to create the trail mesh in
  106584. * @returns the created trail mesh
  106585. */
  106586. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  106587. }
  106588. }
  106589. declare module BABYLON {
  106590. /**
  106591. * Class containing static functions to help procedurally build meshes
  106592. */
  106593. export class RibbonBuilder {
  106594. /**
  106595. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106596. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  106597. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  106598. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  106599. * * 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
  106600. * * 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
  106601. * * 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
  106602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106603. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106604. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106605. * * 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
  106606. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  106607. * * 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
  106608. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  106609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106610. * @param name defines the name of the mesh
  106611. * @param options defines the options used to create the mesh
  106612. * @param scene defines the hosting scene
  106613. * @returns the ribbon mesh
  106614. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  106615. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106616. */
  106617. static CreateRibbon(name: string, options: {
  106618. pathArray: Vector3[][];
  106619. closeArray?: boolean;
  106620. closePath?: boolean;
  106621. offset?: number;
  106622. updatable?: boolean;
  106623. sideOrientation?: number;
  106624. frontUVs?: Vector4;
  106625. backUVs?: Vector4;
  106626. instance?: Mesh;
  106627. invertUV?: boolean;
  106628. uvs?: Vector2[];
  106629. colors?: Color4[];
  106630. }, scene?: Nullable<Scene>): Mesh;
  106631. }
  106632. }
  106633. declare module BABYLON {
  106634. /**
  106635. * Class containing static functions to help procedurally build meshes
  106636. */
  106637. export class TorusKnotBuilder {
  106638. /**
  106639. * Creates a torus knot mesh
  106640. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  106641. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  106642. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  106643. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  106644. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106645. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106647. * @param name defines the name of the mesh
  106648. * @param options defines the options used to create the mesh
  106649. * @param scene defines the hosting scene
  106650. * @returns the torus knot mesh
  106651. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  106652. */
  106653. static CreateTorusKnot(name: string, options: {
  106654. radius?: number;
  106655. tube?: number;
  106656. radialSegments?: number;
  106657. tubularSegments?: number;
  106658. p?: number;
  106659. q?: number;
  106660. updatable?: boolean;
  106661. sideOrientation?: number;
  106662. frontUVs?: Vector4;
  106663. backUVs?: Vector4;
  106664. }, scene: any): Mesh;
  106665. }
  106666. }
  106667. declare module BABYLON {
  106668. /**
  106669. * Polygon
  106670. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  106671. */
  106672. export class Polygon {
  106673. /**
  106674. * Creates a rectangle
  106675. * @param xmin bottom X coord
  106676. * @param ymin bottom Y coord
  106677. * @param xmax top X coord
  106678. * @param ymax top Y coord
  106679. * @returns points that make the resulting rectation
  106680. */
  106681. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  106682. /**
  106683. * Creates a circle
  106684. * @param radius radius of circle
  106685. * @param cx scale in x
  106686. * @param cy scale in y
  106687. * @param numberOfSides number of sides that make up the circle
  106688. * @returns points that make the resulting circle
  106689. */
  106690. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  106691. /**
  106692. * Creates a polygon from input string
  106693. * @param input Input polygon data
  106694. * @returns the parsed points
  106695. */
  106696. static Parse(input: string): Vector2[];
  106697. /**
  106698. * Starts building a polygon from x and y coordinates
  106699. * @param x x coordinate
  106700. * @param y y coordinate
  106701. * @returns the started path2
  106702. */
  106703. static StartingAt(x: number, y: number): Path2;
  106704. }
  106705. /**
  106706. * Builds a polygon
  106707. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  106708. */
  106709. export class PolygonMeshBuilder {
  106710. private _points;
  106711. private _outlinepoints;
  106712. private _holes;
  106713. private _name;
  106714. private _scene;
  106715. private _epoints;
  106716. private _eholes;
  106717. private _addToepoint;
  106718. /**
  106719. * Babylon reference to the earcut plugin.
  106720. */
  106721. bjsEarcut: any;
  106722. /**
  106723. * Creates a PolygonMeshBuilder
  106724. * @param name name of the builder
  106725. * @param contours Path of the polygon
  106726. * @param scene scene to add to when creating the mesh
  106727. * @param earcutInjection can be used to inject your own earcut reference
  106728. */
  106729. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  106730. /**
  106731. * Adds a whole within the polygon
  106732. * @param hole Array of points defining the hole
  106733. * @returns this
  106734. */
  106735. addHole(hole: Vector2[]): PolygonMeshBuilder;
  106736. /**
  106737. * Creates the polygon
  106738. * @param updatable If the mesh should be updatable
  106739. * @param depth The depth of the mesh created
  106740. * @returns the created mesh
  106741. */
  106742. build(updatable?: boolean, depth?: number): Mesh;
  106743. /**
  106744. * Creates the polygon
  106745. * @param depth The depth of the mesh created
  106746. * @returns the created VertexData
  106747. */
  106748. buildVertexData(depth?: number): VertexData;
  106749. /**
  106750. * Adds a side to the polygon
  106751. * @param positions points that make the polygon
  106752. * @param normals normals of the polygon
  106753. * @param uvs uvs of the polygon
  106754. * @param indices indices of the polygon
  106755. * @param bounds bounds of the polygon
  106756. * @param points points of the polygon
  106757. * @param depth depth of the polygon
  106758. * @param flip flip of the polygon
  106759. */
  106760. private addSide;
  106761. }
  106762. }
  106763. declare module BABYLON {
  106764. /**
  106765. * Class containing static functions to help procedurally build meshes
  106766. */
  106767. export class PolygonBuilder {
  106768. /**
  106769. * Creates a polygon mesh
  106770. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  106771. * * 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
  106772. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106774. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  106775. * * Remember you can only change the shape positions, not their number when updating a polygon
  106776. * @param name defines the name of the mesh
  106777. * @param options defines the options used to create the mesh
  106778. * @param scene defines the hosting scene
  106779. * @param earcutInjection can be used to inject your own earcut reference
  106780. * @returns the polygon mesh
  106781. */
  106782. static CreatePolygon(name: string, options: {
  106783. shape: Vector3[];
  106784. holes?: Vector3[][];
  106785. depth?: number;
  106786. faceUV?: Vector4[];
  106787. faceColors?: Color4[];
  106788. updatable?: boolean;
  106789. sideOrientation?: number;
  106790. frontUVs?: Vector4;
  106791. backUVs?: Vector4;
  106792. }, scene: Scene, earcutInjection?: any): Mesh;
  106793. /**
  106794. * Creates an extruded polygon mesh, with depth in the Y direction.
  106795. * * 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)
  106796. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  106797. * @param name defines the name of the mesh
  106798. * @param options defines the options used to create the mesh
  106799. * @param scene defines the hosting scene
  106800. * @param earcutInjection can be used to inject your own earcut reference
  106801. * @returns the polygon mesh
  106802. */
  106803. static ExtrudePolygon(name: string, options: {
  106804. shape: Vector3[];
  106805. holes?: Vector3[][];
  106806. depth?: number;
  106807. faceUV?: Vector4[];
  106808. faceColors?: Color4[];
  106809. updatable?: boolean;
  106810. sideOrientation?: number;
  106811. frontUVs?: Vector4;
  106812. backUVs?: Vector4;
  106813. }, scene: Scene, earcutInjection?: any): Mesh;
  106814. }
  106815. }
  106816. declare module BABYLON {
  106817. /**
  106818. * Class containing static functions to help procedurally build meshes
  106819. */
  106820. export class ShapeBuilder {
  106821. /**
  106822. * 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.
  106823. * * 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.
  106824. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106825. * * 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.
  106826. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  106827. * * 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
  106828. * * 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
  106829. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  106830. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106831. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106832. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  106833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106834. * @param name defines the name of the mesh
  106835. * @param options defines the options used to create the mesh
  106836. * @param scene defines the hosting scene
  106837. * @returns the extruded shape mesh
  106838. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106839. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106840. */
  106841. static ExtrudeShape(name: string, options: {
  106842. shape: Vector3[];
  106843. path: Vector3[];
  106844. scale?: number;
  106845. rotation?: number;
  106846. cap?: number;
  106847. updatable?: boolean;
  106848. sideOrientation?: number;
  106849. frontUVs?: Vector4;
  106850. backUVs?: Vector4;
  106851. instance?: Mesh;
  106852. invertUV?: boolean;
  106853. }, scene?: Nullable<Scene>): Mesh;
  106854. /**
  106855. * Creates an custom extruded shape mesh.
  106856. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  106857. * * 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.
  106858. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  106859. * * 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
  106860. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  106861. * * 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
  106862. * * It must returns a float value that will be the scale value applied to the shape on each path point
  106863. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  106864. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  106865. * * 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
  106866. * * 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
  106867. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  106868. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106869. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106870. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106872. * @param name defines the name of the mesh
  106873. * @param options defines the options used to create the mesh
  106874. * @param scene defines the hosting scene
  106875. * @returns the custom extruded shape mesh
  106876. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  106877. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106878. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106879. */
  106880. static ExtrudeShapeCustom(name: string, options: {
  106881. shape: Vector3[];
  106882. path: Vector3[];
  106883. scaleFunction?: any;
  106884. rotationFunction?: any;
  106885. ribbonCloseArray?: boolean;
  106886. ribbonClosePath?: boolean;
  106887. cap?: number;
  106888. updatable?: boolean;
  106889. sideOrientation?: number;
  106890. frontUVs?: Vector4;
  106891. backUVs?: Vector4;
  106892. instance?: Mesh;
  106893. invertUV?: boolean;
  106894. }, scene: Scene): Mesh;
  106895. private static _ExtrudeShapeGeneric;
  106896. }
  106897. }
  106898. declare module BABYLON {
  106899. /**
  106900. * Class containing static functions to help procedurally build meshes
  106901. */
  106902. export class LatheBuilder {
  106903. /**
  106904. * Creates lathe mesh.
  106905. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  106906. * * 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
  106907. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  106908. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  106909. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  106910. * * 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
  106911. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  106912. * * 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
  106913. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106914. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106915. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106917. * @param name defines the name of the mesh
  106918. * @param options defines the options used to create the mesh
  106919. * @param scene defines the hosting scene
  106920. * @returns the lathe mesh
  106921. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  106922. */
  106923. static CreateLathe(name: string, options: {
  106924. shape: Vector3[];
  106925. radius?: number;
  106926. tessellation?: number;
  106927. clip?: number;
  106928. arc?: number;
  106929. closed?: boolean;
  106930. updatable?: boolean;
  106931. sideOrientation?: number;
  106932. frontUVs?: Vector4;
  106933. backUVs?: Vector4;
  106934. cap?: number;
  106935. invertUV?: boolean;
  106936. }, scene: Scene): Mesh;
  106937. }
  106938. }
  106939. declare module BABYLON {
  106940. /**
  106941. * Class containing static functions to help procedurally build meshes
  106942. */
  106943. export class TubeBuilder {
  106944. /**
  106945. * Creates a tube mesh.
  106946. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  106947. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  106948. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  106949. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  106950. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  106951. * * 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)
  106952. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  106953. * * 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
  106954. * * 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
  106955. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106956. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106957. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  106958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106959. * @param name defines the name of the mesh
  106960. * @param options defines the options used to create the mesh
  106961. * @param scene defines the hosting scene
  106962. * @returns the tube mesh
  106963. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106964. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  106965. */
  106966. static CreateTube(name: string, options: {
  106967. path: Vector3[];
  106968. radius?: number;
  106969. tessellation?: number;
  106970. radiusFunction?: {
  106971. (i: number, distance: number): number;
  106972. };
  106973. cap?: number;
  106974. arc?: number;
  106975. updatable?: boolean;
  106976. sideOrientation?: number;
  106977. frontUVs?: Vector4;
  106978. backUVs?: Vector4;
  106979. instance?: Mesh;
  106980. invertUV?: boolean;
  106981. }, scene: Scene): Mesh;
  106982. }
  106983. }
  106984. declare module BABYLON {
  106985. /**
  106986. * Class containing static functions to help procedurally build meshes
  106987. */
  106988. export class IcoSphereBuilder {
  106989. /**
  106990. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  106991. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  106992. * * 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`)
  106993. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  106994. * * 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
  106995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106996. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106998. * @param name defines the name of the mesh
  106999. * @param options defines the options used to create the mesh
  107000. * @param scene defines the hosting scene
  107001. * @returns the icosahedron mesh
  107002. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  107003. */
  107004. static CreateIcoSphere(name: string, options: {
  107005. radius?: number;
  107006. radiusX?: number;
  107007. radiusY?: number;
  107008. radiusZ?: number;
  107009. flat?: boolean;
  107010. subdivisions?: number;
  107011. sideOrientation?: number;
  107012. frontUVs?: Vector4;
  107013. backUVs?: Vector4;
  107014. updatable?: boolean;
  107015. }, scene: Scene): Mesh;
  107016. }
  107017. }
  107018. declare module BABYLON {
  107019. /**
  107020. * Class containing static functions to help procedurally build meshes
  107021. */
  107022. export class DecalBuilder {
  107023. /**
  107024. * Creates a decal mesh.
  107025. * 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
  107026. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  107027. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  107028. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  107029. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  107030. * @param name defines the name of the mesh
  107031. * @param sourceMesh defines the mesh where the decal must be applied
  107032. * @param options defines the options used to create the mesh
  107033. * @param scene defines the hosting scene
  107034. * @returns the decal mesh
  107035. * @see https://doc.babylonjs.com/how_to/decals
  107036. */
  107037. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  107038. position?: Vector3;
  107039. normal?: Vector3;
  107040. size?: Vector3;
  107041. angle?: number;
  107042. }): Mesh;
  107043. }
  107044. }
  107045. declare module BABYLON {
  107046. /**
  107047. * Class containing static functions to help procedurally build meshes
  107048. */
  107049. export class MeshBuilder {
  107050. /**
  107051. * Creates a box mesh
  107052. * * The parameter `size` sets the size (float) of each box side (default 1)
  107053. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  107054. * * 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)
  107055. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  107056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107057. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107059. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  107060. * @param name defines the name of the mesh
  107061. * @param options defines the options used to create the mesh
  107062. * @param scene defines the hosting scene
  107063. * @returns the box mesh
  107064. */
  107065. static CreateBox(name: string, options: {
  107066. size?: number;
  107067. width?: number;
  107068. height?: number;
  107069. depth?: number;
  107070. faceUV?: Vector4[];
  107071. faceColors?: Color4[];
  107072. sideOrientation?: number;
  107073. frontUVs?: Vector4;
  107074. backUVs?: Vector4;
  107075. updatable?: boolean;
  107076. }, scene?: Nullable<Scene>): Mesh;
  107077. /**
  107078. * Creates a sphere mesh
  107079. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  107080. * * 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`)
  107081. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  107082. * * 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
  107083. * * 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)
  107084. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107085. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107087. * @param name defines the name of the mesh
  107088. * @param options defines the options used to create the mesh
  107089. * @param scene defines the hosting scene
  107090. * @returns the sphere mesh
  107091. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  107092. */
  107093. static CreateSphere(name: string, options: {
  107094. segments?: number;
  107095. diameter?: number;
  107096. diameterX?: number;
  107097. diameterY?: number;
  107098. diameterZ?: number;
  107099. arc?: number;
  107100. slice?: number;
  107101. sideOrientation?: number;
  107102. frontUVs?: Vector4;
  107103. backUVs?: Vector4;
  107104. updatable?: boolean;
  107105. }, scene: any): Mesh;
  107106. /**
  107107. * Creates a plane polygonal mesh. By default, this is a disc
  107108. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  107109. * * 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
  107110. * * 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
  107111. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107112. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107114. * @param name defines the name of the mesh
  107115. * @param options defines the options used to create the mesh
  107116. * @param scene defines the hosting scene
  107117. * @returns the plane polygonal mesh
  107118. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  107119. */
  107120. static CreateDisc(name: string, options: {
  107121. radius?: number;
  107122. tessellation?: number;
  107123. arc?: number;
  107124. updatable?: boolean;
  107125. sideOrientation?: number;
  107126. frontUVs?: Vector4;
  107127. backUVs?: Vector4;
  107128. }, scene?: Nullable<Scene>): Mesh;
  107129. /**
  107130. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  107131. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  107132. * * 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`)
  107133. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  107134. * * 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
  107135. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107136. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107138. * @param name defines the name of the mesh
  107139. * @param options defines the options used to create the mesh
  107140. * @param scene defines the hosting scene
  107141. * @returns the icosahedron mesh
  107142. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  107143. */
  107144. static CreateIcoSphere(name: string, options: {
  107145. radius?: number;
  107146. radiusX?: number;
  107147. radiusY?: number;
  107148. radiusZ?: number;
  107149. flat?: boolean;
  107150. subdivisions?: number;
  107151. sideOrientation?: number;
  107152. frontUVs?: Vector4;
  107153. backUVs?: Vector4;
  107154. updatable?: boolean;
  107155. }, scene: Scene): Mesh;
  107156. /**
  107157. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107158. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  107159. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  107160. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  107161. * * 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
  107162. * * 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
  107163. * * 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
  107164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107165. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107166. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107167. * * 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
  107168. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  107169. * * 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
  107170. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  107171. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107172. * @param name defines the name of the mesh
  107173. * @param options defines the options used to create the mesh
  107174. * @param scene defines the hosting scene
  107175. * @returns the ribbon mesh
  107176. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  107177. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107178. */
  107179. static CreateRibbon(name: string, options: {
  107180. pathArray: Vector3[][];
  107181. closeArray?: boolean;
  107182. closePath?: boolean;
  107183. offset?: number;
  107184. updatable?: boolean;
  107185. sideOrientation?: number;
  107186. frontUVs?: Vector4;
  107187. backUVs?: Vector4;
  107188. instance?: Mesh;
  107189. invertUV?: boolean;
  107190. uvs?: Vector2[];
  107191. colors?: Color4[];
  107192. }, scene?: Nullable<Scene>): Mesh;
  107193. /**
  107194. * Creates a cylinder or a cone mesh
  107195. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  107196. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  107197. * * 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.
  107198. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  107199. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  107200. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  107201. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  107202. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  107203. * * 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).
  107204. * * 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
  107205. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  107206. * * 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
  107207. * * 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.
  107208. * * If `enclose` is false, a ring surface is one element.
  107209. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  107210. * * 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
  107211. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107212. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107214. * @param name defines the name of the mesh
  107215. * @param options defines the options used to create the mesh
  107216. * @param scene defines the hosting scene
  107217. * @returns the cylinder mesh
  107218. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  107219. */
  107220. static CreateCylinder(name: string, options: {
  107221. height?: number;
  107222. diameterTop?: number;
  107223. diameterBottom?: number;
  107224. diameter?: number;
  107225. tessellation?: number;
  107226. subdivisions?: number;
  107227. arc?: number;
  107228. faceColors?: Color4[];
  107229. faceUV?: Vector4[];
  107230. updatable?: boolean;
  107231. hasRings?: boolean;
  107232. enclose?: boolean;
  107233. sideOrientation?: number;
  107234. frontUVs?: Vector4;
  107235. backUVs?: Vector4;
  107236. }, scene: any): Mesh;
  107237. /**
  107238. * Creates a torus mesh
  107239. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  107240. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  107241. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  107242. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107243. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107245. * @param name defines the name of the mesh
  107246. * @param options defines the options used to create the mesh
  107247. * @param scene defines the hosting scene
  107248. * @returns the torus mesh
  107249. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  107250. */
  107251. static CreateTorus(name: string, options: {
  107252. diameter?: number;
  107253. thickness?: number;
  107254. tessellation?: number;
  107255. updatable?: boolean;
  107256. sideOrientation?: number;
  107257. frontUVs?: Vector4;
  107258. backUVs?: Vector4;
  107259. }, scene: any): Mesh;
  107260. /**
  107261. * Creates a torus knot mesh
  107262. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  107263. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  107264. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  107265. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  107266. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107267. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107269. * @param name defines the name of the mesh
  107270. * @param options defines the options used to create the mesh
  107271. * @param scene defines the hosting scene
  107272. * @returns the torus knot mesh
  107273. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  107274. */
  107275. static CreateTorusKnot(name: string, options: {
  107276. radius?: number;
  107277. tube?: number;
  107278. radialSegments?: number;
  107279. tubularSegments?: number;
  107280. p?: number;
  107281. q?: number;
  107282. updatable?: boolean;
  107283. sideOrientation?: number;
  107284. frontUVs?: Vector4;
  107285. backUVs?: Vector4;
  107286. }, scene: any): Mesh;
  107287. /**
  107288. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  107289. * * 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
  107290. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  107291. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  107292. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  107293. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  107294. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  107295. * * 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
  107296. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  107297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107298. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  107299. * @param name defines the name of the new line system
  107300. * @param options defines the options used to create the line system
  107301. * @param scene defines the hosting scene
  107302. * @returns a new line system mesh
  107303. */
  107304. static CreateLineSystem(name: string, options: {
  107305. lines: Vector3[][];
  107306. updatable?: boolean;
  107307. instance?: Nullable<LinesMesh>;
  107308. colors?: Nullable<Color4[][]>;
  107309. useVertexAlpha?: boolean;
  107310. }, scene: Nullable<Scene>): LinesMesh;
  107311. /**
  107312. * Creates a line mesh
  107313. * 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
  107314. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  107315. * * The parameter `points` is an array successive Vector3
  107316. * * 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
  107317. * * The optional parameter `colors` is an array of successive Color4, one per line point
  107318. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  107319. * * When updating an instance, remember that only point positions can change, not the number of points
  107320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107321. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  107322. * @param name defines the name of the new line system
  107323. * @param options defines the options used to create the line system
  107324. * @param scene defines the hosting scene
  107325. * @returns a new line mesh
  107326. */
  107327. static CreateLines(name: string, options: {
  107328. points: Vector3[];
  107329. updatable?: boolean;
  107330. instance?: Nullable<LinesMesh>;
  107331. colors?: Color4[];
  107332. useVertexAlpha?: boolean;
  107333. }, scene?: Nullable<Scene>): LinesMesh;
  107334. /**
  107335. * Creates a dashed line mesh
  107336. * * 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
  107337. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  107338. * * The parameter `points` is an array successive Vector3
  107339. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  107340. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  107341. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  107342. * * 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
  107343. * * When updating an instance, remember that only point positions can change, not the number of points
  107344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107345. * @param name defines the name of the mesh
  107346. * @param options defines the options used to create the mesh
  107347. * @param scene defines the hosting scene
  107348. * @returns the dashed line mesh
  107349. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  107350. */
  107351. static CreateDashedLines(name: string, options: {
  107352. points: Vector3[];
  107353. dashSize?: number;
  107354. gapSize?: number;
  107355. dashNb?: number;
  107356. updatable?: boolean;
  107357. instance?: LinesMesh;
  107358. }, scene?: Nullable<Scene>): LinesMesh;
  107359. /**
  107360. * 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.
  107361. * * 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.
  107362. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107363. * * 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.
  107364. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  107365. * * 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
  107366. * * 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
  107367. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  107368. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107369. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107370. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  107371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107372. * @param name defines the name of the mesh
  107373. * @param options defines the options used to create the mesh
  107374. * @param scene defines the hosting scene
  107375. * @returns the extruded shape mesh
  107376. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107377. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107378. */
  107379. static ExtrudeShape(name: string, options: {
  107380. shape: Vector3[];
  107381. path: Vector3[];
  107382. scale?: number;
  107383. rotation?: number;
  107384. cap?: number;
  107385. updatable?: boolean;
  107386. sideOrientation?: number;
  107387. frontUVs?: Vector4;
  107388. backUVs?: Vector4;
  107389. instance?: Mesh;
  107390. invertUV?: boolean;
  107391. }, scene?: Nullable<Scene>): Mesh;
  107392. /**
  107393. * Creates an custom extruded shape mesh.
  107394. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  107395. * * 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.
  107396. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107397. * * 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
  107398. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  107399. * * 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
  107400. * * It must returns a float value that will be the scale value applied to the shape on each path point
  107401. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107402. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  107403. * * 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
  107404. * * 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
  107405. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  107406. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107407. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107408. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107410. * @param name defines the name of the mesh
  107411. * @param options defines the options used to create the mesh
  107412. * @param scene defines the hosting scene
  107413. * @returns the custom extruded shape mesh
  107414. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  107415. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107416. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107417. */
  107418. static ExtrudeShapeCustom(name: string, options: {
  107419. shape: Vector3[];
  107420. path: Vector3[];
  107421. scaleFunction?: any;
  107422. rotationFunction?: any;
  107423. ribbonCloseArray?: boolean;
  107424. ribbonClosePath?: boolean;
  107425. cap?: number;
  107426. updatable?: boolean;
  107427. sideOrientation?: number;
  107428. frontUVs?: Vector4;
  107429. backUVs?: Vector4;
  107430. instance?: Mesh;
  107431. invertUV?: boolean;
  107432. }, scene: Scene): Mesh;
  107433. /**
  107434. * Creates lathe mesh.
  107435. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  107436. * * 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
  107437. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  107438. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  107439. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  107440. * * 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
  107441. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  107442. * * 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
  107443. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107444. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107445. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107447. * @param name defines the name of the mesh
  107448. * @param options defines the options used to create the mesh
  107449. * @param scene defines the hosting scene
  107450. * @returns the lathe mesh
  107451. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  107452. */
  107453. static CreateLathe(name: string, options: {
  107454. shape: Vector3[];
  107455. radius?: number;
  107456. tessellation?: number;
  107457. clip?: number;
  107458. arc?: number;
  107459. closed?: boolean;
  107460. updatable?: boolean;
  107461. sideOrientation?: number;
  107462. frontUVs?: Vector4;
  107463. backUVs?: Vector4;
  107464. cap?: number;
  107465. invertUV?: boolean;
  107466. }, scene: Scene): Mesh;
  107467. /**
  107468. * Creates a plane mesh
  107469. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  107470. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  107471. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  107472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107473. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107475. * @param name defines the name of the mesh
  107476. * @param options defines the options used to create the mesh
  107477. * @param scene defines the hosting scene
  107478. * @returns the plane mesh
  107479. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  107480. */
  107481. static CreatePlane(name: string, options: {
  107482. size?: number;
  107483. width?: number;
  107484. height?: number;
  107485. sideOrientation?: number;
  107486. frontUVs?: Vector4;
  107487. backUVs?: Vector4;
  107488. updatable?: boolean;
  107489. sourcePlane?: Plane;
  107490. }, scene: Scene): Mesh;
  107491. /**
  107492. * Creates a ground mesh
  107493. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  107494. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  107495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107496. * @param name defines the name of the mesh
  107497. * @param options defines the options used to create the mesh
  107498. * @param scene defines the hosting scene
  107499. * @returns the ground mesh
  107500. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  107501. */
  107502. static CreateGround(name: string, options: {
  107503. width?: number;
  107504. height?: number;
  107505. subdivisions?: number;
  107506. subdivisionsX?: number;
  107507. subdivisionsY?: number;
  107508. updatable?: boolean;
  107509. }, scene: any): Mesh;
  107510. /**
  107511. * Creates a tiled ground mesh
  107512. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  107513. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  107514. * * 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
  107515. * * 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
  107516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107517. * @param name defines the name of the mesh
  107518. * @param options defines the options used to create the mesh
  107519. * @param scene defines the hosting scene
  107520. * @returns the tiled ground mesh
  107521. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  107522. */
  107523. static CreateTiledGround(name: string, options: {
  107524. xmin: number;
  107525. zmin: number;
  107526. xmax: number;
  107527. zmax: number;
  107528. subdivisions?: {
  107529. w: number;
  107530. h: number;
  107531. };
  107532. precision?: {
  107533. w: number;
  107534. h: number;
  107535. };
  107536. updatable?: boolean;
  107537. }, scene: Scene): Mesh;
  107538. /**
  107539. * Creates a ground mesh from a height map
  107540. * * The parameter `url` sets the URL of the height map image resource.
  107541. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  107542. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  107543. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  107544. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  107545. * * 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.
  107546. * * 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).
  107547. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  107548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107549. * @param name defines the name of the mesh
  107550. * @param url defines the url to the height map
  107551. * @param options defines the options used to create the mesh
  107552. * @param scene defines the hosting scene
  107553. * @returns the ground mesh
  107554. * @see https://doc.babylonjs.com/babylon101/height_map
  107555. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  107556. */
  107557. static CreateGroundFromHeightMap(name: string, url: string, options: {
  107558. width?: number;
  107559. height?: number;
  107560. subdivisions?: number;
  107561. minHeight?: number;
  107562. maxHeight?: number;
  107563. colorFilter?: Color3;
  107564. alphaFilter?: number;
  107565. updatable?: boolean;
  107566. onReady?: (mesh: GroundMesh) => void;
  107567. }, scene: Scene): GroundMesh;
  107568. /**
  107569. * Creates a polygon mesh
  107570. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  107571. * * 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
  107572. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107574. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  107575. * * Remember you can only change the shape positions, not their number when updating a polygon
  107576. * @param name defines the name of the mesh
  107577. * @param options defines the options used to create the mesh
  107578. * @param scene defines the hosting scene
  107579. * @param earcutInjection can be used to inject your own earcut reference
  107580. * @returns the polygon mesh
  107581. */
  107582. static CreatePolygon(name: string, options: {
  107583. shape: Vector3[];
  107584. holes?: Vector3[][];
  107585. depth?: number;
  107586. faceUV?: Vector4[];
  107587. faceColors?: Color4[];
  107588. updatable?: boolean;
  107589. sideOrientation?: number;
  107590. frontUVs?: Vector4;
  107591. backUVs?: Vector4;
  107592. }, scene: Scene, earcutInjection?: any): Mesh;
  107593. /**
  107594. * Creates an extruded polygon mesh, with depth in the Y direction.
  107595. * * 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)
  107596. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  107597. * @param name defines the name of the mesh
  107598. * @param options defines the options used to create the mesh
  107599. * @param scene defines the hosting scene
  107600. * @param earcutInjection can be used to inject your own earcut reference
  107601. * @returns the polygon mesh
  107602. */
  107603. static ExtrudePolygon(name: string, options: {
  107604. shape: Vector3[];
  107605. holes?: Vector3[][];
  107606. depth?: number;
  107607. faceUV?: Vector4[];
  107608. faceColors?: Color4[];
  107609. updatable?: boolean;
  107610. sideOrientation?: number;
  107611. frontUVs?: Vector4;
  107612. backUVs?: Vector4;
  107613. }, scene: Scene, earcutInjection?: any): Mesh;
  107614. /**
  107615. * Creates a tube mesh.
  107616. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107617. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  107618. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  107619. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  107620. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  107621. * * 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)
  107622. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  107623. * * 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
  107624. * * 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
  107625. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107626. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107627. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107629. * @param name defines the name of the mesh
  107630. * @param options defines the options used to create the mesh
  107631. * @param scene defines the hosting scene
  107632. * @returns the tube mesh
  107633. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107634. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  107635. */
  107636. static CreateTube(name: string, options: {
  107637. path: Vector3[];
  107638. radius?: number;
  107639. tessellation?: number;
  107640. radiusFunction?: {
  107641. (i: number, distance: number): number;
  107642. };
  107643. cap?: number;
  107644. arc?: number;
  107645. updatable?: boolean;
  107646. sideOrientation?: number;
  107647. frontUVs?: Vector4;
  107648. backUVs?: Vector4;
  107649. instance?: Mesh;
  107650. invertUV?: boolean;
  107651. }, scene: Scene): Mesh;
  107652. /**
  107653. * Creates a polyhedron mesh
  107654. * * 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
  107655. * * The parameter `size` (positive float, default 1) sets the polygon size
  107656. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  107657. * * 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`
  107658. * * 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
  107659. * * 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)`)
  107660. * * 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
  107661. * * 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
  107662. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107663. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107665. * @param name defines the name of the mesh
  107666. * @param options defines the options used to create the mesh
  107667. * @param scene defines the hosting scene
  107668. * @returns the polyhedron mesh
  107669. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  107670. */
  107671. static CreatePolyhedron(name: string, options: {
  107672. type?: number;
  107673. size?: number;
  107674. sizeX?: number;
  107675. sizeY?: number;
  107676. sizeZ?: number;
  107677. custom?: any;
  107678. faceUV?: Vector4[];
  107679. faceColors?: Color4[];
  107680. flat?: boolean;
  107681. updatable?: boolean;
  107682. sideOrientation?: number;
  107683. frontUVs?: Vector4;
  107684. backUVs?: Vector4;
  107685. }, scene: Scene): Mesh;
  107686. /**
  107687. * Creates a decal mesh.
  107688. * 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
  107689. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  107690. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  107691. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  107692. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  107693. * @param name defines the name of the mesh
  107694. * @param sourceMesh defines the mesh where the decal must be applied
  107695. * @param options defines the options used to create the mesh
  107696. * @param scene defines the hosting scene
  107697. * @returns the decal mesh
  107698. * @see https://doc.babylonjs.com/how_to/decals
  107699. */
  107700. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  107701. position?: Vector3;
  107702. normal?: Vector3;
  107703. size?: Vector3;
  107704. angle?: number;
  107705. }): Mesh;
  107706. }
  107707. }
  107708. declare module BABYLON {
  107709. /**
  107710. * A simplifier interface for future simplification implementations
  107711. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107712. */
  107713. export interface ISimplifier {
  107714. /**
  107715. * Simplification of a given mesh according to the given settings.
  107716. * Since this requires computation, it is assumed that the function runs async.
  107717. * @param settings The settings of the simplification, including quality and distance
  107718. * @param successCallback A callback that will be called after the mesh was simplified.
  107719. * @param errorCallback in case of an error, this callback will be called. optional.
  107720. */
  107721. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  107722. }
  107723. /**
  107724. * Expected simplification settings.
  107725. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  107726. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107727. */
  107728. export interface ISimplificationSettings {
  107729. /**
  107730. * Gets or sets the expected quality
  107731. */
  107732. quality: number;
  107733. /**
  107734. * Gets or sets the distance when this optimized version should be used
  107735. */
  107736. distance: number;
  107737. /**
  107738. * Gets an already optimized mesh
  107739. */
  107740. optimizeMesh?: boolean;
  107741. }
  107742. /**
  107743. * Class used to specify simplification options
  107744. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107745. */
  107746. export class SimplificationSettings implements ISimplificationSettings {
  107747. /** expected quality */
  107748. quality: number;
  107749. /** distance when this optimized version should be used */
  107750. distance: number;
  107751. /** already optimized mesh */
  107752. optimizeMesh?: boolean | undefined;
  107753. /**
  107754. * Creates a SimplificationSettings
  107755. * @param quality expected quality
  107756. * @param distance distance when this optimized version should be used
  107757. * @param optimizeMesh already optimized mesh
  107758. */
  107759. constructor(
  107760. /** expected quality */
  107761. quality: number,
  107762. /** distance when this optimized version should be used */
  107763. distance: number,
  107764. /** already optimized mesh */
  107765. optimizeMesh?: boolean | undefined);
  107766. }
  107767. /**
  107768. * Interface used to define a simplification task
  107769. */
  107770. export interface ISimplificationTask {
  107771. /**
  107772. * Array of settings
  107773. */
  107774. settings: Array<ISimplificationSettings>;
  107775. /**
  107776. * Simplification type
  107777. */
  107778. simplificationType: SimplificationType;
  107779. /**
  107780. * Mesh to simplify
  107781. */
  107782. mesh: Mesh;
  107783. /**
  107784. * Callback called on success
  107785. */
  107786. successCallback?: () => void;
  107787. /**
  107788. * Defines if parallel processing can be used
  107789. */
  107790. parallelProcessing: boolean;
  107791. }
  107792. /**
  107793. * Queue used to order the simplification tasks
  107794. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107795. */
  107796. export class SimplificationQueue {
  107797. private _simplificationArray;
  107798. /**
  107799. * Gets a boolean indicating that the process is still running
  107800. */
  107801. running: boolean;
  107802. /**
  107803. * Creates a new queue
  107804. */
  107805. constructor();
  107806. /**
  107807. * Adds a new simplification task
  107808. * @param task defines a task to add
  107809. */
  107810. addTask(task: ISimplificationTask): void;
  107811. /**
  107812. * Execute next task
  107813. */
  107814. executeNext(): void;
  107815. /**
  107816. * Execute a simplification task
  107817. * @param task defines the task to run
  107818. */
  107819. runSimplification(task: ISimplificationTask): void;
  107820. private getSimplifier;
  107821. }
  107822. /**
  107823. * The implemented types of simplification
  107824. * At the moment only Quadratic Error Decimation is implemented
  107825. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107826. */
  107827. export enum SimplificationType {
  107828. /** Quadratic error decimation */
  107829. QUADRATIC = 0
  107830. }
  107831. }
  107832. declare module BABYLON {
  107833. interface Scene {
  107834. /** @hidden (Backing field) */
  107835. _simplificationQueue: SimplificationQueue;
  107836. /**
  107837. * Gets or sets the simplification queue attached to the scene
  107838. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  107839. */
  107840. simplificationQueue: SimplificationQueue;
  107841. }
  107842. interface Mesh {
  107843. /**
  107844. * Simplify the mesh according to the given array of settings.
  107845. * Function will return immediately and will simplify async
  107846. * @param settings a collection of simplification settings
  107847. * @param parallelProcessing should all levels calculate parallel or one after the other
  107848. * @param simplificationType the type of simplification to run
  107849. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  107850. * @returns the current mesh
  107851. */
  107852. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  107853. }
  107854. /**
  107855. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  107856. * created in a scene
  107857. */
  107858. export class SimplicationQueueSceneComponent implements ISceneComponent {
  107859. /**
  107860. * The component name helpfull to identify the component in the list of scene components.
  107861. */
  107862. readonly name: string;
  107863. /**
  107864. * The scene the component belongs to.
  107865. */
  107866. scene: Scene;
  107867. /**
  107868. * Creates a new instance of the component for the given scene
  107869. * @param scene Defines the scene to register the component in
  107870. */
  107871. constructor(scene: Scene);
  107872. /**
  107873. * Registers the component in a given scene
  107874. */
  107875. register(): void;
  107876. /**
  107877. * Rebuilds the elements related to this component in case of
  107878. * context lost for instance.
  107879. */
  107880. rebuild(): void;
  107881. /**
  107882. * Disposes the component and the associated ressources
  107883. */
  107884. dispose(): void;
  107885. private _beforeCameraUpdate;
  107886. }
  107887. }
  107888. declare module BABYLON {
  107889. /**
  107890. * Class used to enable access to IndexedDB
  107891. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  107892. */
  107893. export class Database implements IOfflineProvider {
  107894. private _callbackManifestChecked;
  107895. private _currentSceneUrl;
  107896. private _db;
  107897. private _enableSceneOffline;
  107898. private _enableTexturesOffline;
  107899. private _manifestVersionFound;
  107900. private _mustUpdateRessources;
  107901. private _hasReachedQuota;
  107902. private _isSupported;
  107903. private _idbFactory;
  107904. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  107905. private static IsUASupportingBlobStorage;
  107906. /**
  107907. * Gets a boolean indicating if Database storate is enabled (off by default)
  107908. */
  107909. static IDBStorageEnabled: boolean;
  107910. /**
  107911. * Gets a boolean indicating if scene must be saved in the database
  107912. */
  107913. readonly enableSceneOffline: boolean;
  107914. /**
  107915. * Gets a boolean indicating if textures must be saved in the database
  107916. */
  107917. readonly enableTexturesOffline: boolean;
  107918. /**
  107919. * Creates a new Database
  107920. * @param urlToScene defines the url to load the scene
  107921. * @param callbackManifestChecked defines the callback to use when manifest is checked
  107922. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  107923. */
  107924. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  107925. private static _ParseURL;
  107926. private static _ReturnFullUrlLocation;
  107927. private _checkManifestFile;
  107928. /**
  107929. * Open the database and make it available
  107930. * @param successCallback defines the callback to call on success
  107931. * @param errorCallback defines the callback to call on error
  107932. */
  107933. open(successCallback: () => void, errorCallback: () => void): void;
  107934. /**
  107935. * Loads an image from the database
  107936. * @param url defines the url to load from
  107937. * @param image defines the target DOM image
  107938. */
  107939. loadImage(url: string, image: HTMLImageElement): void;
  107940. private _loadImageFromDBAsync;
  107941. private _saveImageIntoDBAsync;
  107942. private _checkVersionFromDB;
  107943. private _loadVersionFromDBAsync;
  107944. private _saveVersionIntoDBAsync;
  107945. /**
  107946. * Loads a file from database
  107947. * @param url defines the URL to load from
  107948. * @param sceneLoaded defines a callback to call on success
  107949. * @param progressCallBack defines a callback to call when progress changed
  107950. * @param errorCallback defines a callback to call on error
  107951. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  107952. */
  107953. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  107954. private _loadFileAsync;
  107955. private _saveFileAsync;
  107956. /**
  107957. * Validates if xhr data is correct
  107958. * @param xhr defines the request to validate
  107959. * @param dataType defines the expected data type
  107960. * @returns true if data is correct
  107961. */
  107962. private static _ValidateXHRData;
  107963. }
  107964. }
  107965. declare module BABYLON {
  107966. /** @hidden */
  107967. export var gpuUpdateParticlesPixelShader: {
  107968. name: string;
  107969. shader: string;
  107970. };
  107971. }
  107972. declare module BABYLON {
  107973. /** @hidden */
  107974. export var gpuUpdateParticlesVertexShader: {
  107975. name: string;
  107976. shader: string;
  107977. };
  107978. }
  107979. declare module BABYLON {
  107980. /** @hidden */
  107981. export var clipPlaneFragmentDeclaration2: {
  107982. name: string;
  107983. shader: string;
  107984. };
  107985. }
  107986. declare module BABYLON {
  107987. /** @hidden */
  107988. export var gpuRenderParticlesPixelShader: {
  107989. name: string;
  107990. shader: string;
  107991. };
  107992. }
  107993. declare module BABYLON {
  107994. /** @hidden */
  107995. export var clipPlaneVertexDeclaration2: {
  107996. name: string;
  107997. shader: string;
  107998. };
  107999. }
  108000. declare module BABYLON {
  108001. /** @hidden */
  108002. export var gpuRenderParticlesVertexShader: {
  108003. name: string;
  108004. shader: string;
  108005. };
  108006. }
  108007. declare module BABYLON {
  108008. /**
  108009. * This represents a GPU particle system in Babylon
  108010. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  108011. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  108012. */
  108013. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  108014. /**
  108015. * The layer mask we are rendering the particles through.
  108016. */
  108017. layerMask: number;
  108018. private _capacity;
  108019. private _activeCount;
  108020. private _currentActiveCount;
  108021. private _accumulatedCount;
  108022. private _renderEffect;
  108023. private _updateEffect;
  108024. private _buffer0;
  108025. private _buffer1;
  108026. private _spriteBuffer;
  108027. private _updateVAO;
  108028. private _renderVAO;
  108029. private _targetIndex;
  108030. private _sourceBuffer;
  108031. private _targetBuffer;
  108032. private _engine;
  108033. private _currentRenderId;
  108034. private _started;
  108035. private _stopped;
  108036. private _timeDelta;
  108037. private _randomTexture;
  108038. private _randomTexture2;
  108039. private _attributesStrideSize;
  108040. private _updateEffectOptions;
  108041. private _randomTextureSize;
  108042. private _actualFrame;
  108043. private readonly _rawTextureWidth;
  108044. /**
  108045. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  108046. */
  108047. static readonly IsSupported: boolean;
  108048. /**
  108049. * An event triggered when the system is disposed.
  108050. */
  108051. onDisposeObservable: Observable<GPUParticleSystem>;
  108052. /**
  108053. * Gets the maximum number of particles active at the same time.
  108054. * @returns The max number of active particles.
  108055. */
  108056. getCapacity(): number;
  108057. /**
  108058. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  108059. * to override the particles.
  108060. */
  108061. forceDepthWrite: boolean;
  108062. /**
  108063. * Gets or set the number of active particles
  108064. */
  108065. activeParticleCount: number;
  108066. private _preWarmDone;
  108067. /**
  108068. * Is this system ready to be used/rendered
  108069. * @return true if the system is ready
  108070. */
  108071. isReady(): boolean;
  108072. /**
  108073. * Gets if the system has been started. (Note: this will still be true after stop is called)
  108074. * @returns True if it has been started, otherwise false.
  108075. */
  108076. isStarted(): boolean;
  108077. /**
  108078. * Starts the particle system and begins to emit
  108079. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  108080. */
  108081. start(delay?: number): void;
  108082. /**
  108083. * Stops the particle system.
  108084. */
  108085. stop(): void;
  108086. /**
  108087. * Remove all active particles
  108088. */
  108089. reset(): void;
  108090. /**
  108091. * Returns the string "GPUParticleSystem"
  108092. * @returns a string containing the class name
  108093. */
  108094. getClassName(): string;
  108095. private _colorGradientsTexture;
  108096. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  108097. /**
  108098. * Adds a new color gradient
  108099. * @param gradient defines the gradient to use (between 0 and 1)
  108100. * @param color1 defines the color to affect to the specified gradient
  108101. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  108102. * @returns the current particle system
  108103. */
  108104. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  108105. /**
  108106. * Remove a specific color gradient
  108107. * @param gradient defines the gradient to remove
  108108. * @returns the current particle system
  108109. */
  108110. removeColorGradient(gradient: number): GPUParticleSystem;
  108111. private _angularSpeedGradientsTexture;
  108112. private _sizeGradientsTexture;
  108113. private _velocityGradientsTexture;
  108114. private _limitVelocityGradientsTexture;
  108115. private _dragGradientsTexture;
  108116. private _addFactorGradient;
  108117. /**
  108118. * Adds a new size gradient
  108119. * @param gradient defines the gradient to use (between 0 and 1)
  108120. * @param factor defines the size factor to affect to the specified gradient
  108121. * @returns the current particle system
  108122. */
  108123. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  108124. /**
  108125. * Remove a specific size gradient
  108126. * @param gradient defines the gradient to remove
  108127. * @returns the current particle system
  108128. */
  108129. removeSizeGradient(gradient: number): GPUParticleSystem;
  108130. /**
  108131. * Adds a new angular speed gradient
  108132. * @param gradient defines the gradient to use (between 0 and 1)
  108133. * @param factor defines the angular speed to affect to the specified gradient
  108134. * @returns the current particle system
  108135. */
  108136. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  108137. /**
  108138. * Remove a specific angular speed gradient
  108139. * @param gradient defines the gradient to remove
  108140. * @returns the current particle system
  108141. */
  108142. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  108143. /**
  108144. * Adds a new velocity gradient
  108145. * @param gradient defines the gradient to use (between 0 and 1)
  108146. * @param factor defines the velocity to affect to the specified gradient
  108147. * @returns the current particle system
  108148. */
  108149. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  108150. /**
  108151. * Remove a specific velocity gradient
  108152. * @param gradient defines the gradient to remove
  108153. * @returns the current particle system
  108154. */
  108155. removeVelocityGradient(gradient: number): GPUParticleSystem;
  108156. /**
  108157. * Adds a new limit velocity gradient
  108158. * @param gradient defines the gradient to use (between 0 and 1)
  108159. * @param factor defines the limit velocity value to affect to the specified gradient
  108160. * @returns the current particle system
  108161. */
  108162. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  108163. /**
  108164. * Remove a specific limit velocity gradient
  108165. * @param gradient defines the gradient to remove
  108166. * @returns the current particle system
  108167. */
  108168. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  108169. /**
  108170. * Adds a new drag gradient
  108171. * @param gradient defines the gradient to use (between 0 and 1)
  108172. * @param factor defines the drag value to affect to the specified gradient
  108173. * @returns the current particle system
  108174. */
  108175. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  108176. /**
  108177. * Remove a specific drag gradient
  108178. * @param gradient defines the gradient to remove
  108179. * @returns the current particle system
  108180. */
  108181. removeDragGradient(gradient: number): GPUParticleSystem;
  108182. /**
  108183. * Not supported by GPUParticleSystem
  108184. * @param gradient defines the gradient to use (between 0 and 1)
  108185. * @param factor defines the emit rate value to affect to the specified gradient
  108186. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108187. * @returns the current particle system
  108188. */
  108189. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  108190. /**
  108191. * Not supported by GPUParticleSystem
  108192. * @param gradient defines the gradient to remove
  108193. * @returns the current particle system
  108194. */
  108195. removeEmitRateGradient(gradient: number): IParticleSystem;
  108196. /**
  108197. * Not supported by GPUParticleSystem
  108198. * @param gradient defines the gradient to use (between 0 and 1)
  108199. * @param factor defines the start size value to affect to the specified gradient
  108200. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108201. * @returns the current particle system
  108202. */
  108203. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  108204. /**
  108205. * Not supported by GPUParticleSystem
  108206. * @param gradient defines the gradient to remove
  108207. * @returns the current particle system
  108208. */
  108209. removeStartSizeGradient(gradient: number): IParticleSystem;
  108210. /**
  108211. * Not supported by GPUParticleSystem
  108212. * @param gradient defines the gradient to use (between 0 and 1)
  108213. * @param min defines the color remap minimal range
  108214. * @param max defines the color remap maximal range
  108215. * @returns the current particle system
  108216. */
  108217. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  108218. /**
  108219. * Not supported by GPUParticleSystem
  108220. * @param gradient defines the gradient to remove
  108221. * @returns the current particle system
  108222. */
  108223. removeColorRemapGradient(): IParticleSystem;
  108224. /**
  108225. * Not supported by GPUParticleSystem
  108226. * @param gradient defines the gradient to use (between 0 and 1)
  108227. * @param min defines the alpha remap minimal range
  108228. * @param max defines the alpha remap maximal range
  108229. * @returns the current particle system
  108230. */
  108231. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  108232. /**
  108233. * Not supported by GPUParticleSystem
  108234. * @param gradient defines the gradient to remove
  108235. * @returns the current particle system
  108236. */
  108237. removeAlphaRemapGradient(): IParticleSystem;
  108238. /**
  108239. * Not supported by GPUParticleSystem
  108240. * @param gradient defines the gradient to use (between 0 and 1)
  108241. * @param color defines the color to affect to the specified gradient
  108242. * @returns the current particle system
  108243. */
  108244. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  108245. /**
  108246. * Not supported by GPUParticleSystem
  108247. * @param gradient defines the gradient to remove
  108248. * @returns the current particle system
  108249. */
  108250. removeRampGradient(): IParticleSystem;
  108251. /**
  108252. * Not supported by GPUParticleSystem
  108253. * @returns the list of ramp gradients
  108254. */
  108255. getRampGradients(): Nullable<Array<Color3Gradient>>;
  108256. /**
  108257. * Not supported by GPUParticleSystem
  108258. * Gets or sets a boolean indicating that ramp gradients must be used
  108259. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  108260. */
  108261. useRampGradients: boolean;
  108262. /**
  108263. * Not supported by GPUParticleSystem
  108264. * @param gradient defines the gradient to use (between 0 and 1)
  108265. * @param factor defines the life time factor to affect to the specified gradient
  108266. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108267. * @returns the current particle system
  108268. */
  108269. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  108270. /**
  108271. * Not supported by GPUParticleSystem
  108272. * @param gradient defines the gradient to remove
  108273. * @returns the current particle system
  108274. */
  108275. removeLifeTimeGradient(gradient: number): IParticleSystem;
  108276. /**
  108277. * Instantiates a GPU particle system.
  108278. * 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.
  108279. * @param name The name of the particle system
  108280. * @param options The options used to create the system
  108281. * @param scene The scene the particle system belongs to
  108282. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  108283. */
  108284. constructor(name: string, options: Partial<{
  108285. capacity: number;
  108286. randomTextureSize: number;
  108287. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  108288. protected _reset(): void;
  108289. private _createUpdateVAO;
  108290. private _createRenderVAO;
  108291. private _initialize;
  108292. /** @hidden */
  108293. _recreateUpdateEffect(): void;
  108294. /** @hidden */
  108295. _recreateRenderEffect(): void;
  108296. /**
  108297. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  108298. * @param preWarm defines if we are in the pre-warmimg phase
  108299. */
  108300. animate(preWarm?: boolean): void;
  108301. private _createFactorGradientTexture;
  108302. private _createSizeGradientTexture;
  108303. private _createAngularSpeedGradientTexture;
  108304. private _createVelocityGradientTexture;
  108305. private _createLimitVelocityGradientTexture;
  108306. private _createDragGradientTexture;
  108307. private _createColorGradientTexture;
  108308. /**
  108309. * Renders the particle system in its current state
  108310. * @param preWarm defines if the system should only update the particles but not render them
  108311. * @returns the current number of particles
  108312. */
  108313. render(preWarm?: boolean): number;
  108314. /**
  108315. * Rebuilds the particle system
  108316. */
  108317. rebuild(): void;
  108318. private _releaseBuffers;
  108319. private _releaseVAOs;
  108320. /**
  108321. * Disposes the particle system and free the associated resources
  108322. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  108323. */
  108324. dispose(disposeTexture?: boolean): void;
  108325. /**
  108326. * Clones the particle system.
  108327. * @param name The name of the cloned object
  108328. * @param newEmitter The new emitter to use
  108329. * @returns the cloned particle system
  108330. */
  108331. clone(name: string, newEmitter: any): GPUParticleSystem;
  108332. /**
  108333. * Serializes the particle system to a JSON object.
  108334. * @returns the JSON object
  108335. */
  108336. serialize(): any;
  108337. /**
  108338. * Parses a JSON object to create a GPU particle system.
  108339. * @param parsedParticleSystem The JSON object to parse
  108340. * @param scene The scene to create the particle system in
  108341. * @param rootUrl The root url to use to load external dependencies like texture
  108342. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  108343. * @returns the parsed GPU particle system
  108344. */
  108345. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  108346. }
  108347. }
  108348. declare module BABYLON {
  108349. /**
  108350. * Represents a set of particle systems working together to create a specific effect
  108351. */
  108352. export class ParticleSystemSet implements IDisposable {
  108353. private _emitterCreationOptions;
  108354. private _emitterNode;
  108355. /**
  108356. * Gets the particle system list
  108357. */
  108358. systems: IParticleSystem[];
  108359. /**
  108360. * Gets the emitter node used with this set
  108361. */
  108362. readonly emitterNode: Nullable<TransformNode>;
  108363. /**
  108364. * Creates a new emitter mesh as a sphere
  108365. * @param options defines the options used to create the sphere
  108366. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  108367. * @param scene defines the hosting scene
  108368. */
  108369. setEmitterAsSphere(options: {
  108370. diameter: number;
  108371. segments: number;
  108372. color: Color3;
  108373. }, renderingGroupId: number, scene: Scene): void;
  108374. /**
  108375. * Starts all particle systems of the set
  108376. * @param emitter defines an optional mesh to use as emitter for the particle systems
  108377. */
  108378. start(emitter?: AbstractMesh): void;
  108379. /**
  108380. * Release all associated resources
  108381. */
  108382. dispose(): void;
  108383. /**
  108384. * Serialize the set into a JSON compatible object
  108385. * @returns a JSON compatible representation of the set
  108386. */
  108387. serialize(): any;
  108388. /**
  108389. * Parse a new ParticleSystemSet from a serialized source
  108390. * @param data defines a JSON compatible representation of the set
  108391. * @param scene defines the hosting scene
  108392. * @param gpu defines if we want GPU particles or CPU particles
  108393. * @returns a new ParticleSystemSet
  108394. */
  108395. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  108396. }
  108397. }
  108398. declare module BABYLON {
  108399. /**
  108400. * This class is made for on one-liner static method to help creating particle system set.
  108401. */
  108402. export class ParticleHelper {
  108403. /**
  108404. * Gets or sets base Assets URL
  108405. */
  108406. static BaseAssetsUrl: string;
  108407. /**
  108408. * Create a default particle system that you can tweak
  108409. * @param emitter defines the emitter to use
  108410. * @param capacity defines the system capacity (default is 500 particles)
  108411. * @param scene defines the hosting scene
  108412. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  108413. * @returns the new Particle system
  108414. */
  108415. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  108416. /**
  108417. * This is the main static method (one-liner) of this helper to create different particle systems
  108418. * @param type This string represents the type to the particle system to create
  108419. * @param scene The scene where the particle system should live
  108420. * @param gpu If the system will use gpu
  108421. * @returns the ParticleSystemSet created
  108422. */
  108423. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  108424. /**
  108425. * Static function used to export a particle system to a ParticleSystemSet variable.
  108426. * Please note that the emitter shape is not exported
  108427. * @param systems defines the particle systems to export
  108428. * @returns the created particle system set
  108429. */
  108430. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  108431. }
  108432. }
  108433. declare module BABYLON {
  108434. interface Engine {
  108435. /**
  108436. * Create an effect to use with particle systems.
  108437. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  108438. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  108439. * @param uniformsNames defines a list of attribute names
  108440. * @param samplers defines an array of string used to represent textures
  108441. * @param defines defines the string containing the defines to use to compile the shaders
  108442. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  108443. * @param onCompiled defines a function to call when the effect creation is successful
  108444. * @param onError defines a function to call when the effect creation has failed
  108445. * @returns the new Effect
  108446. */
  108447. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  108448. }
  108449. interface Mesh {
  108450. /**
  108451. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  108452. * @returns an array of IParticleSystem
  108453. */
  108454. getEmittedParticleSystems(): IParticleSystem[];
  108455. /**
  108456. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  108457. * @returns an array of IParticleSystem
  108458. */
  108459. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  108460. }
  108461. /**
  108462. * @hidden
  108463. */
  108464. export var _IDoNeedToBeInTheBuild: number;
  108465. }
  108466. declare module BABYLON {
  108467. interface Scene {
  108468. /** @hidden (Backing field) */
  108469. _physicsEngine: Nullable<IPhysicsEngine>;
  108470. /**
  108471. * Gets the current physics engine
  108472. * @returns a IPhysicsEngine or null if none attached
  108473. */
  108474. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  108475. /**
  108476. * Enables physics to the current scene
  108477. * @param gravity defines the scene's gravity for the physics engine
  108478. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  108479. * @return a boolean indicating if the physics engine was initialized
  108480. */
  108481. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  108482. /**
  108483. * Disables and disposes the physics engine associated with the scene
  108484. */
  108485. disablePhysicsEngine(): void;
  108486. /**
  108487. * Gets a boolean indicating if there is an active physics engine
  108488. * @returns a boolean indicating if there is an active physics engine
  108489. */
  108490. isPhysicsEnabled(): boolean;
  108491. /**
  108492. * Deletes a physics compound impostor
  108493. * @param compound defines the compound to delete
  108494. */
  108495. deleteCompoundImpostor(compound: any): void;
  108496. /**
  108497. * An event triggered when physic simulation is about to be run
  108498. */
  108499. onBeforePhysicsObservable: Observable<Scene>;
  108500. /**
  108501. * An event triggered when physic simulation has been done
  108502. */
  108503. onAfterPhysicsObservable: Observable<Scene>;
  108504. }
  108505. interface AbstractMesh {
  108506. /** @hidden */
  108507. _physicsImpostor: Nullable<PhysicsImpostor>;
  108508. /**
  108509. * Gets or sets impostor used for physic simulation
  108510. * @see http://doc.babylonjs.com/features/physics_engine
  108511. */
  108512. physicsImpostor: Nullable<PhysicsImpostor>;
  108513. /**
  108514. * Gets the current physics impostor
  108515. * @see http://doc.babylonjs.com/features/physics_engine
  108516. * @returns a physics impostor or null
  108517. */
  108518. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  108519. /** Apply a physic impulse to the mesh
  108520. * @param force defines the force to apply
  108521. * @param contactPoint defines where to apply the force
  108522. * @returns the current mesh
  108523. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  108524. */
  108525. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  108526. /**
  108527. * Creates a physic joint between two meshes
  108528. * @param otherMesh defines the other mesh to use
  108529. * @param pivot1 defines the pivot to use on this mesh
  108530. * @param pivot2 defines the pivot to use on the other mesh
  108531. * @param options defines additional options (can be plugin dependent)
  108532. * @returns the current mesh
  108533. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  108534. */
  108535. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  108536. /** @hidden */
  108537. _disposePhysicsObserver: Nullable<Observer<Node>>;
  108538. }
  108539. /**
  108540. * Defines the physics engine scene component responsible to manage a physics engine
  108541. */
  108542. export class PhysicsEngineSceneComponent implements ISceneComponent {
  108543. /**
  108544. * The component name helpful to identify the component in the list of scene components.
  108545. */
  108546. readonly name: string;
  108547. /**
  108548. * The scene the component belongs to.
  108549. */
  108550. scene: Scene;
  108551. /**
  108552. * Creates a new instance of the component for the given scene
  108553. * @param scene Defines the scene to register the component in
  108554. */
  108555. constructor(scene: Scene);
  108556. /**
  108557. * Registers the component in a given scene
  108558. */
  108559. register(): void;
  108560. /**
  108561. * Rebuilds the elements related to this component in case of
  108562. * context lost for instance.
  108563. */
  108564. rebuild(): void;
  108565. /**
  108566. * Disposes the component and the associated ressources
  108567. */
  108568. dispose(): void;
  108569. }
  108570. }
  108571. declare module BABYLON {
  108572. /**
  108573. * A helper for physics simulations
  108574. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108575. */
  108576. export class PhysicsHelper {
  108577. private _scene;
  108578. private _physicsEngine;
  108579. /**
  108580. * Initializes the Physics helper
  108581. * @param scene Babylon.js scene
  108582. */
  108583. constructor(scene: Scene);
  108584. /**
  108585. * Applies a radial explosion impulse
  108586. * @param origin the origin of the explosion
  108587. * @param radiusOrEventOptions the radius or the options of radial explosion
  108588. * @param strength the explosion strength
  108589. * @param falloff possible options: Constant & Linear. Defaults to Constant
  108590. * @returns A physics radial explosion event, or null
  108591. */
  108592. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  108593. /**
  108594. * Applies a radial explosion force
  108595. * @param origin the origin of the explosion
  108596. * @param radiusOrEventOptions the radius or the options of radial explosion
  108597. * @param strength the explosion strength
  108598. * @param falloff possible options: Constant & Linear. Defaults to Constant
  108599. * @returns A physics radial explosion event, or null
  108600. */
  108601. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  108602. /**
  108603. * Creates a gravitational field
  108604. * @param origin the origin of the explosion
  108605. * @param radiusOrEventOptions the radius or the options of radial explosion
  108606. * @param strength the explosion strength
  108607. * @param falloff possible options: Constant & Linear. Defaults to Constant
  108608. * @returns A physics gravitational field event, or null
  108609. */
  108610. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  108611. /**
  108612. * Creates a physics updraft event
  108613. * @param origin the origin of the updraft
  108614. * @param radiusOrEventOptions the radius or the options of the updraft
  108615. * @param strength the strength of the updraft
  108616. * @param height the height of the updraft
  108617. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  108618. * @returns A physics updraft event, or null
  108619. */
  108620. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  108621. /**
  108622. * Creates a physics vortex event
  108623. * @param origin the of the vortex
  108624. * @param radiusOrEventOptions the radius or the options of the vortex
  108625. * @param strength the strength of the vortex
  108626. * @param height the height of the vortex
  108627. * @returns a Physics vortex event, or null
  108628. * A physics vortex event or null
  108629. */
  108630. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  108631. }
  108632. /**
  108633. * Represents a physics radial explosion event
  108634. */
  108635. class PhysicsRadialExplosionEvent {
  108636. private _scene;
  108637. private _options;
  108638. private _sphere;
  108639. private _dataFetched;
  108640. /**
  108641. * Initializes a radial explosioin event
  108642. * @param _scene BabylonJS scene
  108643. * @param _options The options for the vortex event
  108644. */
  108645. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  108646. /**
  108647. * Returns the data related to the radial explosion event (sphere).
  108648. * @returns The radial explosion event data
  108649. */
  108650. getData(): PhysicsRadialExplosionEventData;
  108651. /**
  108652. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  108653. * @param impostor A physics imposter
  108654. * @param origin the origin of the explosion
  108655. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  108656. */
  108657. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsForceAndContactPoint>;
  108658. /**
  108659. * Disposes the sphere.
  108660. * @param force Specifies if the sphere should be disposed by force
  108661. */
  108662. dispose(force?: boolean): void;
  108663. /*** Helpers ***/
  108664. private _prepareSphere;
  108665. private _intersectsWithSphere;
  108666. }
  108667. /**
  108668. * Represents a gravitational field event
  108669. */
  108670. class PhysicsGravitationalFieldEvent {
  108671. private _physicsHelper;
  108672. private _scene;
  108673. private _origin;
  108674. private _options;
  108675. private _tickCallback;
  108676. private _sphere;
  108677. private _dataFetched;
  108678. /**
  108679. * Initializes the physics gravitational field event
  108680. * @param _physicsHelper A physics helper
  108681. * @param _scene BabylonJS scene
  108682. * @param _origin The origin position of the gravitational field event
  108683. * @param _options The options for the vortex event
  108684. */
  108685. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  108686. /**
  108687. * Returns the data related to the gravitational field event (sphere).
  108688. * @returns A gravitational field event
  108689. */
  108690. getData(): PhysicsGravitationalFieldEventData;
  108691. /**
  108692. * Enables the gravitational field.
  108693. */
  108694. enable(): void;
  108695. /**
  108696. * Disables the gravitational field.
  108697. */
  108698. disable(): void;
  108699. /**
  108700. * Disposes the sphere.
  108701. * @param force The force to dispose from the gravitational field event
  108702. */
  108703. dispose(force?: boolean): void;
  108704. private _tick;
  108705. }
  108706. /**
  108707. * Represents a physics updraft event
  108708. */
  108709. class PhysicsUpdraftEvent {
  108710. private _scene;
  108711. private _origin;
  108712. private _options;
  108713. private _physicsEngine;
  108714. private _originTop;
  108715. private _originDirection;
  108716. private _tickCallback;
  108717. private _cylinder;
  108718. private _cylinderPosition;
  108719. private _dataFetched;
  108720. /**
  108721. * Initializes the physics updraft event
  108722. * @param _scene BabylonJS scene
  108723. * @param _origin The origin position of the updraft
  108724. * @param _options The options for the updraft event
  108725. */
  108726. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  108727. /**
  108728. * Returns the data related to the updraft event (cylinder).
  108729. * @returns A physics updraft event
  108730. */
  108731. getData(): PhysicsUpdraftEventData;
  108732. /**
  108733. * Enables the updraft.
  108734. */
  108735. enable(): void;
  108736. /**
  108737. * Disables the updraft.
  108738. */
  108739. disable(): void;
  108740. /**
  108741. * Disposes the cylinder.
  108742. * @param force Specifies if the updraft should be disposed by force
  108743. */
  108744. dispose(force?: boolean): void;
  108745. private getImpostorForceAndContactPoint;
  108746. private _tick;
  108747. /*** Helpers ***/
  108748. private _prepareCylinder;
  108749. private _intersectsWithCylinder;
  108750. }
  108751. /**
  108752. * Represents a physics vortex event
  108753. */
  108754. class PhysicsVortexEvent {
  108755. private _scene;
  108756. private _origin;
  108757. private _options;
  108758. private _physicsEngine;
  108759. private _originTop;
  108760. private _tickCallback;
  108761. private _cylinder;
  108762. private _cylinderPosition;
  108763. private _dataFetched;
  108764. /**
  108765. * Initializes the physics vortex event
  108766. * @param _scene The BabylonJS scene
  108767. * @param _origin The origin position of the vortex
  108768. * @param _options The options for the vortex event
  108769. */
  108770. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  108771. /**
  108772. * Returns the data related to the vortex event (cylinder).
  108773. * @returns The physics vortex event data
  108774. */
  108775. getData(): PhysicsVortexEventData;
  108776. /**
  108777. * Enables the vortex.
  108778. */
  108779. enable(): void;
  108780. /**
  108781. * Disables the cortex.
  108782. */
  108783. disable(): void;
  108784. /**
  108785. * Disposes the sphere.
  108786. * @param force
  108787. */
  108788. dispose(force?: boolean): void;
  108789. private getImpostorForceAndContactPoint;
  108790. private _tick;
  108791. /*** Helpers ***/
  108792. private _prepareCylinder;
  108793. private _intersectsWithCylinder;
  108794. }
  108795. /**
  108796. * Options fot the radial explosion event
  108797. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108798. */
  108799. export class PhysicsRadialExplosionEventOptions {
  108800. /**
  108801. * The radius of the sphere for the radial explosion.
  108802. */
  108803. radius: number;
  108804. /**
  108805. * The strenth of the explosion.
  108806. */
  108807. strength: number;
  108808. /**
  108809. * The strenght of the force in correspondence to the distance of the affected object
  108810. */
  108811. falloff: PhysicsRadialImpulseFalloff;
  108812. /**
  108813. * Sphere options for the radial explosion.
  108814. */
  108815. sphere: {
  108816. segments: number;
  108817. diameter: number;
  108818. };
  108819. }
  108820. /**
  108821. * Options fot the updraft event
  108822. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108823. */
  108824. export class PhysicsUpdraftEventOptions {
  108825. /**
  108826. * The radius of the cylinder for the vortex
  108827. */
  108828. radius: number;
  108829. /**
  108830. * The strenth of the updraft.
  108831. */
  108832. strength: number;
  108833. /**
  108834. * The height of the cylinder for the updraft.
  108835. */
  108836. height: number;
  108837. /**
  108838. * The mode for the the updraft.
  108839. */
  108840. updraftMode: PhysicsUpdraftMode;
  108841. }
  108842. /**
  108843. * Options fot the vortex event
  108844. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108845. */
  108846. export class PhysicsVortexEventOptions {
  108847. /**
  108848. * The radius of the cylinder for the vortex
  108849. */
  108850. radius: number;
  108851. /**
  108852. * The strenth of the vortex.
  108853. */
  108854. strength: number;
  108855. /**
  108856. * The height of the cylinder for the vortex.
  108857. */
  108858. height: number;
  108859. /**
  108860. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  108861. */
  108862. centripetalForceThreshold: number;
  108863. /**
  108864. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  108865. */
  108866. centripetalForceMultiplier: number;
  108867. /**
  108868. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  108869. */
  108870. centrifugalForceMultiplier: number;
  108871. /**
  108872. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  108873. */
  108874. updraftForceMultiplier: number;
  108875. }
  108876. /**
  108877. * The strenght of the force in correspondence to the distance of the affected object
  108878. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108879. */
  108880. export enum PhysicsRadialImpulseFalloff {
  108881. /** Defines that impulse is constant in strength across it's whole radius */
  108882. Constant = 0,
  108883. /** Defines that impulse gets weaker if it's further from the origin */
  108884. Linear = 1
  108885. }
  108886. /**
  108887. * The strength of the force in correspondence to the distance of the affected object
  108888. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108889. */
  108890. export enum PhysicsUpdraftMode {
  108891. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  108892. Center = 0,
  108893. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  108894. Perpendicular = 1
  108895. }
  108896. /**
  108897. * Interface for a physics force and contact point
  108898. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108899. */
  108900. export interface PhysicsForceAndContactPoint {
  108901. /**
  108902. * The force applied at the contact point
  108903. */
  108904. force: Vector3;
  108905. /**
  108906. * The contact point
  108907. */
  108908. contactPoint: Vector3;
  108909. }
  108910. /**
  108911. * Interface for radial explosion event data
  108912. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108913. */
  108914. export interface PhysicsRadialExplosionEventData {
  108915. /**
  108916. * A sphere used for the radial explosion event
  108917. */
  108918. sphere: Mesh;
  108919. }
  108920. /**
  108921. * Interface for gravitational field event data
  108922. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108923. */
  108924. export interface PhysicsGravitationalFieldEventData {
  108925. /**
  108926. * A sphere mesh used for the gravitational field event
  108927. */
  108928. sphere: Mesh;
  108929. }
  108930. /**
  108931. * Interface for updraft event data
  108932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108933. */
  108934. export interface PhysicsUpdraftEventData {
  108935. /**
  108936. * A cylinder used for the updraft event
  108937. */
  108938. cylinder: Mesh;
  108939. }
  108940. /**
  108941. * Interface for vortex event data
  108942. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  108943. */
  108944. export interface PhysicsVortexEventData {
  108945. /**
  108946. * A cylinder used for the vortex event
  108947. */
  108948. cylinder: Mesh;
  108949. }
  108950. }
  108951. declare module BABYLON {
  108952. /**
  108953. * AmmoJS Physics plugin
  108954. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108955. * @see https://github.com/kripken/ammo.js/
  108956. */
  108957. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  108958. private _useDeltaForWorldStep;
  108959. /**
  108960. * Reference to the Ammo library
  108961. */
  108962. bjsAMMO: any;
  108963. /**
  108964. * Created ammoJS world which physics bodies are added to
  108965. */
  108966. world: any;
  108967. /**
  108968. * Name of the plugin
  108969. */
  108970. name: string;
  108971. private _timeStep;
  108972. private _fixedTimeStep;
  108973. private _maxSteps;
  108974. private _tmpQuaternion;
  108975. private _tmpAmmoTransform;
  108976. private _tmpAmmoQuaternion;
  108977. private _tmpAmmoConcreteContactResultCallback;
  108978. private _collisionConfiguration;
  108979. private _dispatcher;
  108980. private _overlappingPairCache;
  108981. private _solver;
  108982. private _softBodySolver;
  108983. private _tmpAmmoVectorA;
  108984. private _tmpAmmoVectorB;
  108985. private _tmpAmmoVectorC;
  108986. private _tmpAmmoVectorD;
  108987. private _tmpContactCallbackResult;
  108988. private _tmpAmmoVectorRCA;
  108989. private _tmpAmmoVectorRCB;
  108990. private _raycastResult;
  108991. private static readonly DISABLE_COLLISION_FLAG;
  108992. private static readonly KINEMATIC_FLAG;
  108993. private static readonly DISABLE_DEACTIVATION_FLAG;
  108994. /**
  108995. * Initializes the ammoJS plugin
  108996. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  108997. * @param ammoInjection can be used to inject your own ammo reference
  108998. */
  108999. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  109000. /**
  109001. * Sets the gravity of the physics world (m/(s^2))
  109002. * @param gravity Gravity to set
  109003. */
  109004. setGravity(gravity: Vector3): void;
  109005. /**
  109006. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  109007. * @param timeStep timestep to use in seconds
  109008. */
  109009. setTimeStep(timeStep: number): void;
  109010. /**
  109011. * 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)
  109012. * @param fixedTimeStep fixedTimeStep to use in seconds
  109013. */
  109014. setFixedTimeStep(fixedTimeStep: number): void;
  109015. /**
  109016. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  109017. * @param maxSteps the maximum number of steps by the physics engine per frame
  109018. */
  109019. setMaxSteps(maxSteps: number): void;
  109020. /**
  109021. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  109022. * @returns the current timestep in seconds
  109023. */
  109024. getTimeStep(): number;
  109025. private _isImpostorInContact;
  109026. private _isImpostorPairInContact;
  109027. private _stepSimulation;
  109028. /**
  109029. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  109030. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  109031. * After the step the babylon meshes are set to the position of the physics imposters
  109032. * @param delta amount of time to step forward
  109033. * @param impostors array of imposters to update before/after the step
  109034. */
  109035. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  109036. /**
  109037. * Update babylon mesh vertices vertices to match physics world object
  109038. * @param impostor imposter to match
  109039. */
  109040. afterSoftStep(impostor: PhysicsImpostor): void;
  109041. private _tmpVector;
  109042. private _tmpMatrix;
  109043. /**
  109044. * Applies an impulse on the imposter
  109045. * @param impostor imposter to apply impulse to
  109046. * @param force amount of force to be applied to the imposter
  109047. * @param contactPoint the location to apply the impulse on the imposter
  109048. */
  109049. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  109050. /**
  109051. * Applies a force on the imposter
  109052. * @param impostor imposter to apply force
  109053. * @param force amount of force to be applied to the imposter
  109054. * @param contactPoint the location to apply the force on the imposter
  109055. */
  109056. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  109057. /**
  109058. * Creates a physics body using the plugin
  109059. * @param impostor the imposter to create the physics body on
  109060. */
  109061. generatePhysicsBody(impostor: PhysicsImpostor): void;
  109062. /**
  109063. * Removes the physics body from the imposter and disposes of the body's memory
  109064. * @param impostor imposter to remove the physics body from
  109065. */
  109066. removePhysicsBody(impostor: PhysicsImpostor): void;
  109067. /**
  109068. * Generates a joint
  109069. * @param impostorJoint the imposter joint to create the joint with
  109070. */
  109071. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  109072. /**
  109073. * Removes a joint
  109074. * @param impostorJoint the imposter joint to remove the joint from
  109075. */
  109076. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  109077. private _addMeshVerts;
  109078. /**
  109079. * Initialise the soft body vertices to match its object's (mesh) vertices
  109080. * Softbody vertices (nodes) are in world space and to match this
  109081. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  109082. * @param impostor to create the softbody for
  109083. */
  109084. private _softVertexData;
  109085. /**
  109086. * Create an impostor's soft body
  109087. * @param impostor to create the softbody for
  109088. */
  109089. private _createSoftbody;
  109090. /**
  109091. * Create cloth for an impostor
  109092. * @param impostor to create the softbody for
  109093. */
  109094. private _createCloth;
  109095. private _addHullVerts;
  109096. private _createShape;
  109097. /**
  109098. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  109099. * @param impostor imposter containing the physics body and babylon object
  109100. */
  109101. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  109102. /**
  109103. * Sets the babylon object's position/rotation from the physics body's position/rotation
  109104. * @param impostor imposter containing the physics body and babylon object
  109105. * @param newPosition new position
  109106. * @param newRotation new rotation
  109107. */
  109108. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  109109. /**
  109110. * If this plugin is supported
  109111. * @returns true if its supported
  109112. */
  109113. isSupported(): boolean;
  109114. /**
  109115. * Sets the linear velocity of the physics body
  109116. * @param impostor imposter to set the velocity on
  109117. * @param velocity velocity to set
  109118. */
  109119. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  109120. /**
  109121. * Sets the angular velocity of the physics body
  109122. * @param impostor imposter to set the velocity on
  109123. * @param velocity velocity to set
  109124. */
  109125. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  109126. /**
  109127. * gets the linear velocity
  109128. * @param impostor imposter to get linear velocity from
  109129. * @returns linear velocity
  109130. */
  109131. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  109132. /**
  109133. * gets the angular velocity
  109134. * @param impostor imposter to get angular velocity from
  109135. * @returns angular velocity
  109136. */
  109137. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  109138. /**
  109139. * Sets the mass of physics body
  109140. * @param impostor imposter to set the mass on
  109141. * @param mass mass to set
  109142. */
  109143. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  109144. /**
  109145. * Gets the mass of the physics body
  109146. * @param impostor imposter to get the mass from
  109147. * @returns mass
  109148. */
  109149. getBodyMass(impostor: PhysicsImpostor): number;
  109150. /**
  109151. * Gets friction of the impostor
  109152. * @param impostor impostor to get friction from
  109153. * @returns friction value
  109154. */
  109155. getBodyFriction(impostor: PhysicsImpostor): number;
  109156. /**
  109157. * Sets friction of the impostor
  109158. * @param impostor impostor to set friction on
  109159. * @param friction friction value
  109160. */
  109161. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  109162. /**
  109163. * Gets restitution of the impostor
  109164. * @param impostor impostor to get restitution from
  109165. * @returns restitution value
  109166. */
  109167. getBodyRestitution(impostor: PhysicsImpostor): number;
  109168. /**
  109169. * Sets resitution of the impostor
  109170. * @param impostor impostor to set resitution on
  109171. * @param restitution resitution value
  109172. */
  109173. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  109174. /**
  109175. * Gets pressure inside the impostor
  109176. * @param impostor impostor to get pressure from
  109177. * @returns pressure value
  109178. */
  109179. getBodyPressure(impostor: PhysicsImpostor): number;
  109180. /**
  109181. * Sets pressure inside a soft body impostor
  109182. * Cloth and rope must remain 0 pressure
  109183. * @param impostor impostor to set pressure on
  109184. * @param pressure pressure value
  109185. */
  109186. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  109187. /**
  109188. * Gets stiffness of the impostor
  109189. * @param impostor impostor to get stiffness from
  109190. * @returns pressure value
  109191. */
  109192. getBodyStiffness(impostor: PhysicsImpostor): number;
  109193. /**
  109194. * Sets stiffness of the impostor
  109195. * @param impostor impostor to set stiffness on
  109196. * @param stiffness stiffness value from 0 to 1
  109197. */
  109198. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  109199. /**
  109200. * Gets velocityIterations of the impostor
  109201. * @param impostor impostor to get velocity iterations from
  109202. * @returns velocityIterations value
  109203. */
  109204. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  109205. /**
  109206. * Sets velocityIterations of the impostor
  109207. * @param impostor impostor to set velocity iterations on
  109208. * @param velocityIterations velocityIterations value
  109209. */
  109210. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  109211. /**
  109212. * Gets positionIterations of the impostor
  109213. * @param impostor impostor to get position iterations from
  109214. * @returns positionIterations value
  109215. */
  109216. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  109217. /**
  109218. * Sets positionIterations of the impostor
  109219. * @param impostor impostor to set position on
  109220. * @param positionIterations positionIterations value
  109221. */
  109222. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  109223. /**
  109224. * Sleeps the physics body and stops it from being active
  109225. * @param impostor impostor to sleep
  109226. */
  109227. sleepBody(impostor: PhysicsImpostor): void;
  109228. /**
  109229. * Activates the physics body
  109230. * @param impostor impostor to activate
  109231. */
  109232. wakeUpBody(impostor: PhysicsImpostor): void;
  109233. /**
  109234. * Updates the distance parameters of the joint
  109235. * @param joint joint to update
  109236. * @param maxDistance maximum distance of the joint
  109237. * @param minDistance minimum distance of the joint
  109238. */
  109239. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  109240. /**
  109241. * Sets a motor on the joint
  109242. * @param joint joint to set motor on
  109243. * @param speed speed of the motor
  109244. * @param maxForce maximum force of the motor
  109245. * @param motorIndex index of the motor
  109246. */
  109247. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  109248. /**
  109249. * Sets the motors limit
  109250. * @param joint joint to set limit on
  109251. * @param upperLimit upper limit
  109252. * @param lowerLimit lower limit
  109253. */
  109254. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  109255. /**
  109256. * Syncs the position and rotation of a mesh with the impostor
  109257. * @param mesh mesh to sync
  109258. * @param impostor impostor to update the mesh with
  109259. */
  109260. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  109261. /**
  109262. * Gets the radius of the impostor
  109263. * @param impostor impostor to get radius from
  109264. * @returns the radius
  109265. */
  109266. getRadius(impostor: PhysicsImpostor): number;
  109267. /**
  109268. * Gets the box size of the impostor
  109269. * @param impostor impostor to get box size from
  109270. * @param result the resulting box size
  109271. */
  109272. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  109273. /**
  109274. * Disposes of the impostor
  109275. */
  109276. dispose(): void;
  109277. /**
  109278. * Does a raycast in the physics world
  109279. * @param from when should the ray start?
  109280. * @param to when should the ray end?
  109281. * @returns PhysicsRaycastResult
  109282. */
  109283. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  109284. }
  109285. }
  109286. declare module BABYLON {
  109287. /** @hidden */
  109288. export var blackAndWhitePixelShader: {
  109289. name: string;
  109290. shader: string;
  109291. };
  109292. }
  109293. declare module BABYLON {
  109294. /**
  109295. * Post process used to render in black and white
  109296. */
  109297. export class BlackAndWhitePostProcess extends PostProcess {
  109298. /**
  109299. * Linear about to convert he result to black and white (default: 1)
  109300. */
  109301. degree: number;
  109302. /**
  109303. * Creates a black and white post process
  109304. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  109305. * @param name The name of the effect.
  109306. * @param options The required width/height ratio to downsize to before computing the render pass.
  109307. * @param camera The camera to apply the render pass to.
  109308. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109309. * @param engine The engine which the post process will be applied. (default: current engine)
  109310. * @param reusable If the post process can be reused on the same frame. (default: false)
  109311. */
  109312. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109313. }
  109314. }
  109315. declare module BABYLON {
  109316. /**
  109317. * This represents a set of one or more post processes in Babylon.
  109318. * A post process can be used to apply a shader to a texture after it is rendered.
  109319. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  109320. */
  109321. export class PostProcessRenderEffect {
  109322. private _postProcesses;
  109323. private _getPostProcesses;
  109324. private _singleInstance;
  109325. private _cameras;
  109326. private _indicesForCamera;
  109327. /**
  109328. * Name of the effect
  109329. * @hidden
  109330. */
  109331. _name: string;
  109332. /**
  109333. * Instantiates a post process render effect.
  109334. * A post process can be used to apply a shader to a texture after it is rendered.
  109335. * @param engine The engine the effect is tied to
  109336. * @param name The name of the effect
  109337. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  109338. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  109339. */
  109340. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  109341. /**
  109342. * Checks if all the post processes in the effect are supported.
  109343. */
  109344. readonly isSupported: boolean;
  109345. /**
  109346. * Updates the current state of the effect
  109347. * @hidden
  109348. */
  109349. _update(): void;
  109350. /**
  109351. * Attaches the effect on cameras
  109352. * @param cameras The camera to attach to.
  109353. * @hidden
  109354. */
  109355. _attachCameras(cameras: Camera): void;
  109356. /**
  109357. * Attaches the effect on cameras
  109358. * @param cameras The camera to attach to.
  109359. * @hidden
  109360. */
  109361. _attachCameras(cameras: Camera[]): void;
  109362. /**
  109363. * Detatches the effect on cameras
  109364. * @param cameras The camera to detatch from.
  109365. * @hidden
  109366. */
  109367. _detachCameras(cameras: Camera): void;
  109368. /**
  109369. * Detatches the effect on cameras
  109370. * @param cameras The camera to detatch from.
  109371. * @hidden
  109372. */
  109373. _detachCameras(cameras: Camera[]): void;
  109374. /**
  109375. * Enables the effect on given cameras
  109376. * @param cameras The camera to enable.
  109377. * @hidden
  109378. */
  109379. _enable(cameras: Camera): void;
  109380. /**
  109381. * Enables the effect on given cameras
  109382. * @param cameras The camera to enable.
  109383. * @hidden
  109384. */
  109385. _enable(cameras: Nullable<Camera[]>): void;
  109386. /**
  109387. * Disables the effect on the given cameras
  109388. * @param cameras The camera to disable.
  109389. * @hidden
  109390. */
  109391. _disable(cameras: Camera): void;
  109392. /**
  109393. * Disables the effect on the given cameras
  109394. * @param cameras The camera to disable.
  109395. * @hidden
  109396. */
  109397. _disable(cameras: Nullable<Camera[]>): void;
  109398. /**
  109399. * Gets a list of the post processes contained in the effect.
  109400. * @param camera The camera to get the post processes on.
  109401. * @returns The list of the post processes in the effect.
  109402. */
  109403. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  109404. }
  109405. }
  109406. declare module BABYLON {
  109407. /** @hidden */
  109408. export var extractHighlightsPixelShader: {
  109409. name: string;
  109410. shader: string;
  109411. };
  109412. }
  109413. declare module BABYLON {
  109414. /**
  109415. * 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.
  109416. */
  109417. export class ExtractHighlightsPostProcess extends PostProcess {
  109418. /**
  109419. * The luminance threshold, pixels below this value will be set to black.
  109420. */
  109421. threshold: number;
  109422. /** @hidden */
  109423. _exposure: number;
  109424. /**
  109425. * Post process which has the input texture to be used when performing highlight extraction
  109426. * @hidden
  109427. */
  109428. _inputPostProcess: Nullable<PostProcess>;
  109429. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109430. }
  109431. }
  109432. declare module BABYLON {
  109433. /** @hidden */
  109434. export var bloomMergePixelShader: {
  109435. name: string;
  109436. shader: string;
  109437. };
  109438. }
  109439. declare module BABYLON {
  109440. /**
  109441. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  109442. */
  109443. export class BloomMergePostProcess extends PostProcess {
  109444. /** Weight of the bloom to be added to the original input. */
  109445. weight: number;
  109446. /**
  109447. * Creates a new instance of @see BloomMergePostProcess
  109448. * @param name The name of the effect.
  109449. * @param originalFromInput Post process which's input will be used for the merge.
  109450. * @param blurred Blurred highlights post process which's output will be used.
  109451. * @param weight Weight of the bloom to be added to the original input.
  109452. * @param options The required width/height ratio to downsize to before computing the render pass.
  109453. * @param camera The camera to apply the render pass to.
  109454. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109455. * @param engine The engine which the post process will be applied. (default: current engine)
  109456. * @param reusable If the post process can be reused on the same frame. (default: false)
  109457. * @param textureType Type of textures used when performing the post process. (default: 0)
  109458. * @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)
  109459. */
  109460. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  109461. /** Weight of the bloom to be added to the original input. */
  109462. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109463. }
  109464. }
  109465. declare module BABYLON {
  109466. /**
  109467. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  109468. */
  109469. export class BloomEffect extends PostProcessRenderEffect {
  109470. private bloomScale;
  109471. /**
  109472. * @hidden Internal
  109473. */
  109474. _effects: Array<PostProcess>;
  109475. /**
  109476. * @hidden Internal
  109477. */
  109478. _downscale: ExtractHighlightsPostProcess;
  109479. private _blurX;
  109480. private _blurY;
  109481. private _merge;
  109482. /**
  109483. * The luminance threshold to find bright areas of the image to bloom.
  109484. */
  109485. threshold: number;
  109486. /**
  109487. * The strength of the bloom.
  109488. */
  109489. weight: number;
  109490. /**
  109491. * Specifies the size of the bloom blur kernel, relative to the final output size
  109492. */
  109493. kernel: number;
  109494. /**
  109495. * Creates a new instance of @see BloomEffect
  109496. * @param scene The scene the effect belongs to.
  109497. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  109498. * @param bloomKernel The size of the kernel to be used when applying the blur.
  109499. * @param bloomWeight The the strength of bloom.
  109500. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  109501. * @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)
  109502. */
  109503. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  109504. /**
  109505. * Disposes each of the internal effects for a given camera.
  109506. * @param camera The camera to dispose the effect on.
  109507. */
  109508. disposeEffects(camera: Camera): void;
  109509. /**
  109510. * @hidden Internal
  109511. */
  109512. _updateEffects(): void;
  109513. /**
  109514. * Internal
  109515. * @returns if all the contained post processes are ready.
  109516. * @hidden
  109517. */
  109518. _isReady(): boolean;
  109519. }
  109520. }
  109521. declare module BABYLON {
  109522. /** @hidden */
  109523. export var chromaticAberrationPixelShader: {
  109524. name: string;
  109525. shader: string;
  109526. };
  109527. }
  109528. declare module BABYLON {
  109529. /**
  109530. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  109531. */
  109532. export class ChromaticAberrationPostProcess extends PostProcess {
  109533. /**
  109534. * The amount of seperation of rgb channels (default: 30)
  109535. */
  109536. aberrationAmount: number;
  109537. /**
  109538. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  109539. */
  109540. radialIntensity: number;
  109541. /**
  109542. * 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))
  109543. */
  109544. direction: Vector2;
  109545. /**
  109546. * 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))
  109547. */
  109548. centerPosition: Vector2;
  109549. /**
  109550. * Creates a new instance ChromaticAberrationPostProcess
  109551. * @param name The name of the effect.
  109552. * @param screenWidth The width of the screen to apply the effect on.
  109553. * @param screenHeight The height of the screen to apply the effect on.
  109554. * @param options The required width/height ratio to downsize to before computing the render pass.
  109555. * @param camera The camera to apply the render pass to.
  109556. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109557. * @param engine The engine which the post process will be applied. (default: current engine)
  109558. * @param reusable If the post process can be reused on the same frame. (default: false)
  109559. * @param textureType Type of textures used when performing the post process. (default: 0)
  109560. * @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)
  109561. */
  109562. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109563. }
  109564. }
  109565. declare module BABYLON {
  109566. /** @hidden */
  109567. export var circleOfConfusionPixelShader: {
  109568. name: string;
  109569. shader: string;
  109570. };
  109571. }
  109572. declare module BABYLON {
  109573. /**
  109574. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  109575. */
  109576. export class CircleOfConfusionPostProcess extends PostProcess {
  109577. /**
  109578. * 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.
  109579. */
  109580. lensSize: number;
  109581. /**
  109582. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  109583. */
  109584. fStop: number;
  109585. /**
  109586. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  109587. */
  109588. focusDistance: number;
  109589. /**
  109590. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  109591. */
  109592. focalLength: number;
  109593. private _depthTexture;
  109594. /**
  109595. * Creates a new instance CircleOfConfusionPostProcess
  109596. * @param name The name of the effect.
  109597. * @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.
  109598. * @param options The required width/height ratio to downsize to before computing the render pass.
  109599. * @param camera The camera to apply the render pass to.
  109600. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109601. * @param engine The engine which the post process will be applied. (default: current engine)
  109602. * @param reusable If the post process can be reused on the same frame. (default: false)
  109603. * @param textureType Type of textures used when performing the post process. (default: 0)
  109604. * @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)
  109605. */
  109606. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109607. /**
  109608. * 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.
  109609. */
  109610. depthTexture: RenderTargetTexture;
  109611. }
  109612. }
  109613. declare module BABYLON {
  109614. /** @hidden */
  109615. export var colorCorrectionPixelShader: {
  109616. name: string;
  109617. shader: string;
  109618. };
  109619. }
  109620. declare module BABYLON {
  109621. /**
  109622. *
  109623. * This post-process allows the modification of rendered colors by using
  109624. * a 'look-up table' (LUT). This effect is also called Color Grading.
  109625. *
  109626. * The object needs to be provided an url to a texture containing the color
  109627. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  109628. * Use an image editing software to tweak the LUT to match your needs.
  109629. *
  109630. * For an example of a color LUT, see here:
  109631. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  109632. * For explanations on color grading, see here:
  109633. * @see http://udn.epicgames.com/Three/ColorGrading.html
  109634. *
  109635. */
  109636. export class ColorCorrectionPostProcess extends PostProcess {
  109637. private _colorTableTexture;
  109638. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109639. }
  109640. }
  109641. declare module BABYLON {
  109642. /** @hidden */
  109643. export var convolutionPixelShader: {
  109644. name: string;
  109645. shader: string;
  109646. };
  109647. }
  109648. declare module BABYLON {
  109649. /**
  109650. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  109651. * input texture to perform effects such as edge detection or sharpening
  109652. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  109653. */
  109654. export class ConvolutionPostProcess extends PostProcess {
  109655. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  109656. kernel: number[];
  109657. /**
  109658. * Creates a new instance ConvolutionPostProcess
  109659. * @param name The name of the effect.
  109660. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  109661. * @param options The required width/height ratio to downsize to before computing the render pass.
  109662. * @param camera The camera to apply the render pass to.
  109663. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109664. * @param engine The engine which the post process will be applied. (default: current engine)
  109665. * @param reusable If the post process can be reused on the same frame. (default: false)
  109666. * @param textureType Type of textures used when performing the post process. (default: 0)
  109667. */
  109668. constructor(name: string,
  109669. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  109670. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  109671. /**
  109672. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109673. */
  109674. static EdgeDetect0Kernel: number[];
  109675. /**
  109676. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109677. */
  109678. static EdgeDetect1Kernel: number[];
  109679. /**
  109680. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109681. */
  109682. static EdgeDetect2Kernel: number[];
  109683. /**
  109684. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109685. */
  109686. static SharpenKernel: number[];
  109687. /**
  109688. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109689. */
  109690. static EmbossKernel: number[];
  109691. /**
  109692. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  109693. */
  109694. static GaussianKernel: number[];
  109695. }
  109696. }
  109697. declare module BABYLON {
  109698. /**
  109699. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  109700. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  109701. * based on samples that have a large difference in distance than the center pixel.
  109702. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  109703. */
  109704. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  109705. direction: Vector2;
  109706. /**
  109707. * Creates a new instance CircleOfConfusionPostProcess
  109708. * @param name The name of the effect.
  109709. * @param scene The scene the effect belongs to.
  109710. * @param direction The direction the blur should be applied.
  109711. * @param kernel The size of the kernel used to blur.
  109712. * @param options The required width/height ratio to downsize to before computing the render pass.
  109713. * @param camera The camera to apply the render pass to.
  109714. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  109715. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  109716. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109717. * @param engine The engine which the post process will be applied. (default: current engine)
  109718. * @param reusable If the post process can be reused on the same frame. (default: false)
  109719. * @param textureType Type of textures used when performing the post process. (default: 0)
  109720. * @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)
  109721. */
  109722. 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);
  109723. }
  109724. }
  109725. declare module BABYLON {
  109726. /** @hidden */
  109727. export var depthOfFieldMergePixelShader: {
  109728. name: string;
  109729. shader: string;
  109730. };
  109731. }
  109732. declare module BABYLON {
  109733. /**
  109734. * Options to be set when merging outputs from the default pipeline.
  109735. */
  109736. export class DepthOfFieldMergePostProcessOptions {
  109737. /**
  109738. * The original image to merge on top of
  109739. */
  109740. originalFromInput: PostProcess;
  109741. /**
  109742. * Parameters to perform the merge of the depth of field effect
  109743. */
  109744. depthOfField?: {
  109745. circleOfConfusion: PostProcess;
  109746. blurSteps: Array<PostProcess>;
  109747. };
  109748. /**
  109749. * Parameters to perform the merge of bloom effect
  109750. */
  109751. bloom?: {
  109752. blurred: PostProcess;
  109753. weight: number;
  109754. };
  109755. }
  109756. /**
  109757. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  109758. */
  109759. export class DepthOfFieldMergePostProcess extends PostProcess {
  109760. private blurSteps;
  109761. /**
  109762. * Creates a new instance of DepthOfFieldMergePostProcess
  109763. * @param name The name of the effect.
  109764. * @param originalFromInput Post process which's input will be used for the merge.
  109765. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  109766. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  109767. * @param options The required width/height ratio to downsize to before computing the render pass.
  109768. * @param camera The camera to apply the render pass to.
  109769. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109770. * @param engine The engine which the post process will be applied. (default: current engine)
  109771. * @param reusable If the post process can be reused on the same frame. (default: false)
  109772. * @param textureType Type of textures used when performing the post process. (default: 0)
  109773. * @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)
  109774. */
  109775. 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);
  109776. /**
  109777. * Updates the effect with the current post process compile time values and recompiles the shader.
  109778. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  109779. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  109780. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  109781. * @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
  109782. * @param onCompiled Called when the shader has been compiled.
  109783. * @param onError Called if there is an error when compiling a shader.
  109784. */
  109785. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  109786. }
  109787. }
  109788. declare module BABYLON {
  109789. /**
  109790. * Specifies the level of max blur that should be applied when using the depth of field effect
  109791. */
  109792. export enum DepthOfFieldEffectBlurLevel {
  109793. /**
  109794. * Subtle blur
  109795. */
  109796. Low = 0,
  109797. /**
  109798. * Medium blur
  109799. */
  109800. Medium = 1,
  109801. /**
  109802. * Large blur
  109803. */
  109804. High = 2
  109805. }
  109806. /**
  109807. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  109808. */
  109809. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  109810. private _circleOfConfusion;
  109811. /**
  109812. * @hidden Internal, blurs from high to low
  109813. */
  109814. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  109815. private _depthOfFieldBlurY;
  109816. private _dofMerge;
  109817. /**
  109818. * @hidden Internal post processes in depth of field effect
  109819. */
  109820. _effects: Array<PostProcess>;
  109821. /**
  109822. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  109823. */
  109824. focalLength: number;
  109825. /**
  109826. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  109827. */
  109828. fStop: number;
  109829. /**
  109830. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  109831. */
  109832. focusDistance: number;
  109833. /**
  109834. * 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.
  109835. */
  109836. lensSize: number;
  109837. /**
  109838. * Creates a new instance DepthOfFieldEffect
  109839. * @param scene The scene the effect belongs to.
  109840. * @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.
  109841. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  109842. * @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)
  109843. */
  109844. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  109845. /**
  109846. * 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.
  109847. */
  109848. depthTexture: RenderTargetTexture;
  109849. /**
  109850. * Disposes each of the internal effects for a given camera.
  109851. * @param camera The camera to dispose the effect on.
  109852. */
  109853. disposeEffects(camera: Camera): void;
  109854. /**
  109855. * @hidden Internal
  109856. */
  109857. _updateEffects(): void;
  109858. /**
  109859. * Internal
  109860. * @returns if all the contained post processes are ready.
  109861. * @hidden
  109862. */
  109863. _isReady(): boolean;
  109864. }
  109865. }
  109866. declare module BABYLON {
  109867. /** @hidden */
  109868. export var displayPassPixelShader: {
  109869. name: string;
  109870. shader: string;
  109871. };
  109872. }
  109873. declare module BABYLON {
  109874. /**
  109875. * DisplayPassPostProcess which produces an output the same as it's input
  109876. */
  109877. export class DisplayPassPostProcess extends PostProcess {
  109878. /**
  109879. * Creates the DisplayPassPostProcess
  109880. * @param name The name of the effect.
  109881. * @param options The required width/height ratio to downsize to before computing the render pass.
  109882. * @param camera The camera to apply the render pass to.
  109883. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109884. * @param engine The engine which the post process will be applied. (default: current engine)
  109885. * @param reusable If the post process can be reused on the same frame. (default: false)
  109886. */
  109887. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109888. }
  109889. }
  109890. declare module BABYLON {
  109891. /** @hidden */
  109892. export var filterPixelShader: {
  109893. name: string;
  109894. shader: string;
  109895. };
  109896. }
  109897. declare module BABYLON {
  109898. /**
  109899. * Applies a kernel filter to the image
  109900. */
  109901. export class FilterPostProcess extends PostProcess {
  109902. /** The matrix to be applied to the image */
  109903. kernelMatrix: Matrix;
  109904. /**
  109905. *
  109906. * @param name The name of the effect.
  109907. * @param kernelMatrix The matrix to be applied to the image
  109908. * @param options The required width/height ratio to downsize to before computing the render pass.
  109909. * @param camera The camera to apply the render pass to.
  109910. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109911. * @param engine The engine which the post process will be applied. (default: current engine)
  109912. * @param reusable If the post process can be reused on the same frame. (default: false)
  109913. */
  109914. constructor(name: string,
  109915. /** The matrix to be applied to the image */
  109916. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  109917. }
  109918. }
  109919. declare module BABYLON {
  109920. /** @hidden */
  109921. export var fxaaPixelShader: {
  109922. name: string;
  109923. shader: string;
  109924. };
  109925. }
  109926. declare module BABYLON {
  109927. /** @hidden */
  109928. export var fxaaVertexShader: {
  109929. name: string;
  109930. shader: string;
  109931. };
  109932. }
  109933. declare module BABYLON {
  109934. /**
  109935. * Fxaa post process
  109936. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  109937. */
  109938. export class FxaaPostProcess extends PostProcess {
  109939. /** @hidden */
  109940. texelWidth: number;
  109941. /** @hidden */
  109942. texelHeight: number;
  109943. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  109944. private _getDefines;
  109945. }
  109946. }
  109947. declare module BABYLON {
  109948. /** @hidden */
  109949. export var grainPixelShader: {
  109950. name: string;
  109951. shader: string;
  109952. };
  109953. }
  109954. declare module BABYLON {
  109955. /**
  109956. * The GrainPostProcess adds noise to the image at mid luminance levels
  109957. */
  109958. export class GrainPostProcess extends PostProcess {
  109959. /**
  109960. * The intensity of the grain added (default: 30)
  109961. */
  109962. intensity: number;
  109963. /**
  109964. * If the grain should be randomized on every frame
  109965. */
  109966. animated: boolean;
  109967. /**
  109968. * Creates a new instance of @see GrainPostProcess
  109969. * @param name The name of the effect.
  109970. * @param options The required width/height ratio to downsize to before computing the render pass.
  109971. * @param camera The camera to apply the render pass to.
  109972. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109973. * @param engine The engine which the post process will be applied. (default: current engine)
  109974. * @param reusable If the post process can be reused on the same frame. (default: false)
  109975. * @param textureType Type of textures used when performing the post process. (default: 0)
  109976. * @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)
  109977. */
  109978. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  109979. }
  109980. }
  109981. declare module BABYLON {
  109982. /** @hidden */
  109983. export var highlightsPixelShader: {
  109984. name: string;
  109985. shader: string;
  109986. };
  109987. }
  109988. declare module BABYLON {
  109989. /**
  109990. * Extracts highlights from the image
  109991. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  109992. */
  109993. export class HighlightsPostProcess extends PostProcess {
  109994. /**
  109995. * Extracts highlights from the image
  109996. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  109997. * @param name The name of the effect.
  109998. * @param options The required width/height ratio to downsize to before computing the render pass.
  109999. * @param camera The camera to apply the render pass to.
  110000. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110001. * @param engine The engine which the post process will be applied. (default: current engine)
  110002. * @param reusable If the post process can be reused on the same frame. (default: false)
  110003. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  110004. */
  110005. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  110006. }
  110007. }
  110008. declare module BABYLON {
  110009. /** @hidden */
  110010. export var mrtFragmentDeclaration: {
  110011. name: string;
  110012. shader: string;
  110013. };
  110014. }
  110015. declare module BABYLON {
  110016. /** @hidden */
  110017. export var geometryPixelShader: {
  110018. name: string;
  110019. shader: string;
  110020. };
  110021. }
  110022. declare module BABYLON {
  110023. /** @hidden */
  110024. export var geometryVertexShader: {
  110025. name: string;
  110026. shader: string;
  110027. };
  110028. }
  110029. declare module BABYLON {
  110030. /**
  110031. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  110032. */
  110033. export class GeometryBufferRenderer {
  110034. /**
  110035. * Constant used to retrieve the position texture index in the G-Buffer textures array
  110036. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  110037. */
  110038. static readonly POSITION_TEXTURE_TYPE: number;
  110039. /**
  110040. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  110041. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  110042. */
  110043. static readonly VELOCITY_TEXTURE_TYPE: number;
  110044. /**
  110045. * Dictionary used to store the previous transformation matrices of each rendered mesh
  110046. * in order to compute objects velocities when enableVelocity is set to "true"
  110047. * @hidden
  110048. */
  110049. _previousTransformationMatrices: {
  110050. [index: number]: Matrix;
  110051. };
  110052. private _scene;
  110053. private _multiRenderTarget;
  110054. private _ratio;
  110055. private _enablePosition;
  110056. private _enableVelocity;
  110057. private _positionIndex;
  110058. private _velocityIndex;
  110059. protected _effect: Effect;
  110060. protected _cachedDefines: string;
  110061. /**
  110062. * Set the render list (meshes to be rendered) used in the G buffer.
  110063. */
  110064. renderList: Mesh[];
  110065. /**
  110066. * Gets wether or not G buffer are supported by the running hardware.
  110067. * This requires draw buffer supports
  110068. */
  110069. readonly isSupported: boolean;
  110070. /**
  110071. * Returns the index of the given texture type in the G-Buffer textures array
  110072. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  110073. * @returns the index of the given texture type in the G-Buffer textures array
  110074. */
  110075. getTextureIndex(textureType: number): number;
  110076. /**
  110077. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  110078. */
  110079. /**
  110080. * Sets whether or not objects positions are enabled for the G buffer.
  110081. */
  110082. enablePosition: boolean;
  110083. /**
  110084. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  110085. */
  110086. /**
  110087. * Sets wether or not objects velocities are enabled for the G buffer.
  110088. */
  110089. enableVelocity: boolean;
  110090. /**
  110091. * Gets the scene associated with the buffer.
  110092. */
  110093. readonly scene: Scene;
  110094. /**
  110095. * Gets the ratio used by the buffer during its creation.
  110096. * How big is the buffer related to the main canvas.
  110097. */
  110098. readonly ratio: number;
  110099. /** @hidden */
  110100. static _SceneComponentInitialization: (scene: Scene) => void;
  110101. /**
  110102. * Creates a new G Buffer for the scene
  110103. * @param scene The scene the buffer belongs to
  110104. * @param ratio How big is the buffer related to the main canvas.
  110105. */
  110106. constructor(scene: Scene, ratio?: number);
  110107. /**
  110108. * Checks wether everything is ready to render a submesh to the G buffer.
  110109. * @param subMesh the submesh to check readiness for
  110110. * @param useInstances is the mesh drawn using instance or not
  110111. * @returns true if ready otherwise false
  110112. */
  110113. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110114. /**
  110115. * Gets the current underlying G Buffer.
  110116. * @returns the buffer
  110117. */
  110118. getGBuffer(): MultiRenderTarget;
  110119. /**
  110120. * Gets the number of samples used to render the buffer (anti aliasing).
  110121. */
  110122. /**
  110123. * Sets the number of samples used to render the buffer (anti aliasing).
  110124. */
  110125. samples: number;
  110126. /**
  110127. * Disposes the renderer and frees up associated resources.
  110128. */
  110129. dispose(): void;
  110130. protected _createRenderTargets(): void;
  110131. }
  110132. }
  110133. declare module BABYLON {
  110134. interface Scene {
  110135. /** @hidden (Backing field) */
  110136. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  110137. /**
  110138. * Gets or Sets the current geometry buffer associated to the scene.
  110139. */
  110140. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  110141. /**
  110142. * Enables a GeometryBufferRender and associates it with the scene
  110143. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  110144. * @returns the GeometryBufferRenderer
  110145. */
  110146. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  110147. /**
  110148. * Disables the GeometryBufferRender associated with the scene
  110149. */
  110150. disableGeometryBufferRenderer(): void;
  110151. }
  110152. /**
  110153. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  110154. * in several rendering techniques.
  110155. */
  110156. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  110157. /**
  110158. * The component name helpful to identify the component in the list of scene components.
  110159. */
  110160. readonly name: string;
  110161. /**
  110162. * The scene the component belongs to.
  110163. */
  110164. scene: Scene;
  110165. /**
  110166. * Creates a new instance of the component for the given scene
  110167. * @param scene Defines the scene to register the component in
  110168. */
  110169. constructor(scene: Scene);
  110170. /**
  110171. * Registers the component in a given scene
  110172. */
  110173. register(): void;
  110174. /**
  110175. * Rebuilds the elements related to this component in case of
  110176. * context lost for instance.
  110177. */
  110178. rebuild(): void;
  110179. /**
  110180. * Disposes the component and the associated ressources
  110181. */
  110182. dispose(): void;
  110183. private _gatherRenderTargets;
  110184. }
  110185. }
  110186. declare module BABYLON {
  110187. /** @hidden */
  110188. export var motionBlurPixelShader: {
  110189. name: string;
  110190. shader: string;
  110191. };
  110192. }
  110193. declare module BABYLON {
  110194. /**
  110195. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  110196. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  110197. * As an example, all you have to do is to create the post-process:
  110198. * var mb = new BABYLON.MotionBlurPostProcess(
  110199. * 'mb', // The name of the effect.
  110200. * scene, // The scene containing the objects to blur according to their velocity.
  110201. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  110202. * camera // The camera to apply the render pass to.
  110203. * );
  110204. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  110205. */
  110206. export class MotionBlurPostProcess extends PostProcess {
  110207. /**
  110208. * Defines how much the image is blurred by the movement. Default value is equal to 1
  110209. */
  110210. motionStrength: number;
  110211. /**
  110212. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  110213. */
  110214. /**
  110215. * Sets the number of iterations to be used for motion blur quality
  110216. */
  110217. motionBlurSamples: number;
  110218. private _motionBlurSamples;
  110219. private _geometryBufferRenderer;
  110220. /**
  110221. * Creates a new instance MotionBlurPostProcess
  110222. * @param name The name of the effect.
  110223. * @param scene The scene containing the objects to blur according to their velocity.
  110224. * @param options The required width/height ratio to downsize to before computing the render pass.
  110225. * @param camera The camera to apply the render pass to.
  110226. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110227. * @param engine The engine which the post process will be applied. (default: current engine)
  110228. * @param reusable If the post process can be reused on the same frame. (default: false)
  110229. * @param textureType Type of textures used when performing the post process. (default: 0)
  110230. * @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)
  110231. */
  110232. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110233. /**
  110234. * Disposes the post process.
  110235. * @param camera The camera to dispose the post process on.
  110236. */
  110237. dispose(camera?: Camera): void;
  110238. }
  110239. }
  110240. declare module BABYLON {
  110241. /** @hidden */
  110242. export var refractionPixelShader: {
  110243. name: string;
  110244. shader: string;
  110245. };
  110246. }
  110247. declare module BABYLON {
  110248. /**
  110249. * Post process which applies a refractin texture
  110250. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  110251. */
  110252. export class RefractionPostProcess extends PostProcess {
  110253. /** the base color of the refraction (used to taint the rendering) */
  110254. color: Color3;
  110255. /** simulated refraction depth */
  110256. depth: number;
  110257. /** the coefficient of the base color (0 to remove base color tainting) */
  110258. colorLevel: number;
  110259. private _refTexture;
  110260. private _ownRefractionTexture;
  110261. /**
  110262. * Gets or sets the refraction texture
  110263. * Please note that you are responsible for disposing the texture if you set it manually
  110264. */
  110265. refractionTexture: Texture;
  110266. /**
  110267. * Initializes the RefractionPostProcess
  110268. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  110269. * @param name The name of the effect.
  110270. * @param refractionTextureUrl Url of the refraction texture to use
  110271. * @param color the base color of the refraction (used to taint the rendering)
  110272. * @param depth simulated refraction depth
  110273. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  110274. * @param camera The camera to apply the render pass to.
  110275. * @param options The required width/height ratio to downsize to before computing the render pass.
  110276. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110277. * @param engine The engine which the post process will be applied. (default: current engine)
  110278. * @param reusable If the post process can be reused on the same frame. (default: false)
  110279. */
  110280. constructor(name: string, refractionTextureUrl: string,
  110281. /** the base color of the refraction (used to taint the rendering) */
  110282. color: Color3,
  110283. /** simulated refraction depth */
  110284. depth: number,
  110285. /** the coefficient of the base color (0 to remove base color tainting) */
  110286. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  110287. /**
  110288. * Disposes of the post process
  110289. * @param camera Camera to dispose post process on
  110290. */
  110291. dispose(camera: Camera): void;
  110292. }
  110293. }
  110294. declare module BABYLON {
  110295. /** @hidden */
  110296. export var sharpenPixelShader: {
  110297. name: string;
  110298. shader: string;
  110299. };
  110300. }
  110301. declare module BABYLON {
  110302. /**
  110303. * The SharpenPostProcess applies a sharpen kernel to every pixel
  110304. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  110305. */
  110306. export class SharpenPostProcess extends PostProcess {
  110307. /**
  110308. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  110309. */
  110310. colorAmount: number;
  110311. /**
  110312. * How much sharpness should be applied (default: 0.3)
  110313. */
  110314. edgeAmount: number;
  110315. /**
  110316. * Creates a new instance ConvolutionPostProcess
  110317. * @param name The name of the effect.
  110318. * @param options The required width/height ratio to downsize to before computing the render pass.
  110319. * @param camera The camera to apply the render pass to.
  110320. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  110321. * @param engine The engine which the post process will be applied. (default: current engine)
  110322. * @param reusable If the post process can be reused on the same frame. (default: false)
  110323. * @param textureType Type of textures used when performing the post process. (default: 0)
  110324. * @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)
  110325. */
  110326. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  110327. }
  110328. }
  110329. declare module BABYLON {
  110330. /**
  110331. * PostProcessRenderPipeline
  110332. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110333. */
  110334. export class PostProcessRenderPipeline {
  110335. private engine;
  110336. private _renderEffects;
  110337. private _renderEffectsForIsolatedPass;
  110338. /**
  110339. * List of inspectable custom properties (used by the Inspector)
  110340. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  110341. */
  110342. inspectableCustomProperties: IInspectable[];
  110343. /**
  110344. * @hidden
  110345. */
  110346. protected _cameras: Camera[];
  110347. /** @hidden */
  110348. _name: string;
  110349. /**
  110350. * Gets pipeline name
  110351. */
  110352. readonly name: string;
  110353. /**
  110354. * Initializes a PostProcessRenderPipeline
  110355. * @param engine engine to add the pipeline to
  110356. * @param name name of the pipeline
  110357. */
  110358. constructor(engine: Engine, name: string);
  110359. /**
  110360. * Gets the class name
  110361. * @returns "PostProcessRenderPipeline"
  110362. */
  110363. getClassName(): string;
  110364. /**
  110365. * If all the render effects in the pipeline are supported
  110366. */
  110367. readonly isSupported: boolean;
  110368. /**
  110369. * Adds an effect to the pipeline
  110370. * @param renderEffect the effect to add
  110371. */
  110372. addEffect(renderEffect: PostProcessRenderEffect): void;
  110373. /** @hidden */
  110374. _rebuild(): void;
  110375. /** @hidden */
  110376. _enableEffect(renderEffectName: string, cameras: Camera): void;
  110377. /** @hidden */
  110378. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  110379. /** @hidden */
  110380. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  110381. /** @hidden */
  110382. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  110383. /** @hidden */
  110384. _attachCameras(cameras: Camera, unique: boolean): void;
  110385. /** @hidden */
  110386. _attachCameras(cameras: Camera[], unique: boolean): void;
  110387. /** @hidden */
  110388. _detachCameras(cameras: Camera): void;
  110389. /** @hidden */
  110390. _detachCameras(cameras: Nullable<Camera[]>): void;
  110391. /** @hidden */
  110392. _update(): void;
  110393. /** @hidden */
  110394. _reset(): void;
  110395. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  110396. /**
  110397. * Disposes of the pipeline
  110398. */
  110399. dispose(): void;
  110400. }
  110401. }
  110402. declare module BABYLON {
  110403. /**
  110404. * PostProcessRenderPipelineManager class
  110405. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110406. */
  110407. export class PostProcessRenderPipelineManager {
  110408. private _renderPipelines;
  110409. /**
  110410. * Initializes a PostProcessRenderPipelineManager
  110411. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110412. */
  110413. constructor();
  110414. /**
  110415. * Gets the list of supported render pipelines
  110416. */
  110417. readonly supportedPipelines: PostProcessRenderPipeline[];
  110418. /**
  110419. * Adds a pipeline to the manager
  110420. * @param renderPipeline The pipeline to add
  110421. */
  110422. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  110423. /**
  110424. * Attaches a camera to the pipeline
  110425. * @param renderPipelineName The name of the pipeline to attach to
  110426. * @param cameras the camera to attach
  110427. * @param unique if the camera can be attached multiple times to the pipeline
  110428. */
  110429. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  110430. /**
  110431. * Detaches a camera from the pipeline
  110432. * @param renderPipelineName The name of the pipeline to detach from
  110433. * @param cameras the camera to detach
  110434. */
  110435. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  110436. /**
  110437. * Enables an effect by name on a pipeline
  110438. * @param renderPipelineName the name of the pipeline to enable the effect in
  110439. * @param renderEffectName the name of the effect to enable
  110440. * @param cameras the cameras that the effect should be enabled on
  110441. */
  110442. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  110443. /**
  110444. * Disables an effect by name on a pipeline
  110445. * @param renderPipelineName the name of the pipeline to disable the effect in
  110446. * @param renderEffectName the name of the effect to disable
  110447. * @param cameras the cameras that the effect should be disabled on
  110448. */
  110449. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  110450. /**
  110451. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  110452. */
  110453. update(): void;
  110454. /** @hidden */
  110455. _rebuild(): void;
  110456. /**
  110457. * Disposes of the manager and pipelines
  110458. */
  110459. dispose(): void;
  110460. }
  110461. }
  110462. declare module BABYLON {
  110463. interface Scene {
  110464. /** @hidden (Backing field) */
  110465. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  110466. /**
  110467. * Gets the postprocess render pipeline manager
  110468. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  110469. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  110470. */
  110471. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  110472. }
  110473. /**
  110474. * Defines the Render Pipeline scene component responsible to rendering pipelines
  110475. */
  110476. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  110477. /**
  110478. * The component name helpfull to identify the component in the list of scene components.
  110479. */
  110480. readonly name: string;
  110481. /**
  110482. * The scene the component belongs to.
  110483. */
  110484. scene: Scene;
  110485. /**
  110486. * Creates a new instance of the component for the given scene
  110487. * @param scene Defines the scene to register the component in
  110488. */
  110489. constructor(scene: Scene);
  110490. /**
  110491. * Registers the component in a given scene
  110492. */
  110493. register(): void;
  110494. /**
  110495. * Rebuilds the elements related to this component in case of
  110496. * context lost for instance.
  110497. */
  110498. rebuild(): void;
  110499. /**
  110500. * Disposes the component and the associated ressources
  110501. */
  110502. dispose(): void;
  110503. private _gatherRenderTargets;
  110504. }
  110505. }
  110506. declare module BABYLON {
  110507. /**
  110508. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  110509. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  110510. */
  110511. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  110512. private _scene;
  110513. private _camerasToBeAttached;
  110514. /**
  110515. * ID of the sharpen post process,
  110516. */
  110517. private readonly SharpenPostProcessId;
  110518. /**
  110519. * @ignore
  110520. * ID of the image processing post process;
  110521. */
  110522. readonly ImageProcessingPostProcessId: string;
  110523. /**
  110524. * @ignore
  110525. * ID of the Fast Approximate Anti-Aliasing post process;
  110526. */
  110527. readonly FxaaPostProcessId: string;
  110528. /**
  110529. * ID of the chromatic aberration post process,
  110530. */
  110531. private readonly ChromaticAberrationPostProcessId;
  110532. /**
  110533. * ID of the grain post process
  110534. */
  110535. private readonly GrainPostProcessId;
  110536. /**
  110537. * Sharpen post process which will apply a sharpen convolution to enhance edges
  110538. */
  110539. sharpen: SharpenPostProcess;
  110540. private _sharpenEffect;
  110541. private bloom;
  110542. /**
  110543. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  110544. */
  110545. depthOfField: DepthOfFieldEffect;
  110546. /**
  110547. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  110548. */
  110549. fxaa: FxaaPostProcess;
  110550. /**
  110551. * Image post processing pass used to perform operations such as tone mapping or color grading.
  110552. */
  110553. imageProcessing: ImageProcessingPostProcess;
  110554. /**
  110555. * Chromatic aberration post process which will shift rgb colors in the image
  110556. */
  110557. chromaticAberration: ChromaticAberrationPostProcess;
  110558. private _chromaticAberrationEffect;
  110559. /**
  110560. * Grain post process which add noise to the image
  110561. */
  110562. grain: GrainPostProcess;
  110563. private _grainEffect;
  110564. /**
  110565. * Glow post process which adds a glow to emissive areas of the image
  110566. */
  110567. private _glowLayer;
  110568. /**
  110569. * Animations which can be used to tweak settings over a period of time
  110570. */
  110571. animations: Animation[];
  110572. private _imageProcessingConfigurationObserver;
  110573. private _sharpenEnabled;
  110574. private _bloomEnabled;
  110575. private _depthOfFieldEnabled;
  110576. private _depthOfFieldBlurLevel;
  110577. private _fxaaEnabled;
  110578. private _imageProcessingEnabled;
  110579. private _defaultPipelineTextureType;
  110580. private _bloomScale;
  110581. private _chromaticAberrationEnabled;
  110582. private _grainEnabled;
  110583. private _buildAllowed;
  110584. /**
  110585. * Gets active scene
  110586. */
  110587. readonly scene: Scene;
  110588. /**
  110589. * Enable or disable the sharpen process from the pipeline
  110590. */
  110591. sharpenEnabled: boolean;
  110592. private _resizeObserver;
  110593. private _hardwareScaleLevel;
  110594. private _bloomKernel;
  110595. /**
  110596. * Specifies the size of the bloom blur kernel, relative to the final output size
  110597. */
  110598. bloomKernel: number;
  110599. /**
  110600. * Specifies the weight of the bloom in the final rendering
  110601. */
  110602. private _bloomWeight;
  110603. /**
  110604. * Specifies the luma threshold for the area that will be blurred by the bloom
  110605. */
  110606. private _bloomThreshold;
  110607. private _hdr;
  110608. /**
  110609. * The strength of the bloom.
  110610. */
  110611. bloomWeight: number;
  110612. /**
  110613. * The strength of the bloom.
  110614. */
  110615. bloomThreshold: number;
  110616. /**
  110617. * The scale of the bloom, lower value will provide better performance.
  110618. */
  110619. bloomScale: number;
  110620. /**
  110621. * Enable or disable the bloom from the pipeline
  110622. */
  110623. bloomEnabled: boolean;
  110624. private _rebuildBloom;
  110625. /**
  110626. * If the depth of field is enabled.
  110627. */
  110628. depthOfFieldEnabled: boolean;
  110629. /**
  110630. * Blur level of the depth of field effect. (Higher blur will effect performance)
  110631. */
  110632. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  110633. /**
  110634. * If the anti aliasing is enabled.
  110635. */
  110636. fxaaEnabled: boolean;
  110637. private _samples;
  110638. /**
  110639. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  110640. */
  110641. samples: number;
  110642. /**
  110643. * If image processing is enabled.
  110644. */
  110645. imageProcessingEnabled: boolean;
  110646. /**
  110647. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  110648. */
  110649. glowLayerEnabled: boolean;
  110650. /**
  110651. * Enable or disable the chromaticAberration process from the pipeline
  110652. */
  110653. chromaticAberrationEnabled: boolean;
  110654. /**
  110655. * Enable or disable the grain process from the pipeline
  110656. */
  110657. grainEnabled: boolean;
  110658. /**
  110659. * @constructor
  110660. * @param name - The rendering pipeline name (default: "")
  110661. * @param hdr - If high dynamic range textures should be used (default: true)
  110662. * @param scene - The scene linked to this pipeline (default: the last created scene)
  110663. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  110664. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  110665. */
  110666. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  110667. /**
  110668. * Get the class name
  110669. * @returns "DefaultRenderingPipeline"
  110670. */
  110671. getClassName(): string;
  110672. /**
  110673. * Force the compilation of the entire pipeline.
  110674. */
  110675. prepare(): void;
  110676. private _hasCleared;
  110677. private _prevPostProcess;
  110678. private _prevPrevPostProcess;
  110679. private _setAutoClearAndTextureSharing;
  110680. private _depthOfFieldSceneObserver;
  110681. private _buildPipeline;
  110682. private _disposePostProcesses;
  110683. /**
  110684. * Adds a camera to the pipeline
  110685. * @param camera the camera to be added
  110686. */
  110687. addCamera(camera: Camera): void;
  110688. /**
  110689. * Removes a camera from the pipeline
  110690. * @param camera the camera to remove
  110691. */
  110692. removeCamera(camera: Camera): void;
  110693. /**
  110694. * Dispose of the pipeline and stop all post processes
  110695. */
  110696. dispose(): void;
  110697. /**
  110698. * Serialize the rendering pipeline (Used when exporting)
  110699. * @returns the serialized object
  110700. */
  110701. serialize(): any;
  110702. /**
  110703. * Parse the serialized pipeline
  110704. * @param source Source pipeline.
  110705. * @param scene The scene to load the pipeline to.
  110706. * @param rootUrl The URL of the serialized pipeline.
  110707. * @returns An instantiated pipeline from the serialized object.
  110708. */
  110709. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  110710. }
  110711. }
  110712. declare module BABYLON {
  110713. /** @hidden */
  110714. export var lensHighlightsPixelShader: {
  110715. name: string;
  110716. shader: string;
  110717. };
  110718. }
  110719. declare module BABYLON {
  110720. /** @hidden */
  110721. export var depthOfFieldPixelShader: {
  110722. name: string;
  110723. shader: string;
  110724. };
  110725. }
  110726. declare module BABYLON {
  110727. /**
  110728. * BABYLON.JS Chromatic Aberration GLSL Shader
  110729. * Author: Olivier Guyot
  110730. * Separates very slightly R, G and B colors on the edges of the screen
  110731. * Inspired by Francois Tarlier & Martins Upitis
  110732. */
  110733. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  110734. /**
  110735. * @ignore
  110736. * The chromatic aberration PostProcess id in the pipeline
  110737. */
  110738. LensChromaticAberrationEffect: string;
  110739. /**
  110740. * @ignore
  110741. * The highlights enhancing PostProcess id in the pipeline
  110742. */
  110743. HighlightsEnhancingEffect: string;
  110744. /**
  110745. * @ignore
  110746. * The depth-of-field PostProcess id in the pipeline
  110747. */
  110748. LensDepthOfFieldEffect: string;
  110749. private _scene;
  110750. private _depthTexture;
  110751. private _grainTexture;
  110752. private _chromaticAberrationPostProcess;
  110753. private _highlightsPostProcess;
  110754. private _depthOfFieldPostProcess;
  110755. private _edgeBlur;
  110756. private _grainAmount;
  110757. private _chromaticAberration;
  110758. private _distortion;
  110759. private _highlightsGain;
  110760. private _highlightsThreshold;
  110761. private _dofDistance;
  110762. private _dofAperture;
  110763. private _dofDarken;
  110764. private _dofPentagon;
  110765. private _blurNoise;
  110766. /**
  110767. * @constructor
  110768. *
  110769. * Effect parameters are as follow:
  110770. * {
  110771. * chromatic_aberration: number; // from 0 to x (1 for realism)
  110772. * edge_blur: number; // from 0 to x (1 for realism)
  110773. * distortion: number; // from 0 to x (1 for realism)
  110774. * grain_amount: number; // from 0 to 1
  110775. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  110776. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  110777. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  110778. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  110779. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  110780. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  110781. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  110782. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  110783. * }
  110784. * Note: if an effect parameter is unset, effect is disabled
  110785. *
  110786. * @param name The rendering pipeline name
  110787. * @param parameters - An object containing all parameters (see above)
  110788. * @param scene The scene linked to this pipeline
  110789. * @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)
  110790. * @param cameras The array of cameras that the rendering pipeline will be attached to
  110791. */
  110792. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  110793. /**
  110794. * Get the class name
  110795. * @returns "LensRenderingPipeline"
  110796. */
  110797. getClassName(): string;
  110798. /**
  110799. * Gets associated scene
  110800. */
  110801. readonly scene: Scene;
  110802. /**
  110803. * Gets or sets the edge blur
  110804. */
  110805. edgeBlur: number;
  110806. /**
  110807. * Gets or sets the grain amount
  110808. */
  110809. grainAmount: number;
  110810. /**
  110811. * Gets or sets the chromatic aberration amount
  110812. */
  110813. chromaticAberration: number;
  110814. /**
  110815. * Gets or sets the depth of field aperture
  110816. */
  110817. dofAperture: number;
  110818. /**
  110819. * Gets or sets the edge distortion
  110820. */
  110821. edgeDistortion: number;
  110822. /**
  110823. * Gets or sets the depth of field distortion
  110824. */
  110825. dofDistortion: number;
  110826. /**
  110827. * Gets or sets the darken out of focus amount
  110828. */
  110829. darkenOutOfFocus: number;
  110830. /**
  110831. * Gets or sets a boolean indicating if blur noise is enabled
  110832. */
  110833. blurNoise: boolean;
  110834. /**
  110835. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  110836. */
  110837. pentagonBokeh: boolean;
  110838. /**
  110839. * Gets or sets the highlight grain amount
  110840. */
  110841. highlightsGain: number;
  110842. /**
  110843. * Gets or sets the highlight threshold
  110844. */
  110845. highlightsThreshold: number;
  110846. /**
  110847. * Sets the amount of blur at the edges
  110848. * @param amount blur amount
  110849. */
  110850. setEdgeBlur(amount: number): void;
  110851. /**
  110852. * Sets edge blur to 0
  110853. */
  110854. disableEdgeBlur(): void;
  110855. /**
  110856. * Sets the amout of grain
  110857. * @param amount Amount of grain
  110858. */
  110859. setGrainAmount(amount: number): void;
  110860. /**
  110861. * Set grain amount to 0
  110862. */
  110863. disableGrain(): void;
  110864. /**
  110865. * Sets the chromatic aberration amount
  110866. * @param amount amount of chromatic aberration
  110867. */
  110868. setChromaticAberration(amount: number): void;
  110869. /**
  110870. * Sets chromatic aberration amount to 0
  110871. */
  110872. disableChromaticAberration(): void;
  110873. /**
  110874. * Sets the EdgeDistortion amount
  110875. * @param amount amount of EdgeDistortion
  110876. */
  110877. setEdgeDistortion(amount: number): void;
  110878. /**
  110879. * Sets edge distortion to 0
  110880. */
  110881. disableEdgeDistortion(): void;
  110882. /**
  110883. * Sets the FocusDistance amount
  110884. * @param amount amount of FocusDistance
  110885. */
  110886. setFocusDistance(amount: number): void;
  110887. /**
  110888. * Disables depth of field
  110889. */
  110890. disableDepthOfField(): void;
  110891. /**
  110892. * Sets the Aperture amount
  110893. * @param amount amount of Aperture
  110894. */
  110895. setAperture(amount: number): void;
  110896. /**
  110897. * Sets the DarkenOutOfFocus amount
  110898. * @param amount amount of DarkenOutOfFocus
  110899. */
  110900. setDarkenOutOfFocus(amount: number): void;
  110901. private _pentagonBokehIsEnabled;
  110902. /**
  110903. * Creates a pentagon bokeh effect
  110904. */
  110905. enablePentagonBokeh(): void;
  110906. /**
  110907. * Disables the pentagon bokeh effect
  110908. */
  110909. disablePentagonBokeh(): void;
  110910. /**
  110911. * Enables noise blur
  110912. */
  110913. enableNoiseBlur(): void;
  110914. /**
  110915. * Disables noise blur
  110916. */
  110917. disableNoiseBlur(): void;
  110918. /**
  110919. * Sets the HighlightsGain amount
  110920. * @param amount amount of HighlightsGain
  110921. */
  110922. setHighlightsGain(amount: number): void;
  110923. /**
  110924. * Sets the HighlightsThreshold amount
  110925. * @param amount amount of HighlightsThreshold
  110926. */
  110927. setHighlightsThreshold(amount: number): void;
  110928. /**
  110929. * Disables highlights
  110930. */
  110931. disableHighlights(): void;
  110932. /**
  110933. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  110934. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  110935. */
  110936. dispose(disableDepthRender?: boolean): void;
  110937. private _createChromaticAberrationPostProcess;
  110938. private _createHighlightsPostProcess;
  110939. private _createDepthOfFieldPostProcess;
  110940. private _createGrainTexture;
  110941. }
  110942. }
  110943. declare module BABYLON {
  110944. /** @hidden */
  110945. export var ssao2PixelShader: {
  110946. name: string;
  110947. shader: string;
  110948. };
  110949. }
  110950. declare module BABYLON {
  110951. /** @hidden */
  110952. export var ssaoCombinePixelShader: {
  110953. name: string;
  110954. shader: string;
  110955. };
  110956. }
  110957. declare module BABYLON {
  110958. /**
  110959. * Render pipeline to produce ssao effect
  110960. */
  110961. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  110962. /**
  110963. * @ignore
  110964. * The PassPostProcess id in the pipeline that contains the original scene color
  110965. */
  110966. SSAOOriginalSceneColorEffect: string;
  110967. /**
  110968. * @ignore
  110969. * The SSAO PostProcess id in the pipeline
  110970. */
  110971. SSAORenderEffect: string;
  110972. /**
  110973. * @ignore
  110974. * The horizontal blur PostProcess id in the pipeline
  110975. */
  110976. SSAOBlurHRenderEffect: string;
  110977. /**
  110978. * @ignore
  110979. * The vertical blur PostProcess id in the pipeline
  110980. */
  110981. SSAOBlurVRenderEffect: string;
  110982. /**
  110983. * @ignore
  110984. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  110985. */
  110986. SSAOCombineRenderEffect: string;
  110987. /**
  110988. * The output strength of the SSAO post-process. Default value is 1.0.
  110989. */
  110990. totalStrength: number;
  110991. /**
  110992. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  110993. */
  110994. maxZ: number;
  110995. /**
  110996. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  110997. */
  110998. minZAspect: number;
  110999. private _samples;
  111000. /**
  111001. * Number of samples used for the SSAO calculations. Default value is 8
  111002. */
  111003. samples: number;
  111004. private _textureSamples;
  111005. /**
  111006. * Number of samples to use for antialiasing
  111007. */
  111008. textureSamples: number;
  111009. /**
  111010. * Ratio object used for SSAO ratio and blur ratio
  111011. */
  111012. private _ratio;
  111013. /**
  111014. * Dynamically generated sphere sampler.
  111015. */
  111016. private _sampleSphere;
  111017. /**
  111018. * Blur filter offsets
  111019. */
  111020. private _samplerOffsets;
  111021. private _expensiveBlur;
  111022. /**
  111023. * If bilateral blur should be used
  111024. */
  111025. expensiveBlur: boolean;
  111026. /**
  111027. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  111028. */
  111029. radius: number;
  111030. /**
  111031. * The base color of the SSAO post-process
  111032. * The final result is "base + ssao" between [0, 1]
  111033. */
  111034. base: number;
  111035. /**
  111036. * Support test.
  111037. */
  111038. static readonly IsSupported: boolean;
  111039. private _scene;
  111040. private _depthTexture;
  111041. private _normalTexture;
  111042. private _randomTexture;
  111043. private _originalColorPostProcess;
  111044. private _ssaoPostProcess;
  111045. private _blurHPostProcess;
  111046. private _blurVPostProcess;
  111047. private _ssaoCombinePostProcess;
  111048. private _firstUpdate;
  111049. /**
  111050. * Gets active scene
  111051. */
  111052. readonly scene: Scene;
  111053. /**
  111054. * @constructor
  111055. * @param name The rendering pipeline name
  111056. * @param scene The scene linked to this pipeline
  111057. * @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 }
  111058. * @param cameras The array of cameras that the rendering pipeline will be attached to
  111059. */
  111060. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  111061. /**
  111062. * Get the class name
  111063. * @returns "SSAO2RenderingPipeline"
  111064. */
  111065. getClassName(): string;
  111066. /**
  111067. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  111068. */
  111069. dispose(disableGeometryBufferRenderer?: boolean): void;
  111070. private _createBlurPostProcess;
  111071. /** @hidden */
  111072. _rebuild(): void;
  111073. private _bits;
  111074. private _radicalInverse_VdC;
  111075. private _hammersley;
  111076. private _hemisphereSample_uniform;
  111077. private _generateHemisphere;
  111078. private _createSSAOPostProcess;
  111079. private _createSSAOCombinePostProcess;
  111080. private _createRandomTexture;
  111081. /**
  111082. * Serialize the rendering pipeline (Used when exporting)
  111083. * @returns the serialized object
  111084. */
  111085. serialize(): any;
  111086. /**
  111087. * Parse the serialized pipeline
  111088. * @param source Source pipeline.
  111089. * @param scene The scene to load the pipeline to.
  111090. * @param rootUrl The URL of the serialized pipeline.
  111091. * @returns An instantiated pipeline from the serialized object.
  111092. */
  111093. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  111094. }
  111095. }
  111096. declare module BABYLON {
  111097. /** @hidden */
  111098. export var ssaoPixelShader: {
  111099. name: string;
  111100. shader: string;
  111101. };
  111102. }
  111103. declare module BABYLON {
  111104. /**
  111105. * Render pipeline to produce ssao effect
  111106. */
  111107. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  111108. /**
  111109. * @ignore
  111110. * The PassPostProcess id in the pipeline that contains the original scene color
  111111. */
  111112. SSAOOriginalSceneColorEffect: string;
  111113. /**
  111114. * @ignore
  111115. * The SSAO PostProcess id in the pipeline
  111116. */
  111117. SSAORenderEffect: string;
  111118. /**
  111119. * @ignore
  111120. * The horizontal blur PostProcess id in the pipeline
  111121. */
  111122. SSAOBlurHRenderEffect: string;
  111123. /**
  111124. * @ignore
  111125. * The vertical blur PostProcess id in the pipeline
  111126. */
  111127. SSAOBlurVRenderEffect: string;
  111128. /**
  111129. * @ignore
  111130. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  111131. */
  111132. SSAOCombineRenderEffect: string;
  111133. /**
  111134. * The output strength of the SSAO post-process. Default value is 1.0.
  111135. */
  111136. totalStrength: number;
  111137. /**
  111138. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  111139. */
  111140. radius: number;
  111141. /**
  111142. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  111143. * Must not be equal to fallOff and superior to fallOff.
  111144. * Default value is 0.0075
  111145. */
  111146. area: number;
  111147. /**
  111148. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  111149. * Must not be equal to area and inferior to area.
  111150. * Default value is 0.000001
  111151. */
  111152. fallOff: number;
  111153. /**
  111154. * The base color of the SSAO post-process
  111155. * The final result is "base + ssao" between [0, 1]
  111156. */
  111157. base: number;
  111158. private _scene;
  111159. private _depthTexture;
  111160. private _randomTexture;
  111161. private _originalColorPostProcess;
  111162. private _ssaoPostProcess;
  111163. private _blurHPostProcess;
  111164. private _blurVPostProcess;
  111165. private _ssaoCombinePostProcess;
  111166. private _firstUpdate;
  111167. /**
  111168. * Gets active scene
  111169. */
  111170. readonly scene: Scene;
  111171. /**
  111172. * @constructor
  111173. * @param name - The rendering pipeline name
  111174. * @param scene - The scene linked to this pipeline
  111175. * @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 }
  111176. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  111177. */
  111178. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  111179. /**
  111180. * Get the class name
  111181. * @returns "SSAORenderingPipeline"
  111182. */
  111183. getClassName(): string;
  111184. /**
  111185. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  111186. */
  111187. dispose(disableDepthRender?: boolean): void;
  111188. private _createBlurPostProcess;
  111189. /** @hidden */
  111190. _rebuild(): void;
  111191. private _createSSAOPostProcess;
  111192. private _createSSAOCombinePostProcess;
  111193. private _createRandomTexture;
  111194. }
  111195. }
  111196. declare module BABYLON {
  111197. /** @hidden */
  111198. export var standardPixelShader: {
  111199. name: string;
  111200. shader: string;
  111201. };
  111202. }
  111203. declare module BABYLON {
  111204. /**
  111205. * Standard rendering pipeline
  111206. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  111207. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  111208. */
  111209. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  111210. /**
  111211. * Public members
  111212. */
  111213. /**
  111214. * Post-process which contains the original scene color before the pipeline applies all the effects
  111215. */
  111216. originalPostProcess: Nullable<PostProcess>;
  111217. /**
  111218. * Post-process used to down scale an image x4
  111219. */
  111220. downSampleX4PostProcess: Nullable<PostProcess>;
  111221. /**
  111222. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  111223. */
  111224. brightPassPostProcess: Nullable<PostProcess>;
  111225. /**
  111226. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  111227. */
  111228. blurHPostProcesses: PostProcess[];
  111229. /**
  111230. * Post-process array storing all the vertical blur post-processes used by the pipeline
  111231. */
  111232. blurVPostProcesses: PostProcess[];
  111233. /**
  111234. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  111235. */
  111236. textureAdderPostProcess: Nullable<PostProcess>;
  111237. /**
  111238. * Post-process used to create volumetric lighting effect
  111239. */
  111240. volumetricLightPostProcess: Nullable<PostProcess>;
  111241. /**
  111242. * Post-process used to smooth the previous volumetric light post-process on the X axis
  111243. */
  111244. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  111245. /**
  111246. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  111247. */
  111248. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  111249. /**
  111250. * Post-process used to merge the volumetric light effect and the real scene color
  111251. */
  111252. volumetricLightMergePostProces: Nullable<PostProcess>;
  111253. /**
  111254. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  111255. */
  111256. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  111257. /**
  111258. * Base post-process used to calculate the average luminance of the final image for HDR
  111259. */
  111260. luminancePostProcess: Nullable<PostProcess>;
  111261. /**
  111262. * Post-processes used to create down sample post-processes in order to get
  111263. * the average luminance of the final image for HDR
  111264. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  111265. */
  111266. luminanceDownSamplePostProcesses: PostProcess[];
  111267. /**
  111268. * Post-process used to create a HDR effect (light adaptation)
  111269. */
  111270. hdrPostProcess: Nullable<PostProcess>;
  111271. /**
  111272. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  111273. */
  111274. textureAdderFinalPostProcess: Nullable<PostProcess>;
  111275. /**
  111276. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  111277. */
  111278. lensFlareFinalPostProcess: Nullable<PostProcess>;
  111279. /**
  111280. * Post-process used to merge the final HDR post-process and the real scene color
  111281. */
  111282. hdrFinalPostProcess: Nullable<PostProcess>;
  111283. /**
  111284. * Post-process used to create a lens flare effect
  111285. */
  111286. lensFlarePostProcess: Nullable<PostProcess>;
  111287. /**
  111288. * Post-process that merges the result of the lens flare post-process and the real scene color
  111289. */
  111290. lensFlareComposePostProcess: Nullable<PostProcess>;
  111291. /**
  111292. * Post-process used to create a motion blur effect
  111293. */
  111294. motionBlurPostProcess: Nullable<PostProcess>;
  111295. /**
  111296. * Post-process used to create a depth of field effect
  111297. */
  111298. depthOfFieldPostProcess: Nullable<PostProcess>;
  111299. /**
  111300. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  111301. */
  111302. fxaaPostProcess: Nullable<FxaaPostProcess>;
  111303. /**
  111304. * Represents the brightness threshold in order to configure the illuminated surfaces
  111305. */
  111306. brightThreshold: number;
  111307. /**
  111308. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  111309. */
  111310. blurWidth: number;
  111311. /**
  111312. * Sets if the blur for highlighted surfaces must be only horizontal
  111313. */
  111314. horizontalBlur: boolean;
  111315. /**
  111316. * Sets the overall exposure used by the pipeline
  111317. */
  111318. exposure: number;
  111319. /**
  111320. * Texture used typically to simulate "dirty" on camera lens
  111321. */
  111322. lensTexture: Nullable<Texture>;
  111323. /**
  111324. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  111325. */
  111326. volumetricLightCoefficient: number;
  111327. /**
  111328. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  111329. */
  111330. volumetricLightPower: number;
  111331. /**
  111332. * Used the set the blur intensity to smooth the volumetric lights
  111333. */
  111334. volumetricLightBlurScale: number;
  111335. /**
  111336. * Light (spot or directional) used to generate the volumetric lights rays
  111337. * The source light must have a shadow generate so the pipeline can get its
  111338. * depth map
  111339. */
  111340. sourceLight: Nullable<SpotLight | DirectionalLight>;
  111341. /**
  111342. * For eye adaptation, represents the minimum luminance the eye can see
  111343. */
  111344. hdrMinimumLuminance: number;
  111345. /**
  111346. * For eye adaptation, represents the decrease luminance speed
  111347. */
  111348. hdrDecreaseRate: number;
  111349. /**
  111350. * For eye adaptation, represents the increase luminance speed
  111351. */
  111352. hdrIncreaseRate: number;
  111353. /**
  111354. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  111355. */
  111356. lensColorTexture: Nullable<Texture>;
  111357. /**
  111358. * The overall strengh for the lens flare effect
  111359. */
  111360. lensFlareStrength: number;
  111361. /**
  111362. * Dispersion coefficient for lens flare ghosts
  111363. */
  111364. lensFlareGhostDispersal: number;
  111365. /**
  111366. * Main lens flare halo width
  111367. */
  111368. lensFlareHaloWidth: number;
  111369. /**
  111370. * Based on the lens distortion effect, defines how much the lens flare result
  111371. * is distorted
  111372. */
  111373. lensFlareDistortionStrength: number;
  111374. /**
  111375. * Lens star texture must be used to simulate rays on the flares and is available
  111376. * in the documentation
  111377. */
  111378. lensStarTexture: Nullable<Texture>;
  111379. /**
  111380. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  111381. * flare effect by taking account of the dirt texture
  111382. */
  111383. lensFlareDirtTexture: Nullable<Texture>;
  111384. /**
  111385. * Represents the focal length for the depth of field effect
  111386. */
  111387. depthOfFieldDistance: number;
  111388. /**
  111389. * Represents the blur intensity for the blurred part of the depth of field effect
  111390. */
  111391. depthOfFieldBlurWidth: number;
  111392. /**
  111393. * For motion blur, defines how much the image is blurred by the movement
  111394. */
  111395. motionStrength: number;
  111396. /**
  111397. * List of animations for the pipeline (IAnimatable implementation)
  111398. */
  111399. animations: Animation[];
  111400. /**
  111401. * Private members
  111402. */
  111403. private _scene;
  111404. private _currentDepthOfFieldSource;
  111405. private _basePostProcess;
  111406. private _hdrCurrentLuminance;
  111407. private _floatTextureType;
  111408. private _ratio;
  111409. private _bloomEnabled;
  111410. private _depthOfFieldEnabled;
  111411. private _vlsEnabled;
  111412. private _lensFlareEnabled;
  111413. private _hdrEnabled;
  111414. private _motionBlurEnabled;
  111415. private _fxaaEnabled;
  111416. private _motionBlurSamples;
  111417. private _volumetricLightStepsCount;
  111418. private _samples;
  111419. /**
  111420. * @ignore
  111421. * Specifies if the bloom pipeline is enabled
  111422. */
  111423. BloomEnabled: boolean;
  111424. /**
  111425. * @ignore
  111426. * Specifies if the depth of field pipeline is enabed
  111427. */
  111428. DepthOfFieldEnabled: boolean;
  111429. /**
  111430. * @ignore
  111431. * Specifies if the lens flare pipeline is enabed
  111432. */
  111433. LensFlareEnabled: boolean;
  111434. /**
  111435. * @ignore
  111436. * Specifies if the HDR pipeline is enabled
  111437. */
  111438. HDREnabled: boolean;
  111439. /**
  111440. * @ignore
  111441. * Specifies if the volumetric lights scattering effect is enabled
  111442. */
  111443. VLSEnabled: boolean;
  111444. /**
  111445. * @ignore
  111446. * Specifies if the motion blur effect is enabled
  111447. */
  111448. MotionBlurEnabled: boolean;
  111449. /**
  111450. * Specifies if anti-aliasing is enabled
  111451. */
  111452. fxaaEnabled: boolean;
  111453. /**
  111454. * Specifies the number of steps used to calculate the volumetric lights
  111455. * Typically in interval [50, 200]
  111456. */
  111457. volumetricLightStepsCount: number;
  111458. /**
  111459. * Specifies the number of samples used for the motion blur effect
  111460. * Typically in interval [16, 64]
  111461. */
  111462. motionBlurSamples: number;
  111463. /**
  111464. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  111465. */
  111466. samples: number;
  111467. /**
  111468. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  111469. * @constructor
  111470. * @param name The rendering pipeline name
  111471. * @param scene The scene linked to this pipeline
  111472. * @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)
  111473. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  111474. * @param cameras The array of cameras that the rendering pipeline will be attached to
  111475. */
  111476. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  111477. private _buildPipeline;
  111478. private _createDownSampleX4PostProcess;
  111479. private _createBrightPassPostProcess;
  111480. private _createBlurPostProcesses;
  111481. private _createTextureAdderPostProcess;
  111482. private _createVolumetricLightPostProcess;
  111483. private _createLuminancePostProcesses;
  111484. private _createHdrPostProcess;
  111485. private _createLensFlarePostProcess;
  111486. private _createDepthOfFieldPostProcess;
  111487. private _createMotionBlurPostProcess;
  111488. private _getDepthTexture;
  111489. private _disposePostProcesses;
  111490. /**
  111491. * Dispose of the pipeline and stop all post processes
  111492. */
  111493. dispose(): void;
  111494. /**
  111495. * Serialize the rendering pipeline (Used when exporting)
  111496. * @returns the serialized object
  111497. */
  111498. serialize(): any;
  111499. /**
  111500. * Parse the serialized pipeline
  111501. * @param source Source pipeline.
  111502. * @param scene The scene to load the pipeline to.
  111503. * @param rootUrl The URL of the serialized pipeline.
  111504. * @returns An instantiated pipeline from the serialized object.
  111505. */
  111506. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  111507. /**
  111508. * Luminance steps
  111509. */
  111510. static LuminanceSteps: number;
  111511. }
  111512. }
  111513. declare module BABYLON {
  111514. /** @hidden */
  111515. export var tonemapPixelShader: {
  111516. name: string;
  111517. shader: string;
  111518. };
  111519. }
  111520. declare module BABYLON {
  111521. /** Defines operator used for tonemapping */
  111522. export enum TonemappingOperator {
  111523. /** Hable */
  111524. Hable = 0,
  111525. /** Reinhard */
  111526. Reinhard = 1,
  111527. /** HejiDawson */
  111528. HejiDawson = 2,
  111529. /** Photographic */
  111530. Photographic = 3
  111531. }
  111532. /**
  111533. * Defines a post process to apply tone mapping
  111534. */
  111535. export class TonemapPostProcess extends PostProcess {
  111536. private _operator;
  111537. /** Defines the required exposure adjustement */
  111538. exposureAdjustment: number;
  111539. /**
  111540. * Creates a new TonemapPostProcess
  111541. * @param name defines the name of the postprocess
  111542. * @param _operator defines the operator to use
  111543. * @param exposureAdjustment defines the required exposure adjustement
  111544. * @param camera defines the camera to use (can be null)
  111545. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  111546. * @param engine defines the hosting engine (can be ignore if camera is set)
  111547. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  111548. */
  111549. constructor(name: string, _operator: TonemappingOperator,
  111550. /** Defines the required exposure adjustement */
  111551. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  111552. }
  111553. }
  111554. declare module BABYLON {
  111555. /** @hidden */
  111556. export var depthVertexShader: {
  111557. name: string;
  111558. shader: string;
  111559. };
  111560. }
  111561. declare module BABYLON {
  111562. /** @hidden */
  111563. export var volumetricLightScatteringPixelShader: {
  111564. name: string;
  111565. shader: string;
  111566. };
  111567. }
  111568. declare module BABYLON {
  111569. /** @hidden */
  111570. export var volumetricLightScatteringPassPixelShader: {
  111571. name: string;
  111572. shader: string;
  111573. };
  111574. }
  111575. declare module BABYLON {
  111576. /**
  111577. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  111578. */
  111579. export class VolumetricLightScatteringPostProcess extends PostProcess {
  111580. private _volumetricLightScatteringPass;
  111581. private _volumetricLightScatteringRTT;
  111582. private _viewPort;
  111583. private _screenCoordinates;
  111584. private _cachedDefines;
  111585. /**
  111586. * If not undefined, the mesh position is computed from the attached node position
  111587. */
  111588. attachedNode: {
  111589. position: Vector3;
  111590. };
  111591. /**
  111592. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  111593. */
  111594. customMeshPosition: Vector3;
  111595. /**
  111596. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  111597. */
  111598. useCustomMeshPosition: boolean;
  111599. /**
  111600. * If the post-process should inverse the light scattering direction
  111601. */
  111602. invert: boolean;
  111603. /**
  111604. * The internal mesh used by the post-process
  111605. */
  111606. mesh: Mesh;
  111607. /**
  111608. * @hidden
  111609. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  111610. */
  111611. useDiffuseColor: boolean;
  111612. /**
  111613. * Array containing the excluded meshes not rendered in the internal pass
  111614. */
  111615. excludedMeshes: AbstractMesh[];
  111616. /**
  111617. * Controls the overall intensity of the post-process
  111618. */
  111619. exposure: number;
  111620. /**
  111621. * Dissipates each sample's contribution in range [0, 1]
  111622. */
  111623. decay: number;
  111624. /**
  111625. * Controls the overall intensity of each sample
  111626. */
  111627. weight: number;
  111628. /**
  111629. * Controls the density of each sample
  111630. */
  111631. density: number;
  111632. /**
  111633. * @constructor
  111634. * @param name The post-process name
  111635. * @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)
  111636. * @param camera The camera that the post-process will be attached to
  111637. * @param mesh The mesh used to create the light scattering
  111638. * @param samples The post-process quality, default 100
  111639. * @param samplingModeThe post-process filtering mode
  111640. * @param engine The babylon engine
  111641. * @param reusable If the post-process is reusable
  111642. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  111643. */
  111644. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  111645. /**
  111646. * Returns the string "VolumetricLightScatteringPostProcess"
  111647. * @returns "VolumetricLightScatteringPostProcess"
  111648. */
  111649. getClassName(): string;
  111650. private _isReady;
  111651. /**
  111652. * Sets the new light position for light scattering effect
  111653. * @param position The new custom light position
  111654. */
  111655. setCustomMeshPosition(position: Vector3): void;
  111656. /**
  111657. * Returns the light position for light scattering effect
  111658. * @return Vector3 The custom light position
  111659. */
  111660. getCustomMeshPosition(): Vector3;
  111661. /**
  111662. * Disposes the internal assets and detaches the post-process from the camera
  111663. */
  111664. dispose(camera: Camera): void;
  111665. /**
  111666. * Returns the render target texture used by the post-process
  111667. * @return the render target texture used by the post-process
  111668. */
  111669. getPass(): RenderTargetTexture;
  111670. private _meshExcluded;
  111671. private _createPass;
  111672. private _updateMeshScreenCoordinates;
  111673. /**
  111674. * Creates a default mesh for the Volumeric Light Scattering post-process
  111675. * @param name The mesh name
  111676. * @param scene The scene where to create the mesh
  111677. * @return the default mesh
  111678. */
  111679. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  111680. }
  111681. }
  111682. declare module BABYLON {
  111683. interface Scene {
  111684. /** @hidden (Backing field) */
  111685. _boundingBoxRenderer: BoundingBoxRenderer;
  111686. /** @hidden (Backing field) */
  111687. _forceShowBoundingBoxes: boolean;
  111688. /**
  111689. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  111690. */
  111691. forceShowBoundingBoxes: boolean;
  111692. /**
  111693. * Gets the bounding box renderer associated with the scene
  111694. * @returns a BoundingBoxRenderer
  111695. */
  111696. getBoundingBoxRenderer(): BoundingBoxRenderer;
  111697. }
  111698. interface AbstractMesh {
  111699. /** @hidden (Backing field) */
  111700. _showBoundingBox: boolean;
  111701. /**
  111702. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  111703. */
  111704. showBoundingBox: boolean;
  111705. }
  111706. /**
  111707. * Component responsible of rendering the bounding box of the meshes in a scene.
  111708. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  111709. */
  111710. export class BoundingBoxRenderer implements ISceneComponent {
  111711. /**
  111712. * The component name helpfull to identify the component in the list of scene components.
  111713. */
  111714. readonly name: string;
  111715. /**
  111716. * The scene the component belongs to.
  111717. */
  111718. scene: Scene;
  111719. /**
  111720. * Color of the bounding box lines placed in front of an object
  111721. */
  111722. frontColor: Color3;
  111723. /**
  111724. * Color of the bounding box lines placed behind an object
  111725. */
  111726. backColor: Color3;
  111727. /**
  111728. * Defines if the renderer should show the back lines or not
  111729. */
  111730. showBackLines: boolean;
  111731. /**
  111732. * @hidden
  111733. */
  111734. renderList: SmartArray<BoundingBox>;
  111735. private _colorShader;
  111736. private _vertexBuffers;
  111737. private _indexBuffer;
  111738. /**
  111739. * Instantiates a new bounding box renderer in a scene.
  111740. * @param scene the scene the renderer renders in
  111741. */
  111742. constructor(scene: Scene);
  111743. /**
  111744. * Registers the component in a given scene
  111745. */
  111746. register(): void;
  111747. private _evaluateSubMesh;
  111748. private _activeMesh;
  111749. private _prepareRessources;
  111750. private _createIndexBuffer;
  111751. /**
  111752. * Rebuilds the elements related to this component in case of
  111753. * context lost for instance.
  111754. */
  111755. rebuild(): void;
  111756. /**
  111757. * @hidden
  111758. */
  111759. reset(): void;
  111760. /**
  111761. * Render the bounding boxes of a specific rendering group
  111762. * @param renderingGroupId defines the rendering group to render
  111763. */
  111764. render(renderingGroupId: number): void;
  111765. /**
  111766. * In case of occlusion queries, we can render the occlusion bounding box through this method
  111767. * @param mesh Define the mesh to render the occlusion bounding box for
  111768. */
  111769. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  111770. /**
  111771. * Dispose and release the resources attached to this renderer.
  111772. */
  111773. dispose(): void;
  111774. }
  111775. }
  111776. declare module BABYLON {
  111777. /** @hidden */
  111778. export var depthPixelShader: {
  111779. name: string;
  111780. shader: string;
  111781. };
  111782. }
  111783. declare module BABYLON {
  111784. /**
  111785. * This represents a depth renderer in Babylon.
  111786. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  111787. */
  111788. export class DepthRenderer {
  111789. private _scene;
  111790. private _depthMap;
  111791. private _effect;
  111792. private _cachedDefines;
  111793. private _camera;
  111794. /**
  111795. * Specifiess that the depth renderer will only be used within
  111796. * the camera it is created for.
  111797. * This can help forcing its rendering during the camera processing.
  111798. */
  111799. useOnlyInActiveCamera: boolean;
  111800. /** @hidden */
  111801. static _SceneComponentInitialization: (scene: Scene) => void;
  111802. /**
  111803. * Instantiates a depth renderer
  111804. * @param scene The scene the renderer belongs to
  111805. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  111806. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  111807. */
  111808. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  111809. /**
  111810. * Creates the depth rendering effect and checks if the effect is ready.
  111811. * @param subMesh The submesh to be used to render the depth map of
  111812. * @param useInstances If multiple world instances should be used
  111813. * @returns if the depth renderer is ready to render the depth map
  111814. */
  111815. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  111816. /**
  111817. * Gets the texture which the depth map will be written to.
  111818. * @returns The depth map texture
  111819. */
  111820. getDepthMap(): RenderTargetTexture;
  111821. /**
  111822. * Disposes of the depth renderer.
  111823. */
  111824. dispose(): void;
  111825. }
  111826. }
  111827. declare module BABYLON {
  111828. interface Scene {
  111829. /** @hidden (Backing field) */
  111830. _depthRenderer: {
  111831. [id: string]: DepthRenderer;
  111832. };
  111833. /**
  111834. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  111835. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  111836. * @returns the created depth renderer
  111837. */
  111838. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  111839. /**
  111840. * Disables a depth renderer for a given camera
  111841. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  111842. */
  111843. disableDepthRenderer(camera?: Nullable<Camera>): void;
  111844. }
  111845. /**
  111846. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  111847. * in several rendering techniques.
  111848. */
  111849. export class DepthRendererSceneComponent implements ISceneComponent {
  111850. /**
  111851. * The component name helpfull to identify the component in the list of scene components.
  111852. */
  111853. readonly name: string;
  111854. /**
  111855. * The scene the component belongs to.
  111856. */
  111857. scene: Scene;
  111858. /**
  111859. * Creates a new instance of the component for the given scene
  111860. * @param scene Defines the scene to register the component in
  111861. */
  111862. constructor(scene: Scene);
  111863. /**
  111864. * Registers the component in a given scene
  111865. */
  111866. register(): void;
  111867. /**
  111868. * Rebuilds the elements related to this component in case of
  111869. * context lost for instance.
  111870. */
  111871. rebuild(): void;
  111872. /**
  111873. * Disposes the component and the associated ressources
  111874. */
  111875. dispose(): void;
  111876. private _gatherRenderTargets;
  111877. private _gatherActiveCameraRenderTargets;
  111878. }
  111879. }
  111880. declare module BABYLON {
  111881. /** @hidden */
  111882. export var outlinePixelShader: {
  111883. name: string;
  111884. shader: string;
  111885. };
  111886. }
  111887. declare module BABYLON {
  111888. /** @hidden */
  111889. export var outlineVertexShader: {
  111890. name: string;
  111891. shader: string;
  111892. };
  111893. }
  111894. declare module BABYLON {
  111895. interface Scene {
  111896. /** @hidden */
  111897. _outlineRenderer: OutlineRenderer;
  111898. /**
  111899. * Gets the outline renderer associated with the scene
  111900. * @returns a OutlineRenderer
  111901. */
  111902. getOutlineRenderer(): OutlineRenderer;
  111903. }
  111904. interface AbstractMesh {
  111905. /** @hidden (Backing field) */
  111906. _renderOutline: boolean;
  111907. /**
  111908. * Gets or sets a boolean indicating if the outline must be rendered as well
  111909. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  111910. */
  111911. renderOutline: boolean;
  111912. /** @hidden (Backing field) */
  111913. _renderOverlay: boolean;
  111914. /**
  111915. * Gets or sets a boolean indicating if the overlay must be rendered as well
  111916. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  111917. */
  111918. renderOverlay: boolean;
  111919. }
  111920. /**
  111921. * This class is responsible to draw bothe outline/overlay of meshes.
  111922. * It should not be used directly but through the available method on mesh.
  111923. */
  111924. export class OutlineRenderer implements ISceneComponent {
  111925. /**
  111926. * The name of the component. Each component must have a unique name.
  111927. */
  111928. name: string;
  111929. /**
  111930. * The scene the component belongs to.
  111931. */
  111932. scene: Scene;
  111933. /**
  111934. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  111935. */
  111936. zOffset: number;
  111937. private _engine;
  111938. private _effect;
  111939. private _cachedDefines;
  111940. private _savedDepthWrite;
  111941. /**
  111942. * Instantiates a new outline renderer. (There could be only one per scene).
  111943. * @param scene Defines the scene it belongs to
  111944. */
  111945. constructor(scene: Scene);
  111946. /**
  111947. * Register the component to one instance of a scene.
  111948. */
  111949. register(): void;
  111950. /**
  111951. * Rebuilds the elements related to this component in case of
  111952. * context lost for instance.
  111953. */
  111954. rebuild(): void;
  111955. /**
  111956. * Disposes the component and the associated ressources.
  111957. */
  111958. dispose(): void;
  111959. /**
  111960. * Renders the outline in the canvas.
  111961. * @param subMesh Defines the sumesh to render
  111962. * @param batch Defines the batch of meshes in case of instances
  111963. * @param useOverlay Defines if the rendering is for the overlay or the outline
  111964. */
  111965. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  111966. /**
  111967. * Returns whether or not the outline renderer is ready for a given submesh.
  111968. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  111969. * @param subMesh Defines the submesh to check readyness for
  111970. * @param useInstances Defines wheter wee are trying to render instances or not
  111971. * @returns true if ready otherwise false
  111972. */
  111973. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  111974. private _beforeRenderingMesh;
  111975. private _afterRenderingMesh;
  111976. }
  111977. }
  111978. declare module BABYLON {
  111979. /**
  111980. * Defines the list of states available for a task inside a AssetsManager
  111981. */
  111982. export enum AssetTaskState {
  111983. /**
  111984. * Initialization
  111985. */
  111986. INIT = 0,
  111987. /**
  111988. * Running
  111989. */
  111990. RUNNING = 1,
  111991. /**
  111992. * Done
  111993. */
  111994. DONE = 2,
  111995. /**
  111996. * Error
  111997. */
  111998. ERROR = 3
  111999. }
  112000. /**
  112001. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  112002. */
  112003. export abstract class AbstractAssetTask {
  112004. /**
  112005. * Task name
  112006. */ name: string;
  112007. /**
  112008. * Callback called when the task is successful
  112009. */
  112010. onSuccess: (task: any) => void;
  112011. /**
  112012. * Callback called when the task is not successful
  112013. */
  112014. onError: (task: any, message?: string, exception?: any) => void;
  112015. /**
  112016. * Creates a new AssetsManager
  112017. * @param name defines the name of the task
  112018. */
  112019. constructor(
  112020. /**
  112021. * Task name
  112022. */ name: string);
  112023. private _isCompleted;
  112024. private _taskState;
  112025. private _errorObject;
  112026. /**
  112027. * Get if the task is completed
  112028. */
  112029. readonly isCompleted: boolean;
  112030. /**
  112031. * Gets the current state of the task
  112032. */
  112033. readonly taskState: AssetTaskState;
  112034. /**
  112035. * Gets the current error object (if task is in error)
  112036. */
  112037. readonly errorObject: {
  112038. message?: string;
  112039. exception?: any;
  112040. };
  112041. /**
  112042. * Internal only
  112043. * @hidden
  112044. */
  112045. _setErrorObject(message?: string, exception?: any): void;
  112046. /**
  112047. * Execute the current task
  112048. * @param scene defines the scene where you want your assets to be loaded
  112049. * @param onSuccess is a callback called when the task is successfully executed
  112050. * @param onError is a callback called if an error occurs
  112051. */
  112052. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112053. /**
  112054. * Execute the current task
  112055. * @param scene defines the scene where you want your assets to be loaded
  112056. * @param onSuccess is a callback called when the task is successfully executed
  112057. * @param onError is a callback called if an error occurs
  112058. */
  112059. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112060. /**
  112061. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  112062. * This can be used with failed tasks that have the reason for failure fixed.
  112063. */
  112064. reset(): void;
  112065. private onErrorCallback;
  112066. private onDoneCallback;
  112067. }
  112068. /**
  112069. * Define the interface used by progress events raised during assets loading
  112070. */
  112071. export interface IAssetsProgressEvent {
  112072. /**
  112073. * Defines the number of remaining tasks to process
  112074. */
  112075. remainingCount: number;
  112076. /**
  112077. * Defines the total number of tasks
  112078. */
  112079. totalCount: number;
  112080. /**
  112081. * Defines the task that was just processed
  112082. */
  112083. task: AbstractAssetTask;
  112084. }
  112085. /**
  112086. * Class used to share progress information about assets loading
  112087. */
  112088. export class AssetsProgressEvent implements IAssetsProgressEvent {
  112089. /**
  112090. * Defines the number of remaining tasks to process
  112091. */
  112092. remainingCount: number;
  112093. /**
  112094. * Defines the total number of tasks
  112095. */
  112096. totalCount: number;
  112097. /**
  112098. * Defines the task that was just processed
  112099. */
  112100. task: AbstractAssetTask;
  112101. /**
  112102. * Creates a AssetsProgressEvent
  112103. * @param remainingCount defines the number of remaining tasks to process
  112104. * @param totalCount defines the total number of tasks
  112105. * @param task defines the task that was just processed
  112106. */
  112107. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  112108. }
  112109. /**
  112110. * Define a task used by AssetsManager to load meshes
  112111. */
  112112. export class MeshAssetTask extends AbstractAssetTask {
  112113. /**
  112114. * Defines the name of the task
  112115. */
  112116. name: string;
  112117. /**
  112118. * Defines the list of mesh's names you want to load
  112119. */
  112120. meshesNames: any;
  112121. /**
  112122. * Defines the root url to use as a base to load your meshes and associated resources
  112123. */
  112124. rootUrl: string;
  112125. /**
  112126. * Defines the filename of the scene to load from
  112127. */
  112128. sceneFilename: string;
  112129. /**
  112130. * Gets the list of loaded meshes
  112131. */
  112132. loadedMeshes: Array<AbstractMesh>;
  112133. /**
  112134. * Gets the list of loaded particle systems
  112135. */
  112136. loadedParticleSystems: Array<IParticleSystem>;
  112137. /**
  112138. * Gets the list of loaded skeletons
  112139. */
  112140. loadedSkeletons: Array<Skeleton>;
  112141. /**
  112142. * Gets the list of loaded animation groups
  112143. */
  112144. loadedAnimationGroups: Array<AnimationGroup>;
  112145. /**
  112146. * Callback called when the task is successful
  112147. */
  112148. onSuccess: (task: MeshAssetTask) => void;
  112149. /**
  112150. * Callback called when the task is successful
  112151. */
  112152. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  112153. /**
  112154. * Creates a new MeshAssetTask
  112155. * @param name defines the name of the task
  112156. * @param meshesNames defines the list of mesh's names you want to load
  112157. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  112158. * @param sceneFilename defines the filename of the scene to load from
  112159. */
  112160. constructor(
  112161. /**
  112162. * Defines the name of the task
  112163. */
  112164. name: string,
  112165. /**
  112166. * Defines the list of mesh's names you want to load
  112167. */
  112168. meshesNames: any,
  112169. /**
  112170. * Defines the root url to use as a base to load your meshes and associated resources
  112171. */
  112172. rootUrl: string,
  112173. /**
  112174. * Defines the filename of the scene to load from
  112175. */
  112176. sceneFilename: string);
  112177. /**
  112178. * Execute the current task
  112179. * @param scene defines the scene where you want your assets to be loaded
  112180. * @param onSuccess is a callback called when the task is successfully executed
  112181. * @param onError is a callback called if an error occurs
  112182. */
  112183. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112184. }
  112185. /**
  112186. * Define a task used by AssetsManager to load text content
  112187. */
  112188. export class TextFileAssetTask extends AbstractAssetTask {
  112189. /**
  112190. * Defines the name of the task
  112191. */
  112192. name: string;
  112193. /**
  112194. * Defines the location of the file to load
  112195. */
  112196. url: string;
  112197. /**
  112198. * Gets the loaded text string
  112199. */
  112200. text: string;
  112201. /**
  112202. * Callback called when the task is successful
  112203. */
  112204. onSuccess: (task: TextFileAssetTask) => void;
  112205. /**
  112206. * Callback called when the task is successful
  112207. */
  112208. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  112209. /**
  112210. * Creates a new TextFileAssetTask object
  112211. * @param name defines the name of the task
  112212. * @param url defines the location of the file to load
  112213. */
  112214. constructor(
  112215. /**
  112216. * Defines the name of the task
  112217. */
  112218. name: string,
  112219. /**
  112220. * Defines the location of the file to load
  112221. */
  112222. url: string);
  112223. /**
  112224. * Execute the current task
  112225. * @param scene defines the scene where you want your assets to be loaded
  112226. * @param onSuccess is a callback called when the task is successfully executed
  112227. * @param onError is a callback called if an error occurs
  112228. */
  112229. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112230. }
  112231. /**
  112232. * Define a task used by AssetsManager to load binary data
  112233. */
  112234. export class BinaryFileAssetTask extends AbstractAssetTask {
  112235. /**
  112236. * Defines the name of the task
  112237. */
  112238. name: string;
  112239. /**
  112240. * Defines the location of the file to load
  112241. */
  112242. url: string;
  112243. /**
  112244. * Gets the lodaded data (as an array buffer)
  112245. */
  112246. data: ArrayBuffer;
  112247. /**
  112248. * Callback called when the task is successful
  112249. */
  112250. onSuccess: (task: BinaryFileAssetTask) => void;
  112251. /**
  112252. * Callback called when the task is successful
  112253. */
  112254. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  112255. /**
  112256. * Creates a new BinaryFileAssetTask object
  112257. * @param name defines the name of the new task
  112258. * @param url defines the location of the file to load
  112259. */
  112260. constructor(
  112261. /**
  112262. * Defines the name of the task
  112263. */
  112264. name: string,
  112265. /**
  112266. * Defines the location of the file to load
  112267. */
  112268. url: string);
  112269. /**
  112270. * Execute the current task
  112271. * @param scene defines the scene where you want your assets to be loaded
  112272. * @param onSuccess is a callback called when the task is successfully executed
  112273. * @param onError is a callback called if an error occurs
  112274. */
  112275. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112276. }
  112277. /**
  112278. * Define a task used by AssetsManager to load images
  112279. */
  112280. export class ImageAssetTask extends AbstractAssetTask {
  112281. /**
  112282. * Defines the name of the task
  112283. */
  112284. name: string;
  112285. /**
  112286. * Defines the location of the image to load
  112287. */
  112288. url: string;
  112289. /**
  112290. * Gets the loaded images
  112291. */
  112292. image: HTMLImageElement;
  112293. /**
  112294. * Callback called when the task is successful
  112295. */
  112296. onSuccess: (task: ImageAssetTask) => void;
  112297. /**
  112298. * Callback called when the task is successful
  112299. */
  112300. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  112301. /**
  112302. * Creates a new ImageAssetTask
  112303. * @param name defines the name of the task
  112304. * @param url defines the location of the image to load
  112305. */
  112306. constructor(
  112307. /**
  112308. * Defines the name of the task
  112309. */
  112310. name: string,
  112311. /**
  112312. * Defines the location of the image to load
  112313. */
  112314. url: string);
  112315. /**
  112316. * Execute the current task
  112317. * @param scene defines the scene where you want your assets to be loaded
  112318. * @param onSuccess is a callback called when the task is successfully executed
  112319. * @param onError is a callback called if an error occurs
  112320. */
  112321. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112322. }
  112323. /**
  112324. * Defines the interface used by texture loading tasks
  112325. */
  112326. export interface ITextureAssetTask<TEX extends BaseTexture> {
  112327. /**
  112328. * Gets the loaded texture
  112329. */
  112330. texture: TEX;
  112331. }
  112332. /**
  112333. * Define a task used by AssetsManager to load 2D textures
  112334. */
  112335. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  112336. /**
  112337. * Defines the name of the task
  112338. */
  112339. name: string;
  112340. /**
  112341. * Defines the location of the file to load
  112342. */
  112343. url: string;
  112344. /**
  112345. * Defines if mipmap should not be generated (default is false)
  112346. */
  112347. noMipmap?: boolean | undefined;
  112348. /**
  112349. * Defines if texture must be inverted on Y axis (default is false)
  112350. */
  112351. invertY?: boolean | undefined;
  112352. /**
  112353. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  112354. */
  112355. samplingMode: number;
  112356. /**
  112357. * Gets the loaded texture
  112358. */
  112359. texture: Texture;
  112360. /**
  112361. * Callback called when the task is successful
  112362. */
  112363. onSuccess: (task: TextureAssetTask) => void;
  112364. /**
  112365. * Callback called when the task is successful
  112366. */
  112367. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  112368. /**
  112369. * Creates a new TextureAssetTask object
  112370. * @param name defines the name of the task
  112371. * @param url defines the location of the file to load
  112372. * @param noMipmap defines if mipmap should not be generated (default is false)
  112373. * @param invertY defines if texture must be inverted on Y axis (default is false)
  112374. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  112375. */
  112376. constructor(
  112377. /**
  112378. * Defines the name of the task
  112379. */
  112380. name: string,
  112381. /**
  112382. * Defines the location of the file to load
  112383. */
  112384. url: string,
  112385. /**
  112386. * Defines if mipmap should not be generated (default is false)
  112387. */
  112388. noMipmap?: boolean | undefined,
  112389. /**
  112390. * Defines if texture must be inverted on Y axis (default is false)
  112391. */
  112392. invertY?: boolean | undefined,
  112393. /**
  112394. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  112395. */
  112396. samplingMode?: number);
  112397. /**
  112398. * Execute the current task
  112399. * @param scene defines the scene where you want your assets to be loaded
  112400. * @param onSuccess is a callback called when the task is successfully executed
  112401. * @param onError is a callback called if an error occurs
  112402. */
  112403. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112404. }
  112405. /**
  112406. * Define a task used by AssetsManager to load cube textures
  112407. */
  112408. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  112409. /**
  112410. * Defines the name of the task
  112411. */
  112412. name: string;
  112413. /**
  112414. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  112415. */
  112416. url: string;
  112417. /**
  112418. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  112419. */
  112420. extensions?: string[] | undefined;
  112421. /**
  112422. * Defines if mipmaps should not be generated (default is false)
  112423. */
  112424. noMipmap?: boolean | undefined;
  112425. /**
  112426. * Defines the explicit list of files (undefined by default)
  112427. */
  112428. files?: string[] | undefined;
  112429. /**
  112430. * Gets the loaded texture
  112431. */
  112432. texture: CubeTexture;
  112433. /**
  112434. * Callback called when the task is successful
  112435. */
  112436. onSuccess: (task: CubeTextureAssetTask) => void;
  112437. /**
  112438. * Callback called when the task is successful
  112439. */
  112440. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  112441. /**
  112442. * Creates a new CubeTextureAssetTask
  112443. * @param name defines the name of the task
  112444. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  112445. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  112446. * @param noMipmap defines if mipmaps should not be generated (default is false)
  112447. * @param files defines the explicit list of files (undefined by default)
  112448. */
  112449. constructor(
  112450. /**
  112451. * Defines the name of the task
  112452. */
  112453. name: string,
  112454. /**
  112455. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  112456. */
  112457. url: string,
  112458. /**
  112459. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  112460. */
  112461. extensions?: string[] | undefined,
  112462. /**
  112463. * Defines if mipmaps should not be generated (default is false)
  112464. */
  112465. noMipmap?: boolean | undefined,
  112466. /**
  112467. * Defines the explicit list of files (undefined by default)
  112468. */
  112469. files?: string[] | undefined);
  112470. /**
  112471. * Execute the current task
  112472. * @param scene defines the scene where you want your assets to be loaded
  112473. * @param onSuccess is a callback called when the task is successfully executed
  112474. * @param onError is a callback called if an error occurs
  112475. */
  112476. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112477. }
  112478. /**
  112479. * Define a task used by AssetsManager to load HDR cube textures
  112480. */
  112481. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  112482. /**
  112483. * Defines the name of the task
  112484. */
  112485. name: string;
  112486. /**
  112487. * Defines the location of the file to load
  112488. */
  112489. url: string;
  112490. /**
  112491. * Defines the desired size (the more it increases the longer the generation will be)
  112492. */
  112493. size: number;
  112494. /**
  112495. * Defines if mipmaps should not be generated (default is false)
  112496. */
  112497. noMipmap: boolean;
  112498. /**
  112499. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  112500. */
  112501. generateHarmonics: boolean;
  112502. /**
  112503. * 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)
  112504. */
  112505. gammaSpace: boolean;
  112506. /**
  112507. * Internal Use Only
  112508. */
  112509. reserved: boolean;
  112510. /**
  112511. * Gets the loaded texture
  112512. */
  112513. texture: HDRCubeTexture;
  112514. /**
  112515. * Callback called when the task is successful
  112516. */
  112517. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  112518. /**
  112519. * Callback called when the task is successful
  112520. */
  112521. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  112522. /**
  112523. * Creates a new HDRCubeTextureAssetTask object
  112524. * @param name defines the name of the task
  112525. * @param url defines the location of the file to load
  112526. * @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.
  112527. * @param noMipmap defines if mipmaps should not be generated (default is false)
  112528. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  112529. * @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)
  112530. * @param reserved Internal use only
  112531. */
  112532. constructor(
  112533. /**
  112534. * Defines the name of the task
  112535. */
  112536. name: string,
  112537. /**
  112538. * Defines the location of the file to load
  112539. */
  112540. url: string,
  112541. /**
  112542. * Defines the desired size (the more it increases the longer the generation will be)
  112543. */
  112544. size: number,
  112545. /**
  112546. * Defines if mipmaps should not be generated (default is false)
  112547. */
  112548. noMipmap?: boolean,
  112549. /**
  112550. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  112551. */
  112552. generateHarmonics?: boolean,
  112553. /**
  112554. * 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)
  112555. */
  112556. gammaSpace?: boolean,
  112557. /**
  112558. * Internal Use Only
  112559. */
  112560. reserved?: boolean);
  112561. /**
  112562. * Execute the current task
  112563. * @param scene defines the scene where you want your assets to be loaded
  112564. * @param onSuccess is a callback called when the task is successfully executed
  112565. * @param onError is a callback called if an error occurs
  112566. */
  112567. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  112568. }
  112569. /**
  112570. * This class can be used to easily import assets into a scene
  112571. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  112572. */
  112573. export class AssetsManager {
  112574. private _scene;
  112575. private _isLoading;
  112576. protected _tasks: AbstractAssetTask[];
  112577. protected _waitingTasksCount: number;
  112578. protected _totalTasksCount: number;
  112579. /**
  112580. * Callback called when all tasks are processed
  112581. */
  112582. onFinish: (tasks: AbstractAssetTask[]) => void;
  112583. /**
  112584. * Callback called when a task is successful
  112585. */
  112586. onTaskSuccess: (task: AbstractAssetTask) => void;
  112587. /**
  112588. * Callback called when a task had an error
  112589. */
  112590. onTaskError: (task: AbstractAssetTask) => void;
  112591. /**
  112592. * Callback called when a task is done (whatever the result is)
  112593. */
  112594. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  112595. /**
  112596. * Observable called when all tasks are processed
  112597. */
  112598. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  112599. /**
  112600. * Observable called when a task had an error
  112601. */
  112602. onTaskErrorObservable: Observable<AbstractAssetTask>;
  112603. /**
  112604. * Observable called when all tasks were executed
  112605. */
  112606. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  112607. /**
  112608. * Observable called when a task is done (whatever the result is)
  112609. */
  112610. onProgressObservable: Observable<IAssetsProgressEvent>;
  112611. /**
  112612. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  112613. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  112614. */
  112615. useDefaultLoadingScreen: boolean;
  112616. /**
  112617. * Creates a new AssetsManager
  112618. * @param scene defines the scene to work on
  112619. */
  112620. constructor(scene: Scene);
  112621. /**
  112622. * Add a MeshAssetTask to the list of active tasks
  112623. * @param taskName defines the name of the new task
  112624. * @param meshesNames defines the name of meshes to load
  112625. * @param rootUrl defines the root url to use to locate files
  112626. * @param sceneFilename defines the filename of the scene file
  112627. * @returns a new MeshAssetTask object
  112628. */
  112629. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  112630. /**
  112631. * Add a TextFileAssetTask to the list of active tasks
  112632. * @param taskName defines the name of the new task
  112633. * @param url defines the url of the file to load
  112634. * @returns a new TextFileAssetTask object
  112635. */
  112636. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  112637. /**
  112638. * Add a BinaryFileAssetTask to the list of active tasks
  112639. * @param taskName defines the name of the new task
  112640. * @param url defines the url of the file to load
  112641. * @returns a new BinaryFileAssetTask object
  112642. */
  112643. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  112644. /**
  112645. * Add a ImageAssetTask to the list of active tasks
  112646. * @param taskName defines the name of the new task
  112647. * @param url defines the url of the file to load
  112648. * @returns a new ImageAssetTask object
  112649. */
  112650. addImageTask(taskName: string, url: string): ImageAssetTask;
  112651. /**
  112652. * Add a TextureAssetTask to the list of active tasks
  112653. * @param taskName defines the name of the new task
  112654. * @param url defines the url of the file to load
  112655. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  112656. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  112657. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  112658. * @returns a new TextureAssetTask object
  112659. */
  112660. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  112661. /**
  112662. * Add a CubeTextureAssetTask to the list of active tasks
  112663. * @param taskName defines the name of the new task
  112664. * @param url defines the url of the file to load
  112665. * @param extensions defines the extension to use to load the cube map (can be null)
  112666. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  112667. * @param files defines the list of files to load (can be null)
  112668. * @returns a new CubeTextureAssetTask object
  112669. */
  112670. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  112671. /**
  112672. *
  112673. * Add a HDRCubeTextureAssetTask to the list of active tasks
  112674. * @param taskName defines the name of the new task
  112675. * @param url defines the url of the file to load
  112676. * @param size defines the size you want for the cubemap (can be null)
  112677. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  112678. * @param generateHarmonics defines if you want to automatically generate (true by default)
  112679. * @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)
  112680. * @param reserved Internal use only
  112681. * @returns a new HDRCubeTextureAssetTask object
  112682. */
  112683. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  112684. /**
  112685. * Remove a task from the assets manager.
  112686. * @param task the task to remove
  112687. */
  112688. removeTask(task: AbstractAssetTask): void;
  112689. private _decreaseWaitingTasksCount;
  112690. private _runTask;
  112691. /**
  112692. * Reset the AssetsManager and remove all tasks
  112693. * @return the current instance of the AssetsManager
  112694. */
  112695. reset(): AssetsManager;
  112696. /**
  112697. * Start the loading process
  112698. * @return the current instance of the AssetsManager
  112699. */
  112700. load(): AssetsManager;
  112701. /**
  112702. * Start the loading process as an async operation
  112703. * @return a promise returning the list of failed tasks
  112704. */
  112705. loadAsync(): Promise<void>;
  112706. }
  112707. }
  112708. declare module BABYLON {
  112709. /**
  112710. * Wrapper class for promise with external resolve and reject.
  112711. */
  112712. export class Deferred<T> {
  112713. /**
  112714. * The promise associated with this deferred object.
  112715. */
  112716. readonly promise: Promise<T>;
  112717. private _resolve;
  112718. private _reject;
  112719. /**
  112720. * The resolve method of the promise associated with this deferred object.
  112721. */
  112722. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  112723. /**
  112724. * The reject method of the promise associated with this deferred object.
  112725. */
  112726. readonly reject: (reason?: any) => void;
  112727. /**
  112728. * Constructor for this deferred object.
  112729. */
  112730. constructor();
  112731. }
  112732. }
  112733. declare module BABYLON {
  112734. /**
  112735. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  112736. */
  112737. export class MeshExploder {
  112738. private _centerMesh;
  112739. private _meshes;
  112740. private _meshesOrigins;
  112741. private _toCenterVectors;
  112742. private _scaledDirection;
  112743. private _newPosition;
  112744. private _centerPosition;
  112745. /**
  112746. * Explodes meshes from a center mesh.
  112747. * @param meshes The meshes to explode.
  112748. * @param centerMesh The mesh to be center of explosion.
  112749. */
  112750. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  112751. private _setCenterMesh;
  112752. /**
  112753. * Get class name
  112754. * @returns "MeshExploder"
  112755. */
  112756. getClassName(): string;
  112757. /**
  112758. * "Exploded meshes"
  112759. * @returns Array of meshes with the centerMesh at index 0.
  112760. */
  112761. getMeshes(): Array<Mesh>;
  112762. /**
  112763. * Explodes meshes giving a specific direction
  112764. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  112765. */
  112766. explode(direction?: number): void;
  112767. }
  112768. }
  112769. declare module BABYLON {
  112770. /**
  112771. * Class used to help managing file picking and drag'n'drop
  112772. */
  112773. export class FilesInput {
  112774. /**
  112775. * List of files ready to be loaded
  112776. */
  112777. static readonly FilesToLoad: {
  112778. [key: string]: File;
  112779. };
  112780. /**
  112781. * Callback called when a file is processed
  112782. */
  112783. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  112784. private _engine;
  112785. private _currentScene;
  112786. private _sceneLoadedCallback;
  112787. private _progressCallback;
  112788. private _additionalRenderLoopLogicCallback;
  112789. private _textureLoadingCallback;
  112790. private _startingProcessingFilesCallback;
  112791. private _onReloadCallback;
  112792. private _errorCallback;
  112793. private _elementToMonitor;
  112794. private _sceneFileToLoad;
  112795. private _filesToLoad;
  112796. /**
  112797. * Creates a new FilesInput
  112798. * @param engine defines the rendering engine
  112799. * @param scene defines the hosting scene
  112800. * @param sceneLoadedCallback callback called when scene is loaded
  112801. * @param progressCallback callback called to track progress
  112802. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  112803. * @param textureLoadingCallback callback called when a texture is loading
  112804. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  112805. * @param onReloadCallback callback called when a reload is requested
  112806. * @param errorCallback callback call if an error occurs
  112807. */
  112808. 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);
  112809. private _dragEnterHandler;
  112810. private _dragOverHandler;
  112811. private _dropHandler;
  112812. /**
  112813. * Calls this function to listen to drag'n'drop events on a specific DOM element
  112814. * @param elementToMonitor defines the DOM element to track
  112815. */
  112816. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  112817. /**
  112818. * Release all associated resources
  112819. */
  112820. dispose(): void;
  112821. private renderFunction;
  112822. private drag;
  112823. private drop;
  112824. private _traverseFolder;
  112825. private _processFiles;
  112826. /**
  112827. * Load files from a drop event
  112828. * @param event defines the drop event to use as source
  112829. */
  112830. loadFiles(event: any): void;
  112831. private _processReload;
  112832. /**
  112833. * Reload the current scene from the loaded files
  112834. */
  112835. reload(): void;
  112836. }
  112837. }
  112838. declare module BABYLON {
  112839. /**
  112840. * Defines the root class used to create scene optimization to use with SceneOptimizer
  112841. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112842. */
  112843. export class SceneOptimization {
  112844. /**
  112845. * Defines the priority of this optimization (0 by default which means first in the list)
  112846. */
  112847. priority: number;
  112848. /**
  112849. * Gets a string describing the action executed by the current optimization
  112850. * @returns description string
  112851. */
  112852. getDescription(): string;
  112853. /**
  112854. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  112855. * @param scene defines the current scene where to apply this optimization
  112856. * @param optimizer defines the current optimizer
  112857. * @returns true if everything that can be done was applied
  112858. */
  112859. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  112860. /**
  112861. * Creates the SceneOptimization object
  112862. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  112863. * @param desc defines the description associated with the optimization
  112864. */
  112865. constructor(
  112866. /**
  112867. * Defines the priority of this optimization (0 by default which means first in the list)
  112868. */
  112869. priority?: number);
  112870. }
  112871. /**
  112872. * Defines an optimization used to reduce the size of render target textures
  112873. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112874. */
  112875. export class TextureOptimization extends SceneOptimization {
  112876. /**
  112877. * Defines the priority of this optimization (0 by default which means first in the list)
  112878. */
  112879. priority: number;
  112880. /**
  112881. * 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
  112882. */
  112883. maximumSize: number;
  112884. /**
  112885. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  112886. */
  112887. step: number;
  112888. /**
  112889. * Gets a string describing the action executed by the current optimization
  112890. * @returns description string
  112891. */
  112892. getDescription(): string;
  112893. /**
  112894. * Creates the TextureOptimization object
  112895. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  112896. * @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
  112897. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  112898. */
  112899. constructor(
  112900. /**
  112901. * Defines the priority of this optimization (0 by default which means first in the list)
  112902. */
  112903. priority?: number,
  112904. /**
  112905. * 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
  112906. */
  112907. maximumSize?: number,
  112908. /**
  112909. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  112910. */
  112911. step?: number);
  112912. /**
  112913. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  112914. * @param scene defines the current scene where to apply this optimization
  112915. * @param optimizer defines the current optimizer
  112916. * @returns true if everything that can be done was applied
  112917. */
  112918. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  112919. }
  112920. /**
  112921. * Defines an optimization used to increase or decrease the rendering resolution
  112922. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112923. */
  112924. export class HardwareScalingOptimization extends SceneOptimization {
  112925. /**
  112926. * Defines the priority of this optimization (0 by default which means first in the list)
  112927. */
  112928. priority: number;
  112929. /**
  112930. * Defines the maximum scale to use (2 by default)
  112931. */
  112932. maximumScale: number;
  112933. /**
  112934. * Defines the step to use between two passes (0.5 by default)
  112935. */
  112936. step: number;
  112937. private _currentScale;
  112938. private _directionOffset;
  112939. /**
  112940. * Gets a string describing the action executed by the current optimization
  112941. * @return description string
  112942. */
  112943. getDescription(): string;
  112944. /**
  112945. * Creates the HardwareScalingOptimization object
  112946. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  112947. * @param maximumScale defines the maximum scale to use (2 by default)
  112948. * @param step defines the step to use between two passes (0.5 by default)
  112949. */
  112950. constructor(
  112951. /**
  112952. * Defines the priority of this optimization (0 by default which means first in the list)
  112953. */
  112954. priority?: number,
  112955. /**
  112956. * Defines the maximum scale to use (2 by default)
  112957. */
  112958. maximumScale?: number,
  112959. /**
  112960. * Defines the step to use between two passes (0.5 by default)
  112961. */
  112962. step?: number);
  112963. /**
  112964. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  112965. * @param scene defines the current scene where to apply this optimization
  112966. * @param optimizer defines the current optimizer
  112967. * @returns true if everything that can be done was applied
  112968. */
  112969. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  112970. }
  112971. /**
  112972. * Defines an optimization used to remove shadows
  112973. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112974. */
  112975. export class ShadowsOptimization extends SceneOptimization {
  112976. /**
  112977. * Gets a string describing the action executed by the current optimization
  112978. * @return description string
  112979. */
  112980. getDescription(): string;
  112981. /**
  112982. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  112983. * @param scene defines the current scene where to apply this optimization
  112984. * @param optimizer defines the current optimizer
  112985. * @returns true if everything that can be done was applied
  112986. */
  112987. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  112988. }
  112989. /**
  112990. * Defines an optimization used to turn post-processes off
  112991. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  112992. */
  112993. export class PostProcessesOptimization extends SceneOptimization {
  112994. /**
  112995. * Gets a string describing the action executed by the current optimization
  112996. * @return description string
  112997. */
  112998. getDescription(): string;
  112999. /**
  113000. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113001. * @param scene defines the current scene where to apply this optimization
  113002. * @param optimizer defines the current optimizer
  113003. * @returns true if everything that can be done was applied
  113004. */
  113005. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113006. }
  113007. /**
  113008. * Defines an optimization used to turn lens flares off
  113009. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113010. */
  113011. export class LensFlaresOptimization extends SceneOptimization {
  113012. /**
  113013. * Gets a string describing the action executed by the current optimization
  113014. * @return description string
  113015. */
  113016. getDescription(): string;
  113017. /**
  113018. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113019. * @param scene defines the current scene where to apply this optimization
  113020. * @param optimizer defines the current optimizer
  113021. * @returns true if everything that can be done was applied
  113022. */
  113023. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113024. }
  113025. /**
  113026. * Defines an optimization based on user defined callback.
  113027. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113028. */
  113029. export class CustomOptimization extends SceneOptimization {
  113030. /**
  113031. * Callback called to apply the custom optimization.
  113032. */
  113033. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  113034. /**
  113035. * Callback called to get custom description
  113036. */
  113037. onGetDescription: () => string;
  113038. /**
  113039. * Gets a string describing the action executed by the current optimization
  113040. * @returns description string
  113041. */
  113042. getDescription(): string;
  113043. /**
  113044. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113045. * @param scene defines the current scene where to apply this optimization
  113046. * @param optimizer defines the current optimizer
  113047. * @returns true if everything that can be done was applied
  113048. */
  113049. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113050. }
  113051. /**
  113052. * Defines an optimization used to turn particles off
  113053. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113054. */
  113055. export class ParticlesOptimization extends SceneOptimization {
  113056. /**
  113057. * Gets a string describing the action executed by the current optimization
  113058. * @return description string
  113059. */
  113060. getDescription(): string;
  113061. /**
  113062. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113063. * @param scene defines the current scene where to apply this optimization
  113064. * @param optimizer defines the current optimizer
  113065. * @returns true if everything that can be done was applied
  113066. */
  113067. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113068. }
  113069. /**
  113070. * Defines an optimization used to turn render targets off
  113071. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113072. */
  113073. export class RenderTargetsOptimization extends SceneOptimization {
  113074. /**
  113075. * Gets a string describing the action executed by the current optimization
  113076. * @return description string
  113077. */
  113078. getDescription(): string;
  113079. /**
  113080. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113081. * @param scene defines the current scene where to apply this optimization
  113082. * @param optimizer defines the current optimizer
  113083. * @returns true if everything that can be done was applied
  113084. */
  113085. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  113086. }
  113087. /**
  113088. * Defines an optimization used to merge meshes with compatible materials
  113089. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113090. */
  113091. export class MergeMeshesOptimization extends SceneOptimization {
  113092. private static _UpdateSelectionTree;
  113093. /**
  113094. * Gets or sets a boolean which defines if optimization octree has to be updated
  113095. */
  113096. /**
  113097. * Gets or sets a boolean which defines if optimization octree has to be updated
  113098. */
  113099. static UpdateSelectionTree: boolean;
  113100. /**
  113101. * Gets a string describing the action executed by the current optimization
  113102. * @return description string
  113103. */
  113104. getDescription(): string;
  113105. private _canBeMerged;
  113106. /**
  113107. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  113108. * @param scene defines the current scene where to apply this optimization
  113109. * @param optimizer defines the current optimizer
  113110. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  113111. * @returns true if everything that can be done was applied
  113112. */
  113113. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  113114. }
  113115. /**
  113116. * Defines a list of options used by SceneOptimizer
  113117. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113118. */
  113119. export class SceneOptimizerOptions {
  113120. /**
  113121. * Defines the target frame rate to reach (60 by default)
  113122. */
  113123. targetFrameRate: number;
  113124. /**
  113125. * Defines the interval between two checkes (2000ms by default)
  113126. */
  113127. trackerDuration: number;
  113128. /**
  113129. * Gets the list of optimizations to apply
  113130. */
  113131. optimizations: SceneOptimization[];
  113132. /**
  113133. * Creates a new list of options used by SceneOptimizer
  113134. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  113135. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  113136. */
  113137. constructor(
  113138. /**
  113139. * Defines the target frame rate to reach (60 by default)
  113140. */
  113141. targetFrameRate?: number,
  113142. /**
  113143. * Defines the interval between two checkes (2000ms by default)
  113144. */
  113145. trackerDuration?: number);
  113146. /**
  113147. * Add a new optimization
  113148. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  113149. * @returns the current SceneOptimizerOptions
  113150. */
  113151. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  113152. /**
  113153. * Add a new custom optimization
  113154. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  113155. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  113156. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  113157. * @returns the current SceneOptimizerOptions
  113158. */
  113159. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  113160. /**
  113161. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  113162. * @param targetFrameRate defines the target frame rate (60 by default)
  113163. * @returns a SceneOptimizerOptions object
  113164. */
  113165. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  113166. /**
  113167. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  113168. * @param targetFrameRate defines the target frame rate (60 by default)
  113169. * @returns a SceneOptimizerOptions object
  113170. */
  113171. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  113172. /**
  113173. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  113174. * @param targetFrameRate defines the target frame rate (60 by default)
  113175. * @returns a SceneOptimizerOptions object
  113176. */
  113177. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  113178. }
  113179. /**
  113180. * Class used to run optimizations in order to reach a target frame rate
  113181. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  113182. */
  113183. export class SceneOptimizer implements IDisposable {
  113184. private _isRunning;
  113185. private _options;
  113186. private _scene;
  113187. private _currentPriorityLevel;
  113188. private _targetFrameRate;
  113189. private _trackerDuration;
  113190. private _currentFrameRate;
  113191. private _sceneDisposeObserver;
  113192. private _improvementMode;
  113193. /**
  113194. * Defines an observable called when the optimizer reaches the target frame rate
  113195. */
  113196. onSuccessObservable: Observable<SceneOptimizer>;
  113197. /**
  113198. * Defines an observable called when the optimizer enables an optimization
  113199. */
  113200. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  113201. /**
  113202. * Defines an observable called when the optimizer is not able to reach the target frame rate
  113203. */
  113204. onFailureObservable: Observable<SceneOptimizer>;
  113205. /**
  113206. * Gets a boolean indicating if the optimizer is in improvement mode
  113207. */
  113208. readonly isInImprovementMode: boolean;
  113209. /**
  113210. * Gets the current priority level (0 at start)
  113211. */
  113212. readonly currentPriorityLevel: number;
  113213. /**
  113214. * Gets the current frame rate checked by the SceneOptimizer
  113215. */
  113216. readonly currentFrameRate: number;
  113217. /**
  113218. * Gets or sets the current target frame rate (60 by default)
  113219. */
  113220. /**
  113221. * Gets or sets the current target frame rate (60 by default)
  113222. */
  113223. targetFrameRate: number;
  113224. /**
  113225. * Gets or sets the current interval between two checks (every 2000ms by default)
  113226. */
  113227. /**
  113228. * Gets or sets the current interval between two checks (every 2000ms by default)
  113229. */
  113230. trackerDuration: number;
  113231. /**
  113232. * Gets the list of active optimizations
  113233. */
  113234. readonly optimizations: SceneOptimization[];
  113235. /**
  113236. * Creates a new SceneOptimizer
  113237. * @param scene defines the scene to work on
  113238. * @param options defines the options to use with the SceneOptimizer
  113239. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  113240. * @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)
  113241. */
  113242. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  113243. /**
  113244. * Stops the current optimizer
  113245. */
  113246. stop(): void;
  113247. /**
  113248. * Reset the optimizer to initial step (current priority level = 0)
  113249. */
  113250. reset(): void;
  113251. /**
  113252. * Start the optimizer. By default it will try to reach a specific framerate
  113253. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  113254. */
  113255. start(): void;
  113256. private _checkCurrentState;
  113257. /**
  113258. * Release all resources
  113259. */
  113260. dispose(): void;
  113261. /**
  113262. * Helper function to create a SceneOptimizer with one single line of code
  113263. * @param scene defines the scene to work on
  113264. * @param options defines the options to use with the SceneOptimizer
  113265. * @param onSuccess defines a callback to call on success
  113266. * @param onFailure defines a callback to call on failure
  113267. * @returns the new SceneOptimizer object
  113268. */
  113269. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  113270. }
  113271. }
  113272. declare module BABYLON {
  113273. /**
  113274. * Class used to serialize a scene into a string
  113275. */
  113276. export class SceneSerializer {
  113277. /**
  113278. * Clear cache used by a previous serialization
  113279. */
  113280. static ClearCache(): void;
  113281. /**
  113282. * Serialize a scene into a JSON compatible object
  113283. * @param scene defines the scene to serialize
  113284. * @returns a JSON compatible object
  113285. */
  113286. static Serialize(scene: Scene): any;
  113287. /**
  113288. * Serialize a mesh into a JSON compatible object
  113289. * @param toSerialize defines the mesh to serialize
  113290. * @param withParents defines if parents must be serialized as well
  113291. * @param withChildren defines if children must be serialized as well
  113292. * @returns a JSON compatible object
  113293. */
  113294. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  113295. }
  113296. }
  113297. declare module BABYLON {
  113298. /**
  113299. * This represents the different options avilable for the video capture.
  113300. */
  113301. export interface VideoRecorderOptions {
  113302. /** Defines the mime type of the video */
  113303. mimeType: string;
  113304. /** Defines the video the video should be recorded at */
  113305. fps: number;
  113306. /** Defines the chunk size for the recording data */
  113307. recordChunckSize: number;
  113308. /** The audio tracks to attach to the record */
  113309. audioTracks?: MediaStreamTrack[];
  113310. }
  113311. /**
  113312. * This can helps recording videos from BabylonJS.
  113313. * This is based on the available WebRTC functionalities of the browser.
  113314. *
  113315. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  113316. */
  113317. export class VideoRecorder {
  113318. private static readonly _defaultOptions;
  113319. /**
  113320. * Returns wehther or not the VideoRecorder is available in your browser.
  113321. * @param engine Defines the Babylon Engine to check the support for
  113322. * @returns true if supported otherwise false
  113323. */
  113324. static IsSupported(engine: Engine): boolean;
  113325. private readonly _options;
  113326. private _canvas;
  113327. private _mediaRecorder;
  113328. private _recordedChunks;
  113329. private _fileName;
  113330. private _resolve;
  113331. private _reject;
  113332. /**
  113333. * True wether a recording is already in progress.
  113334. */
  113335. readonly isRecording: boolean;
  113336. /**
  113337. * Create a new VideoCapture object which can help converting what you see in Babylon to
  113338. * a video file.
  113339. * @param engine Defines the BabylonJS Engine you wish to record
  113340. * @param options Defines options that can be used to customized the capture
  113341. */
  113342. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  113343. /**
  113344. * Stops the current recording before the default capture timeout passed in the startRecording
  113345. * functions.
  113346. */
  113347. stopRecording(): void;
  113348. /**
  113349. * Starts recording the canvas for a max duration specified in parameters.
  113350. * @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.
  113351. * @param maxDuration Defines the maximum recording time in seconds.
  113352. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  113353. * @return a promise callback at the end of the recording with the video data in Blob.
  113354. */
  113355. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  113356. /**
  113357. * Releases internal resources used during the recording.
  113358. */
  113359. dispose(): void;
  113360. private _handleDataAvailable;
  113361. private _handleError;
  113362. private _handleStop;
  113363. }
  113364. }
  113365. declare module BABYLON {
  113366. /**
  113367. * Helper class to push actions to a pool of workers.
  113368. */
  113369. export class WorkerPool implements IDisposable {
  113370. private _workerInfos;
  113371. private _pendingActions;
  113372. /**
  113373. * Constructor
  113374. * @param workers Array of workers to use for actions
  113375. */
  113376. constructor(workers: Array<Worker>);
  113377. /**
  113378. * Terminates all workers and clears any pending actions.
  113379. */
  113380. dispose(): void;
  113381. /**
  113382. * Pushes an action to the worker pool. If all the workers are active, the action will be
  113383. * pended until a worker has completed its action.
  113384. * @param action The action to perform. Call onComplete when the action is complete.
  113385. */
  113386. push(action: (worker: Worker, onComplete: () => void) => void): void;
  113387. private _execute;
  113388. }
  113389. }
  113390. declare module BABYLON {
  113391. /**
  113392. * Class containing a set of static utilities functions for screenshots
  113393. */
  113394. export class ScreenshotTools {
  113395. /**
  113396. * Captures a screenshot of the current rendering
  113397. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  113398. * @param engine defines the rendering engine
  113399. * @param camera defines the source camera
  113400. * @param size This parameter can be set to a single number or to an object with the
  113401. * following (optional) properties: precision, width, height. If a single number is passed,
  113402. * it will be used for both width and height. If an object is passed, the screenshot size
  113403. * will be derived from the parameters. The precision property is a multiplier allowing
  113404. * rendering at a higher or lower resolution
  113405. * @param successCallback defines the callback receives a single parameter which contains the
  113406. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  113407. * src parameter of an <img> to display it
  113408. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  113409. * Check your browser for supported MIME types
  113410. */
  113411. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  113412. /**
  113413. * Generates an image screenshot from the specified camera.
  113414. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  113415. * @param engine The engine to use for rendering
  113416. * @param camera The camera to use for rendering
  113417. * @param size This parameter can be set to a single number or to an object with the
  113418. * following (optional) properties: precision, width, height. If a single number is passed,
  113419. * it will be used for both width and height. If an object is passed, the screenshot size
  113420. * will be derived from the parameters. The precision property is a multiplier allowing
  113421. * rendering at a higher or lower resolution
  113422. * @param successCallback The callback receives a single parameter which contains the
  113423. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  113424. * src parameter of an <img> to display it
  113425. * @param mimeType The MIME type of the screenshot image (default: image/png).
  113426. * Check your browser for supported MIME types
  113427. * @param samples Texture samples (default: 1)
  113428. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  113429. * @param fileName A name for for the downloaded file.
  113430. */
  113431. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  113432. }
  113433. }
  113434. declare module BABYLON {
  113435. /**
  113436. * A cursor which tracks a point on a path
  113437. */
  113438. export class PathCursor {
  113439. private path;
  113440. /**
  113441. * Stores path cursor callbacks for when an onchange event is triggered
  113442. */
  113443. private _onchange;
  113444. /**
  113445. * The value of the path cursor
  113446. */
  113447. value: number;
  113448. /**
  113449. * The animation array of the path cursor
  113450. */
  113451. animations: Animation[];
  113452. /**
  113453. * Initializes the path cursor
  113454. * @param path The path to track
  113455. */
  113456. constructor(path: Path2);
  113457. /**
  113458. * Gets the cursor point on the path
  113459. * @returns A point on the path cursor at the cursor location
  113460. */
  113461. getPoint(): Vector3;
  113462. /**
  113463. * Moves the cursor ahead by the step amount
  113464. * @param step The amount to move the cursor forward
  113465. * @returns This path cursor
  113466. */
  113467. moveAhead(step?: number): PathCursor;
  113468. /**
  113469. * Moves the cursor behind by the step amount
  113470. * @param step The amount to move the cursor back
  113471. * @returns This path cursor
  113472. */
  113473. moveBack(step?: number): PathCursor;
  113474. /**
  113475. * Moves the cursor by the step amount
  113476. * If the step amount is greater than one, an exception is thrown
  113477. * @param step The amount to move the cursor
  113478. * @returns This path cursor
  113479. */
  113480. move(step: number): PathCursor;
  113481. /**
  113482. * Ensures that the value is limited between zero and one
  113483. * @returns This path cursor
  113484. */
  113485. private ensureLimits;
  113486. /**
  113487. * Runs onchange callbacks on change (used by the animation engine)
  113488. * @returns This path cursor
  113489. */
  113490. private raiseOnChange;
  113491. /**
  113492. * Executes a function on change
  113493. * @param f A path cursor onchange callback
  113494. * @returns This path cursor
  113495. */
  113496. onchange(f: (cursor: PathCursor) => void): PathCursor;
  113497. }
  113498. }
  113499. declare module BABYLON {
  113500. /** @hidden */
  113501. export var blurPixelShader: {
  113502. name: string;
  113503. shader: string;
  113504. };
  113505. }
  113506. declare module BABYLON {
  113507. /** @hidden */
  113508. export var bones300Declaration: {
  113509. name: string;
  113510. shader: string;
  113511. };
  113512. }
  113513. declare module BABYLON {
  113514. /** @hidden */
  113515. export var instances300Declaration: {
  113516. name: string;
  113517. shader: string;
  113518. };
  113519. }
  113520. declare module BABYLON {
  113521. /** @hidden */
  113522. export var pointCloudVertexDeclaration: {
  113523. name: string;
  113524. shader: string;
  113525. };
  113526. }
  113527. // Mixins
  113528. interface Window {
  113529. mozIndexedDB: IDBFactory;
  113530. webkitIndexedDB: IDBFactory;
  113531. msIndexedDB: IDBFactory;
  113532. webkitURL: typeof URL;
  113533. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  113534. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  113535. WebGLRenderingContext: WebGLRenderingContext;
  113536. MSGesture: MSGesture;
  113537. CANNON: any;
  113538. AudioContext: AudioContext;
  113539. webkitAudioContext: AudioContext;
  113540. PointerEvent: any;
  113541. Math: Math;
  113542. Uint8Array: Uint8ArrayConstructor;
  113543. Float32Array: Float32ArrayConstructor;
  113544. mozURL: typeof URL;
  113545. msURL: typeof URL;
  113546. VRFrameData: any; // WebVR, from specs 1.1
  113547. DracoDecoderModule: any;
  113548. setImmediate(handler: (...args: any[]) => void): number;
  113549. }
  113550. interface HTMLCanvasElement {
  113551. requestPointerLock(): void;
  113552. msRequestPointerLock?(): void;
  113553. mozRequestPointerLock?(): void;
  113554. webkitRequestPointerLock?(): void;
  113555. /** Track wether a record is in progress */
  113556. isRecording: boolean;
  113557. /** Capture Stream method defined by some browsers */
  113558. captureStream(fps?: number): MediaStream;
  113559. }
  113560. interface CanvasRenderingContext2D {
  113561. msImageSmoothingEnabled: boolean;
  113562. }
  113563. interface MouseEvent {
  113564. mozMovementX: number;
  113565. mozMovementY: number;
  113566. webkitMovementX: number;
  113567. webkitMovementY: number;
  113568. msMovementX: number;
  113569. msMovementY: number;
  113570. }
  113571. interface Navigator {
  113572. mozGetVRDevices: (any: any) => any;
  113573. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  113574. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  113575. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  113576. webkitGetGamepads(): Gamepad[];
  113577. msGetGamepads(): Gamepad[];
  113578. webkitGamepads(): Gamepad[];
  113579. }
  113580. interface HTMLVideoElement {
  113581. mozSrcObject: any;
  113582. }
  113583. interface Math {
  113584. fround(x: number): number;
  113585. imul(a: number, b: number): number;
  113586. }
  113587. interface WebGLProgram {
  113588. context?: WebGLRenderingContext;
  113589. vertexShader?: WebGLShader;
  113590. fragmentShader?: WebGLShader;
  113591. isParallelCompiled: boolean;
  113592. onCompiled?: () => void;
  113593. }
  113594. interface WebGLRenderingContext {
  113595. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  113596. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  113597. vertexAttribDivisor(index: number, divisor: number): void;
  113598. createVertexArray(): any;
  113599. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  113600. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  113601. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  113602. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  113603. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  113604. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  113605. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  113606. // Queries
  113607. createQuery(): WebGLQuery;
  113608. deleteQuery(query: WebGLQuery): void;
  113609. beginQuery(target: number, query: WebGLQuery): void;
  113610. endQuery(target: number): void;
  113611. getQueryParameter(query: WebGLQuery, pname: number): any;
  113612. getQuery(target: number, pname: number): any;
  113613. MAX_SAMPLES: number;
  113614. RGBA8: number;
  113615. READ_FRAMEBUFFER: number;
  113616. DRAW_FRAMEBUFFER: number;
  113617. UNIFORM_BUFFER: number;
  113618. HALF_FLOAT_OES: number;
  113619. RGBA16F: number;
  113620. RGBA32F: number;
  113621. R32F: number;
  113622. RG32F: number;
  113623. RGB32F: number;
  113624. R16F: number;
  113625. RG16F: number;
  113626. RGB16F: number;
  113627. RED: number;
  113628. RG: number;
  113629. R8: number;
  113630. RG8: number;
  113631. UNSIGNED_INT_24_8: number;
  113632. DEPTH24_STENCIL8: number;
  113633. /* Multiple Render Targets */
  113634. drawBuffers(buffers: number[]): void;
  113635. readBuffer(src: number): void;
  113636. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  113637. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  113638. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  113639. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  113640. // Occlusion Query
  113641. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  113642. ANY_SAMPLES_PASSED: number;
  113643. QUERY_RESULT_AVAILABLE: number;
  113644. QUERY_RESULT: number;
  113645. }
  113646. interface WebGLBuffer {
  113647. references: number;
  113648. capacity: number;
  113649. is32Bits: boolean;
  113650. }
  113651. interface WebGLProgram {
  113652. transformFeedback?: WebGLTransformFeedback | null;
  113653. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  113654. }
  113655. interface EXT_disjoint_timer_query {
  113656. QUERY_COUNTER_BITS_EXT: number;
  113657. TIME_ELAPSED_EXT: number;
  113658. TIMESTAMP_EXT: number;
  113659. GPU_DISJOINT_EXT: number;
  113660. QUERY_RESULT_EXT: number;
  113661. QUERY_RESULT_AVAILABLE_EXT: number;
  113662. queryCounterEXT(query: WebGLQuery, target: number): void;
  113663. createQueryEXT(): WebGLQuery;
  113664. beginQueryEXT(target: number, query: WebGLQuery): void;
  113665. endQueryEXT(target: number): void;
  113666. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  113667. deleteQueryEXT(query: WebGLQuery): void;
  113668. }
  113669. interface WebGLUniformLocation {
  113670. _currentState: any;
  113671. }
  113672. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  113673. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  113674. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  113675. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  113676. interface WebGLRenderingContext {
  113677. readonly RASTERIZER_DISCARD: number;
  113678. readonly DEPTH_COMPONENT24: number;
  113679. readonly TEXTURE_3D: number;
  113680. readonly TEXTURE_2D_ARRAY: number;
  113681. readonly TEXTURE_COMPARE_FUNC: number;
  113682. readonly TEXTURE_COMPARE_MODE: number;
  113683. readonly COMPARE_REF_TO_TEXTURE: number;
  113684. readonly TEXTURE_WRAP_R: number;
  113685. readonly HALF_FLOAT: number;
  113686. readonly RGB8: number;
  113687. readonly RED_INTEGER: number;
  113688. readonly RG_INTEGER: number;
  113689. readonly RGB_INTEGER: number;
  113690. readonly RGBA_INTEGER: number;
  113691. readonly R8_SNORM: number;
  113692. readonly RG8_SNORM: number;
  113693. readonly RGB8_SNORM: number;
  113694. readonly RGBA8_SNORM: number;
  113695. readonly R8I: number;
  113696. readonly RG8I: number;
  113697. readonly RGB8I: number;
  113698. readonly RGBA8I: number;
  113699. readonly R8UI: number;
  113700. readonly RG8UI: number;
  113701. readonly RGB8UI: number;
  113702. readonly RGBA8UI: number;
  113703. readonly R16I: number;
  113704. readonly RG16I: number;
  113705. readonly RGB16I: number;
  113706. readonly RGBA16I: number;
  113707. readonly R16UI: number;
  113708. readonly RG16UI: number;
  113709. readonly RGB16UI: number;
  113710. readonly RGBA16UI: number;
  113711. readonly R32I: number;
  113712. readonly RG32I: number;
  113713. readonly RGB32I: number;
  113714. readonly RGBA32I: number;
  113715. readonly R32UI: number;
  113716. readonly RG32UI: number;
  113717. readonly RGB32UI: number;
  113718. readonly RGBA32UI: number;
  113719. readonly RGB10_A2UI: number;
  113720. readonly R11F_G11F_B10F: number;
  113721. readonly RGB9_E5: number;
  113722. readonly RGB10_A2: number;
  113723. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  113724. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  113725. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  113726. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  113727. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  113728. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  113729. 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;
  113730. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  113731. readonly TRANSFORM_FEEDBACK: number;
  113732. readonly INTERLEAVED_ATTRIBS: number;
  113733. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  113734. createTransformFeedback(): WebGLTransformFeedback;
  113735. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  113736. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  113737. beginTransformFeedback(primitiveMode: number): void;
  113738. endTransformFeedback(): void;
  113739. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  113740. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  113741. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  113742. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  113743. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  113744. }
  113745. interface ImageBitmap {
  113746. readonly width: number;
  113747. readonly height: number;
  113748. close(): void;
  113749. }
  113750. interface WebGLQuery extends WebGLObject {
  113751. }
  113752. declare var WebGLQuery: {
  113753. prototype: WebGLQuery;
  113754. new(): WebGLQuery;
  113755. };
  113756. interface WebGLSampler extends WebGLObject {
  113757. }
  113758. declare var WebGLSampler: {
  113759. prototype: WebGLSampler;
  113760. new(): WebGLSampler;
  113761. };
  113762. interface WebGLSync extends WebGLObject {
  113763. }
  113764. declare var WebGLSync: {
  113765. prototype: WebGLSync;
  113766. new(): WebGLSync;
  113767. };
  113768. interface WebGLTransformFeedback extends WebGLObject {
  113769. }
  113770. declare var WebGLTransformFeedback: {
  113771. prototype: WebGLTransformFeedback;
  113772. new(): WebGLTransformFeedback;
  113773. };
  113774. interface WebGLVertexArrayObject extends WebGLObject {
  113775. }
  113776. declare var WebGLVertexArrayObject: {
  113777. prototype: WebGLVertexArrayObject;
  113778. new(): WebGLVertexArrayObject;
  113779. };
  113780. // Type definitions for WebVR API
  113781. // Project: https://w3c.github.io/webvr/
  113782. // Definitions by: six a <https://github.com/lostfictions>
  113783. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  113784. interface VRDisplay extends EventTarget {
  113785. /**
  113786. * Dictionary of capabilities describing the VRDisplay.
  113787. */
  113788. readonly capabilities: VRDisplayCapabilities;
  113789. /**
  113790. * z-depth defining the far plane of the eye view frustum
  113791. * enables mapping of values in the render target depth
  113792. * attachment to scene coordinates. Initially set to 10000.0.
  113793. */
  113794. depthFar: number;
  113795. /**
  113796. * z-depth defining the near plane of the eye view frustum
  113797. * enables mapping of values in the render target depth
  113798. * attachment to scene coordinates. Initially set to 0.01.
  113799. */
  113800. depthNear: number;
  113801. /**
  113802. * An identifier for this distinct VRDisplay. Used as an
  113803. * association point in the Gamepad API.
  113804. */
  113805. readonly displayId: number;
  113806. /**
  113807. * A display name, a user-readable name identifying it.
  113808. */
  113809. readonly displayName: string;
  113810. readonly isConnected: boolean;
  113811. readonly isPresenting: boolean;
  113812. /**
  113813. * If this VRDisplay supports room-scale experiences, the optional
  113814. * stage attribute contains details on the room-scale parameters.
  113815. */
  113816. readonly stageParameters: VRStageParameters | null;
  113817. /**
  113818. * Passing the value returned by `requestAnimationFrame` to
  113819. * `cancelAnimationFrame` will unregister the callback.
  113820. * @param handle Define the hanle of the request to cancel
  113821. */
  113822. cancelAnimationFrame(handle: number): void;
  113823. /**
  113824. * Stops presenting to the VRDisplay.
  113825. * @returns a promise to know when it stopped
  113826. */
  113827. exitPresent(): Promise<void>;
  113828. /**
  113829. * Return the current VREyeParameters for the given eye.
  113830. * @param whichEye Define the eye we want the parameter for
  113831. * @returns the eye parameters
  113832. */
  113833. getEyeParameters(whichEye: string): VREyeParameters;
  113834. /**
  113835. * Populates the passed VRFrameData with the information required to render
  113836. * the current frame.
  113837. * @param frameData Define the data structure to populate
  113838. * @returns true if ok otherwise false
  113839. */
  113840. getFrameData(frameData: VRFrameData): boolean;
  113841. /**
  113842. * Get the layers currently being presented.
  113843. * @returns the list of VR layers
  113844. */
  113845. getLayers(): VRLayer[];
  113846. /**
  113847. * Return a VRPose containing the future predicted pose of the VRDisplay
  113848. * when the current frame will be presented. The value returned will not
  113849. * change until JavaScript has returned control to the browser.
  113850. *
  113851. * The VRPose will contain the position, orientation, velocity,
  113852. * and acceleration of each of these properties.
  113853. * @returns the pose object
  113854. */
  113855. getPose(): VRPose;
  113856. /**
  113857. * Return the current instantaneous pose of the VRDisplay, with no
  113858. * prediction applied.
  113859. * @returns the current instantaneous pose
  113860. */
  113861. getImmediatePose(): VRPose;
  113862. /**
  113863. * The callback passed to `requestAnimationFrame` will be called
  113864. * any time a new frame should be rendered. When the VRDisplay is
  113865. * presenting the callback will be called at the native refresh
  113866. * rate of the HMD. When not presenting this function acts
  113867. * identically to how window.requestAnimationFrame acts. Content should
  113868. * make no assumptions of frame rate or vsync behavior as the HMD runs
  113869. * asynchronously from other displays and at differing refresh rates.
  113870. * @param callback Define the eaction to run next frame
  113871. * @returns the request handle it
  113872. */
  113873. requestAnimationFrame(callback: FrameRequestCallback): number;
  113874. /**
  113875. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  113876. * Repeat calls while already presenting will update the VRLayers being displayed.
  113877. * @param layers Define the list of layer to present
  113878. * @returns a promise to know when the request has been fulfilled
  113879. */
  113880. requestPresent(layers: VRLayer[]): Promise<void>;
  113881. /**
  113882. * Reset the pose for this display, treating its current position and
  113883. * orientation as the "origin/zero" values. VRPose.position,
  113884. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  113885. * updated when calling resetPose(). This should be called in only
  113886. * sitting-space experiences.
  113887. */
  113888. resetPose(): void;
  113889. /**
  113890. * The VRLayer provided to the VRDisplay will be captured and presented
  113891. * in the HMD. Calling this function has the same effect on the source
  113892. * canvas as any other operation that uses its source image, and canvases
  113893. * created without preserveDrawingBuffer set to true will be cleared.
  113894. * @param pose Define the pose to submit
  113895. */
  113896. submitFrame(pose?: VRPose): void;
  113897. }
  113898. declare var VRDisplay: {
  113899. prototype: VRDisplay;
  113900. new(): VRDisplay;
  113901. };
  113902. interface VRLayer {
  113903. leftBounds?: number[] | Float32Array | null;
  113904. rightBounds?: number[] | Float32Array | null;
  113905. source?: HTMLCanvasElement | null;
  113906. }
  113907. interface VRDisplayCapabilities {
  113908. readonly canPresent: boolean;
  113909. readonly hasExternalDisplay: boolean;
  113910. readonly hasOrientation: boolean;
  113911. readonly hasPosition: boolean;
  113912. readonly maxLayers: number;
  113913. }
  113914. interface VREyeParameters {
  113915. /** @deprecated */
  113916. readonly fieldOfView: VRFieldOfView;
  113917. readonly offset: Float32Array;
  113918. readonly renderHeight: number;
  113919. readonly renderWidth: number;
  113920. }
  113921. interface VRFieldOfView {
  113922. readonly downDegrees: number;
  113923. readonly leftDegrees: number;
  113924. readonly rightDegrees: number;
  113925. readonly upDegrees: number;
  113926. }
  113927. interface VRFrameData {
  113928. readonly leftProjectionMatrix: Float32Array;
  113929. readonly leftViewMatrix: Float32Array;
  113930. readonly pose: VRPose;
  113931. readonly rightProjectionMatrix: Float32Array;
  113932. readonly rightViewMatrix: Float32Array;
  113933. readonly timestamp: number;
  113934. }
  113935. interface VRPose {
  113936. readonly angularAcceleration: Float32Array | null;
  113937. readonly angularVelocity: Float32Array | null;
  113938. readonly linearAcceleration: Float32Array | null;
  113939. readonly linearVelocity: Float32Array | null;
  113940. readonly orientation: Float32Array | null;
  113941. readonly position: Float32Array | null;
  113942. readonly timestamp: number;
  113943. }
  113944. interface VRStageParameters {
  113945. sittingToStandingTransform?: Float32Array;
  113946. sizeX?: number;
  113947. sizeY?: number;
  113948. }
  113949. interface Navigator {
  113950. getVRDisplays(): Promise<VRDisplay[]>;
  113951. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  113952. }
  113953. interface Window {
  113954. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  113955. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  113956. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  113957. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  113958. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  113959. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  113960. }
  113961. interface Gamepad {
  113962. readonly displayId: number;
  113963. }
  113964. interface XRDevice {
  113965. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  113966. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  113967. }
  113968. interface XRSession {
  113969. getInputSources(): Array<any>;
  113970. baseLayer: XRWebGLLayer;
  113971. requestFrameOfReference(type: string): Promise<void>;
  113972. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  113973. end(): Promise<void>;
  113974. requestAnimationFrame: Function;
  113975. addEventListener: Function;
  113976. }
  113977. interface XRSessionCreationOptions {
  113978. outputContext?: WebGLRenderingContext | null;
  113979. immersive?: boolean;
  113980. environmentIntegration?: boolean;
  113981. }
  113982. interface XRLayer {
  113983. getViewport: Function;
  113984. framebufferWidth: number;
  113985. framebufferHeight: number;
  113986. }
  113987. interface XRView {
  113988. projectionMatrix: Float32Array;
  113989. }
  113990. interface XRFrame {
  113991. getDevicePose: Function;
  113992. getInputPose: Function;
  113993. views: Array<XRView>;
  113994. baseLayer: XRLayer;
  113995. }
  113996. interface XRFrameOfReference {
  113997. }
  113998. interface XRWebGLLayer extends XRLayer {
  113999. framebuffer: WebGLFramebuffer;
  114000. }
  114001. declare var XRWebGLLayer: {
  114002. prototype: XRWebGLLayer;
  114003. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  114004. };